mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-10 18:10:56 +09: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:
parent
c2c47fb9bb
commit
7ea54db430
Notes:
sideshowbarker
2024-07-18 01:19:19 +09:00
Author: https://github.com/JanDeVisser
Commit: 7ea54db430
Pull-request: https://github.com/SerenityOS/serenity/pull/10770
Reviewed-by: https://github.com/trflynn89 ✅
7 changed files with 27 additions and 25 deletions
|
@ -127,7 +127,7 @@ void insert_into_and_scan_btree(int);
|
|||
NonnullRefPtr<SQL::BTree> setup_btree(SQL::Serializer& serializer)
|
||||
{
|
||||
NonnullRefPtr<SQL::TupleDescriptor> tuple_descriptor = adopt_ref(*new SQL::TupleDescriptor);
|
||||
tuple_descriptor->append({ "key_value", SQL::SQLType::Integer, SQL::Order::Ascending });
|
||||
tuple_descriptor->append({ "schema", "table", "key_value", SQL::SQLType::Integer, SQL::Order::Ascending });
|
||||
|
||||
auto root_pointer = serializer.heap().user_value(0);
|
||||
if (!root_pointer) {
|
||||
|
|
|
@ -124,8 +124,8 @@ void insert_into_and_scan_hash_index(int);
|
|||
NonnullRefPtr<SQL::HashIndex> setup_hash_index(SQL::Serializer& serializer)
|
||||
{
|
||||
NonnullRefPtr<SQL::TupleDescriptor> tuple_descriptor = adopt_ref(*new SQL::TupleDescriptor);
|
||||
tuple_descriptor->append({ "key_value", SQL::SQLType::Integer, SQL::Order::Ascending });
|
||||
tuple_descriptor->append({ "text_value", SQL::SQLType::Text, SQL::Order::Ascending });
|
||||
tuple_descriptor->append({ "schema", "table", "key_value", SQL::SQLType::Integer, SQL::Order::Ascending });
|
||||
tuple_descriptor->append({ "schema", "table", "text_value", SQL::SQLType::Text, SQL::Order::Ascending });
|
||||
|
||||
auto directory_pointer = serializer.heap().user_value(0);
|
||||
if (!directory_pointer) {
|
||||
|
|
|
@ -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";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue