mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 05:48:12 +00:00
LibSQL: First cut of SQL WHERE
clause
Filters matching rows by doing a table scan and evaluating the `WHERE` expression for every row. Does not use indexes, for one because they do not exist yet.
This commit is contained in:
parent
9d1e27d8a8
commit
0cfb5eec32
1 changed files with 7 additions and 1 deletions
|
@ -34,9 +34,15 @@ RefPtr<SQLResult> Select::execute(ExecutionContext& context) const
|
|||
}
|
||||
context.result = SQLResult::construct();
|
||||
AK::NonnullRefPtr<TupleDescriptor> descriptor = AK::adopt_ref(*new TupleDescriptor);
|
||||
Tuple tuple(descriptor);
|
||||
for (auto& row : context.database->select_all(*table)) {
|
||||
context.current_row = &row;
|
||||
Tuple tuple(descriptor);
|
||||
if (where_clause()) {
|
||||
auto where_result = where_clause()->evaluate(context);
|
||||
if (!where_result)
|
||||
continue;
|
||||
}
|
||||
tuple.clear();
|
||||
for (auto& col : columns) {
|
||||
auto value = col.expression()->evaluate(context);
|
||||
tuple.append(value);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue