mirror of
git://source.winehq.org/git/wine.git
synced 2024-10-31 08:49:15 +00:00
msi: Fix merging tables with string primary keys.
This commit is contained in:
parent
a807e86dd7
commit
987d17dc6f
2 changed files with 44 additions and 8 deletions
|
@ -1174,8 +1174,8 @@ done:
|
|||
static LPWSTR get_key_value(MSIQUERY *view, LPCWSTR key, MSIRECORD *rec)
|
||||
{
|
||||
MSIRECORD *colnames;
|
||||
LPWSTR str;
|
||||
UINT r, i = 0;
|
||||
LPWSTR str, val;
|
||||
UINT r, i = 0, sz = 0;
|
||||
int cmp;
|
||||
|
||||
r = MSI_ViewGetColumnInfo(view, MSICOLINFO_NAMES, &colnames);
|
||||
|
@ -1190,7 +1190,43 @@ static LPWSTR get_key_value(MSIQUERY *view, LPCWSTR key, MSIRECORD *rec)
|
|||
} while (cmp);
|
||||
|
||||
msiobj_release(&colnames->hdr);
|
||||
return msi_dup_record_field(rec, i);
|
||||
|
||||
r = MSI_RecordGetStringW(rec, i, NULL, &sz);
|
||||
if (r != ERROR_SUCCESS)
|
||||
return NULL;
|
||||
sz++;
|
||||
|
||||
if (MSI_RecordGetString(rec, i)) /* check record field is a string */
|
||||
{
|
||||
/* quote string record fields */
|
||||
const WCHAR szQuote[] = {'\'', 0};
|
||||
sz += 2;
|
||||
val = msi_alloc(sz*sizeof(WCHAR));
|
||||
if (!val)
|
||||
return NULL;
|
||||
|
||||
lstrcpyW(val, szQuote);
|
||||
r = MSI_RecordGetStringW(rec, i, val+1, &sz);
|
||||
lstrcpyW(val+1+sz, szQuote);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* do not quote integer record fields */
|
||||
val = msi_alloc(sz*sizeof(WCHAR));
|
||||
if (!val)
|
||||
return NULL;
|
||||
|
||||
r = MSI_RecordGetStringW(rec, i, val, &sz);
|
||||
}
|
||||
|
||||
if (r != ERROR_SUCCESS)
|
||||
{
|
||||
ERR("failed to get string!\n");
|
||||
msi_free(val);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
static LPWSTR create_diff_row_query(MSIDATABASE *merge, MSIQUERY *view,
|
||||
|
|
|
@ -6968,19 +6968,19 @@ static void test_dbmerge(void)
|
|||
|
||||
/* primary key is string */
|
||||
r = MsiDatabaseMergeA(hdb, href, "MergeErrors");
|
||||
todo_wine ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
|
||||
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
|
||||
|
||||
query = "SELECT * FROM `One`";
|
||||
r = do_query(hdb, query, &hrec);
|
||||
todo_wine ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
|
||||
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
|
||||
|
||||
size = MAX_PATH;
|
||||
r = MsiRecordGetStringA(hrec, 1, buf, &size);
|
||||
todo_wine ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
|
||||
todo_wine ok(!lstrcmpA(buf, "hi"), "Expected \"hi\", got \"%s\"\n", buf);
|
||||
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
|
||||
ok(!lstrcmpA(buf, "hi"), "Expected \"hi\", got \"%s\"\n", buf);
|
||||
|
||||
r = MsiRecordGetInteger(hrec, 2);
|
||||
todo_wine ok(r == 1, "Expected 1, got %d\n", r);
|
||||
ok(r == 1, "Expected 1, got %d\n", r);
|
||||
|
||||
MsiCloseHandle(hrec);
|
||||
|
||||
|
|
Loading…
Reference in a new issue