1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 09:38:11 +00:00

LibSQL: Add 'schema' and 'table' to TupleElementDescriptor

These are needed to distinguish columns from different tables with the
same column name in one and the same (joined) Tuple. Not quite happy
yet with this API; I think some sort of hierarchical structure would be
better but we'll burn that bridge when we get there :^)
This commit is contained in:
Jan de Visser 2021-11-02 16:39:00 -04:00 committed by Andreas Kling
parent c2c47fb9bb
commit 7ea54db430
7 changed files with 27 additions and 25 deletions

View file

@ -286,8 +286,8 @@ TEST_CASE(serialize_boolean_value)
TEST_CASE(tuple_value)
{
NonnullRefPtr<SQL::TupleDescriptor> descriptor = adopt_ref(*new SQL::TupleDescriptor);
descriptor->append({ "col1", SQL::SQLType::Text, SQL::Order::Ascending });
descriptor->append({ "col2", SQL::SQLType::Integer, SQL::Order::Descending });
descriptor->append({ "schema", "table", "col1", SQL::SQLType::Text, SQL::Order::Ascending });
descriptor->append({ "schema", "table", "col2", SQL::SQLType::Integer, SQL::Order::Descending });
auto v = SQL::Value::create_tuple(descriptor);
Vector<SQL::Value> values;
@ -303,8 +303,8 @@ TEST_CASE(tuple_value)
TEST_CASE(copy_tuple_value)
{
NonnullRefPtr<SQL::TupleDescriptor> descriptor = adopt_ref(*new SQL::TupleDescriptor);
descriptor->append({ "col1", SQL::SQLType::Text, SQL::Order::Ascending });
descriptor->append({ "col2", SQL::SQLType::Integer, SQL::Order::Descending });
descriptor->append({ "schema", "table", "col1", SQL::SQLType::Text, SQL::Order::Ascending });
descriptor->append({ "schema", "table", "col2", SQL::SQLType::Integer, SQL::Order::Descending });
auto v = SQL::Value::create_tuple(descriptor);
Vector<SQL::Value> values;
@ -321,7 +321,7 @@ TEST_CASE(copy_tuple_value)
TEST_CASE(tuple_value_wrong_type)
{
NonnullRefPtr<SQL::TupleDescriptor> descriptor = adopt_ref(*new SQL::TupleDescriptor);
descriptor->append({ "col1", SQL::SQLType::Text, SQL::Order::Ascending });
descriptor->append({ "schema", "table", "col1", SQL::SQLType::Text, SQL::Order::Ascending });
auto v = SQL::Value::create_tuple(descriptor);
Vector<SQL::Value> values;
@ -333,7 +333,7 @@ TEST_CASE(tuple_value_wrong_type)
TEST_CASE(tuple_value_too_many_values)
{
NonnullRefPtr<SQL::TupleDescriptor> descriptor = adopt_ref(*new SQL::TupleDescriptor);
descriptor->append({ "col1", SQL::SQLType::Text, SQL::Order::Ascending });
descriptor->append({ "schema", "table", "col1", SQL::SQLType::Text, SQL::Order::Ascending });
auto v = SQL::Value::create_tuple(descriptor);
Vector<SQL::Value> values;
@ -346,8 +346,8 @@ TEST_CASE(tuple_value_too_many_values)
TEST_CASE(tuple_value_not_enough_values)
{
NonnullRefPtr<SQL::TupleDescriptor> descriptor = adopt_ref(*new SQL::TupleDescriptor);
descriptor->append({ "col1", SQL::SQLType::Text, SQL::Order::Ascending });
descriptor->append({ "col2", SQL::SQLType::Integer, SQL::Order::Ascending });
descriptor->append({ "schema", "table", "col1", SQL::SQLType::Text, SQL::Order::Ascending });
descriptor->append({ "schema", "table", "col2", SQL::SQLType::Integer, SQL::Order::Ascending });
auto v = SQL::Value::create_tuple(descriptor);
Vector<SQL::Value> values;
@ -365,8 +365,8 @@ TEST_CASE(tuple_value_not_enough_values)
TEST_CASE(serialize_tuple_value)
{
NonnullRefPtr<SQL::TupleDescriptor> descriptor = adopt_ref(*new SQL::TupleDescriptor);
descriptor->append({ "col1", SQL::SQLType::Text, SQL::Order::Ascending });
descriptor->append({ "col2", SQL::SQLType::Integer, SQL::Order::Descending });
descriptor->append({ "schema", "table", "col1", SQL::SQLType::Text, SQL::Order::Ascending });
descriptor->append({ "schema", "table", "col2", SQL::SQLType::Integer, SQL::Order::Descending });
auto v = SQL::Value::create_tuple(descriptor);
Vector<SQL::Value> values;
@ -477,8 +477,8 @@ TEST_CASE(order_int_values)
TEST_CASE(tuple)
{
NonnullRefPtr<SQL::TupleDescriptor> descriptor = adopt_ref(*new SQL::TupleDescriptor);
descriptor->append({ "col1", SQL::SQLType::Text, SQL::Order::Ascending });
descriptor->append({ "col2", SQL::SQLType::Integer, SQL::Order::Descending });
descriptor->append({ "schema", "table", "col1", SQL::SQLType::Text, SQL::Order::Ascending });
descriptor->append({ "schema", "table", "col2", SQL::SQLType::Integer, SQL::Order::Descending });
SQL::Tuple tuple(descriptor);
tuple["col1"] = "Test";
@ -490,8 +490,8 @@ TEST_CASE(tuple)
TEST_CASE(serialize_tuple)
{
NonnullRefPtr<SQL::TupleDescriptor> descriptor = adopt_ref(*new SQL::TupleDescriptor);
descriptor->append({ "col1", SQL::SQLType::Text, SQL::Order::Ascending });
descriptor->append({ "col2", SQL::SQLType::Integer, SQL::Order::Descending });
descriptor->append({ "schema", "table", "col1", SQL::SQLType::Text, SQL::Order::Ascending });
descriptor->append({ "schema", "table", "col2", SQL::SQLType::Integer, SQL::Order::Descending });
SQL::Tuple tuple(descriptor);
tuple["col1"] = "Test";
@ -512,8 +512,8 @@ TEST_CASE(serialize_tuple)
TEST_CASE(copy_tuple)
{
NonnullRefPtr<SQL::TupleDescriptor> descriptor = adopt_ref(*new SQL::TupleDescriptor);
descriptor->append({ "col1", SQL::SQLType::Text, SQL::Order::Ascending });
descriptor->append({ "col2", SQL::SQLType::Integer, SQL::Order::Descending });
descriptor->append({ "schema", "table", "col1", SQL::SQLType::Text, SQL::Order::Ascending });
descriptor->append({ "schema", "table", "col2", SQL::SQLType::Integer, SQL::Order::Descending });
SQL::Tuple tuple(descriptor);
tuple["col1"] = "Test";
@ -530,8 +530,8 @@ TEST_CASE(copy_tuple)
TEST_CASE(compare_tuples)
{
NonnullRefPtr<SQL::TupleDescriptor> descriptor = adopt_ref(*new SQL::TupleDescriptor);
descriptor->append({ "col1", SQL::SQLType::Text, SQL::Order::Ascending });
descriptor->append({ "col2", SQL::SQLType::Integer, SQL::Order::Descending });
descriptor->append({ "schema", "table", "col1", SQL::SQLType::Text, SQL::Order::Ascending });
descriptor->append({ "schema", "table", "col2", SQL::SQLType::Integer, SQL::Order::Descending });
SQL::Tuple tuple1(descriptor);
tuple1["col1"] = "Test";