diff options
author | Jan de Visser <jan@de-visser.net> | 2021-11-02 16:39:00 -0400 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-11-10 14:47:49 +0100 |
commit | 7ea54db43062a15615735eda2b23c214cc7a0d1a (patch) | |
tree | c07e8adbf83b60c1d6d4f06e9543a17fa0bbb0eb /Userland/Libraries/LibSQL | |
parent | c2c47fb9bba7e2383e0bd3dfabe8ec29126b93fb (diff) | |
download | serenity-7ea54db43062a15615735eda2b23c214cc7a0d1a.zip |
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 :^)
Diffstat (limited to 'Userland/Libraries/LibSQL')
-rw-r--r-- | Userland/Libraries/LibSQL/Meta.cpp | 4 | ||||
-rw-r--r-- | Userland/Libraries/LibSQL/TupleDescriptor.h | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibSQL/Value.cpp | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibSQL/Value.h | 2 |
4 files changed, 6 insertions, 4 deletions
diff --git a/Userland/Libraries/LibSQL/Meta.cpp b/Userland/Libraries/LibSQL/Meta.cpp index 65859f0e76..5dab68e598 100644 --- a/Userland/Libraries/LibSQL/Meta.cpp +++ b/Userland/Libraries/LibSQL/Meta.cpp @@ -118,7 +118,7 @@ NonnullRefPtr<TupleDescriptor> IndexDef::to_tuple_descriptor() const { NonnullRefPtr<TupleDescriptor> ret = adopt_ref(*new TupleDescriptor); for (auto& part : m_key_definition) { - ret->append({ part.name(), part.type(), part.sort_order() }); + ret->append({ "", "", part.name(), part.type(), part.sort_order() }); } return ret; } @@ -161,7 +161,7 @@ NonnullRefPtr<TupleDescriptor> TableDef::to_tuple_descriptor() const { NonnullRefPtr<TupleDescriptor> ret = adopt_ref(*new TupleDescriptor); for (auto& part : m_columns) { - ret->append({ part.name(), part.type(), Order::Ascending }); + ret->append({ parent()->name(), name(), part.name(), part.type(), Order::Ascending }); } return ret; } diff --git a/Userland/Libraries/LibSQL/TupleDescriptor.h b/Userland/Libraries/LibSQL/TupleDescriptor.h index a4ca1cc6b8..734bea69da 100644 --- a/Userland/Libraries/LibSQL/TupleDescriptor.h +++ b/Userland/Libraries/LibSQL/TupleDescriptor.h @@ -13,6 +13,8 @@ namespace SQL { struct TupleElementDescriptor { + String schema { "" }; + String table { "" }; String name { "" }; SQLType type { SQLType::Text }; Order order { Order::Ascending }; diff --git a/Userland/Libraries/LibSQL/Value.cpp b/Userland/Libraries/LibSQL/Value.cpp index d5fea9d48e..6eb6bdd6b8 100644 --- a/Userland/Libraries/LibSQL/Value.cpp +++ b/Userland/Libraries/LibSQL/Value.cpp @@ -1014,7 +1014,7 @@ void TupleImpl::infer_descriptor() void TupleImpl::extend_descriptor(Value const& value) { VERIFY(m_descriptor_inferred); - m_descriptor->empend("", value.type(), Order::Ascending); + m_descriptor->empend("", "", "", value.type(), Order::Ascending); } bool TupleImpl::validate_before_assignment(Vector<Value> const& values) diff --git a/Userland/Libraries/LibSQL/Value.h b/Userland/Libraries/LibSQL/Value.h index 28ec19eb03..54f1df22d8 100644 --- a/Userland/Libraries/LibSQL/Value.h +++ b/Userland/Libraries/LibSQL/Value.h @@ -130,7 +130,7 @@ public: [[nodiscard]] TupleElementDescriptor descriptor() const { - return { "", type(), Order::Ascending }; + return { "", "", "", type(), Order::Ascending }; } static Value const& null(); |