Commit 6c95dc64 authored by Mike McCormack's avatar Mike McCormack Committed by Alexandre Julliard

msi: Allow UPDATE queries without a condition.

parent 15bfb30f
...@@ -214,13 +214,23 @@ oneupdate: ...@@ -214,13 +214,23 @@ oneupdate:
TK_UPDATE table TK_SET update_assign_list TK_WHERE expr TK_UPDATE table TK_SET update_assign_list TK_WHERE expr
{ {
SQL_input* sql = (SQL_input*) info; SQL_input* sql = (SQL_input*) info;
MSIVIEW *update = NULL; MSIVIEW *update = NULL;
UPDATE_CreateView( sql->db, &update, $2, $4, $6 ); UPDATE_CreateView( sql->db, &update, $2, $4, $6 );
if( !update ) if( !update )
YYABORT; YYABORT;
$$ = update; $$ = update;
} }
| TK_UPDATE table TK_SET update_assign_list
{
SQL_input* sql = (SQL_input*) info;
MSIVIEW *update = NULL;
UPDATE_CreateView( sql->db, &update, $2, $4, NULL );
if( !update )
YYABORT;
$$ = update;
}
; ;
onedelete: onedelete:
......
...@@ -3093,17 +3093,14 @@ static void test_update(void) ...@@ -3093,17 +3093,14 @@ static void test_update(void)
/* no where condition */ /* no where condition */
query = "UPDATE `Control` SET `Text` = 'this is text'"; query = "UPDATE `Control` SET `Text` = 'this is text'";
todo_wine r = MsiDatabaseOpenView(hdb, query, &view);
{ ok(r == ERROR_SUCCESS, "Expected ERROR_SUCESS, got %d\n", r);
r = MsiDatabaseOpenView(hdb, query, &view); r = MsiViewExecute(view, 0);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCESS, got %d\n", r); ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
r = MsiViewExecute(view, 0); r = MsiViewClose(view);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r); ok(r == ERROR_SUCCESS, "MsiViewClose failed\n");
r = MsiViewClose(view); r = MsiCloseHandle(view);
ok(r == ERROR_SUCCESS, "MsiViewClose failed\n"); ok(r == ERROR_SUCCESS, "MsiCloseHandle failed\n");
r = MsiCloseHandle(view);
ok(r == ERROR_SUCCESS, "MsiCloseHandle failed\n");
}
/* check the modified text */ /* check the modified text */
query = "SELECT `Text` FROM `Control`"; query = "SELECT `Text` FROM `Control`";
...@@ -3138,10 +3135,7 @@ static void test_update(void) ...@@ -3138,10 +3135,7 @@ static void test_update(void)
size = MAX_PATH; size = MAX_PATH;
r = MsiRecordGetString(rec, 1, result, &size); r = MsiRecordGetString(rec, 1, result, &size);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r); ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
todo_wine ok(!lstrcmp(result, "this is text"), "Expected `this is text`, got %s\n", result);
{
ok(!lstrcmp(result, "this is text"), "Expected `this is text`, got %s\n", result);
}
MsiCloseHandle(rec); MsiCloseHandle(rec);
......
...@@ -199,14 +199,19 @@ UINT UPDATE_CreateView( MSIDATABASE *db, MSIVIEW **view, LPWSTR table, ...@@ -199,14 +199,19 @@ UINT UPDATE_CreateView( MSIDATABASE *db, MSIVIEW **view, LPWSTR table,
if( r != ERROR_SUCCESS ) if( r != ERROR_SUCCESS )
return r; return r;
/* add conditions first */ if (expr)
r = WHERE_CreateView( db, &wv, tv, expr );
if( r != ERROR_SUCCESS )
{ {
tv->ops->delete( tv ); /* add conditions first */
return r; r = WHERE_CreateView( db, &wv, tv, expr );
if( r != ERROR_SUCCESS )
{
tv->ops->delete( tv );
return r;
}
} }
else
wv = tv;
/* then select the columns we want */ /* then select the columns we want */
r = SELECT_CreateView( db, &sv, wv, columns ); r = SELECT_CreateView( db, &sv, wv, columns );
if( r != ERROR_SUCCESS ) if( r != ERROR_SUCCESS )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment