mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 09:24:57 +00:00
LibSQL+SQLServer+sql: Send and parse the correct number of changed rows
The sql REPL had the created/updated rows swapped by mistake. Also make sure SQLServer fills in the correct value depending on the executed command, and that the DELETE command indicates the rows it deleted.
This commit is contained in:
parent
b9d8c25b0b
commit
b159bdd4fd
3 changed files with 11 additions and 3 deletions
|
@ -31,6 +31,7 @@ ResultOr<ResultSet> Delete::execute(ExecutionContext& context) const
|
|||
TRY(context.database->remove(table_row));
|
||||
|
||||
// FIXME: Implement the RETURNING clause.
|
||||
result.insert_row(table_row, {});
|
||||
}
|
||||
|
||||
return result;
|
||||
|
|
|
@ -94,7 +94,14 @@ Optional<u64> SQLStatement::execute(Vector<SQL::Value> placeholder_values)
|
|||
auto result_size = result.size();
|
||||
next(execution_id, move(result), result_size);
|
||||
} else {
|
||||
client_connection->async_execution_success(statement_id(), execution_id, false, 0, result.size(), 0);
|
||||
if (result.command() == SQL::SQLCommand::Insert)
|
||||
client_connection->async_execution_success(statement_id(), execution_id, false, result.size(), 0, 0);
|
||||
else if (result.command() == SQL::SQLCommand::Update)
|
||||
client_connection->async_execution_success(statement_id(), execution_id, false, 0, result.size(), 0);
|
||||
else if (result.command() == SQL::SQLCommand::Delete)
|
||||
client_connection->async_execution_success(statement_id(), execution_id, false, 0, 0, result.size());
|
||||
else
|
||||
client_connection->async_execution_success(statement_id(), execution_id, false, 0, 0, 0);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -76,9 +76,9 @@ public:
|
|||
|
||||
m_sql_client = SQL::SQLClient::try_create().release_value_but_fixme_should_propagate_errors();
|
||||
|
||||
m_sql_client->on_execution_success = [this](auto, auto, auto has_results, auto updated, auto created, auto deleted) {
|
||||
m_sql_client->on_execution_success = [this](auto, auto, auto has_results, auto created, auto updated, auto deleted) {
|
||||
if (updated != 0 || created != 0 || deleted != 0) {
|
||||
outln("{} row(s) updated, {} created, {} deleted", updated, created, deleted);
|
||||
outln("{} row(s) created, {} updated, {} deleted", created, updated, deleted);
|
||||
}
|
||||
if (!has_results) {
|
||||
read_sql();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue