mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-08 12:19:37 +03: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
Notes:
sideshowbarker
2024-07-18 01:54:13 +09:00
Author: https://github.com/JanDeVisser Commit: https://github.com/SerenityOS/serenity/commit/0cfb5eec327 Pull-request: https://github.com/SerenityOS/serenity/pull/10598 Reviewed-by: https://github.com/trflynn89 ✅
@ -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…
Reference in New Issue
Block a user