1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 06:57:44 +00:00

LibSQL: Do not crash when SELECTing from an empty table

The crash was caused by getting the first element of an empty vector.
This commit is contained in:
Timothy Flynn 2022-02-09 17:10:08 -05:00 committed by Linus Groh
parent 373b467302
commit f1f0770d68
2 changed files with 13 additions and 2 deletions

View file

@ -177,6 +177,17 @@ TEST_CASE(insert_without_column_names)
EXPECT_EQ(rows_or_error.value().size(), 2u);
}
TEST_CASE(select_from_empty_table)
{
ScopeGuard guard([]() { unlink(db_name); });
auto database = SQL::Database::construct(db_name);
EXPECT(!database->open().is_error());
create_table(database);
auto result = execute(database, "SELECT * FROM TestSchema.TestTable;");
EXPECT(!result.is_error());
EXPECT(!result.has_results());
}
TEST_CASE(select_from_table)
{
ScopeGuard guard([]() { unlink(db_name); });