mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 17:47:44 +00:00
LibSQL: Add better error handling to evaluate
and execute
methods
There was a lot of `VERIFY_NOT_REACHED` error handling going on. Fixed most of those. A bit of a caveat is that after every `evaluate` call for expressions that are part of a statement the error status of the `SQLResult` return value must be called.
This commit is contained in:
parent
0cfb5eec32
commit
9022cf99ff
5 changed files with 125 additions and 55 deletions
|
@ -44,6 +44,7 @@ RefPtr<SQLResult> Insert::execute(ExecutionContext& context) const
|
|||
|
||||
Vector<Row> inserted_rows;
|
||||
inserted_rows.ensure_capacity(m_chained_expressions.size());
|
||||
context.result = SQLResult::construct();
|
||||
for (auto& row_expr : m_chained_expressions) {
|
||||
for (auto& column_def : table_def->columns()) {
|
||||
if (!m_column_names.contains_slow(column_def.name())) {
|
||||
|
@ -51,6 +52,8 @@ RefPtr<SQLResult> Insert::execute(ExecutionContext& context) const
|
|||
}
|
||||
}
|
||||
auto row_value = row_expr.evaluate(context);
|
||||
if (context.result->has_error())
|
||||
return context.result;
|
||||
VERIFY(row_value.type() == SQLType::Tuple);
|
||||
auto values = row_value.to_vector().value();
|
||||
|
||||
|
@ -76,6 +79,7 @@ RefPtr<SQLResult> Insert::execute(ExecutionContext& context) const
|
|||
|
||||
for (auto& inserted_row : inserted_rows) {
|
||||
context.database->insert(inserted_row);
|
||||
// FIXME Error handling
|
||||
}
|
||||
|
||||
return SQLResult::construct(SQLCommand::Insert, 0, m_chained_expressions.size(), 0);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue