mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-05-01 12:07:14 +02:00
LibSQL: Allow expressions and column names in SELECT ... FROM
Up to now the only ``SELECT`` statement that worked was ``SELECT * FROM <table>``. This commit allows a column list consisting of column names and expressions in addition to ``*``. ``WHERE`` still doesn't work though.
This commit is contained in:
committed by
Andreas Kling
parent
f33a288ca4
commit
fe50598a03
Notes:
sideshowbarker
2024-07-18 03:02:56 +09:00
Author: https://github.com/JanDeVisser Commit: https://github.com/SerenityOS/serenity/commit/fe50598a03e Pull-request: https://github.com/SerenityOS/serenity/pull/10094 Reviewed-by: https://github.com/trflynn89 ✅
@@ -87,4 +87,17 @@ Value UnaryOperatorExpression::evaluate(ExecutionContext& context) const
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
Value ColumnNameExpression::evaluate(ExecutionContext& context) const
|
||||
{
|
||||
auto& descriptor = *context.current_row->descriptor();
|
||||
VERIFY(context.current_row->size() == descriptor.size());
|
||||
for (auto ix = 0u; ix < context.current_row->size(); ix++) {
|
||||
auto& column_descriptor = descriptor[ix];
|
||||
if (column_descriptor.name == column_name())
|
||||
return { (*context.current_row)[ix] };
|
||||
}
|
||||
// TODO: Error handling.
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user