summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibSQL/Result.cpp
diff options
context:
space:
mode:
authorTimothy Flynn <trflynn89@pm.me>2022-02-10 14:43:00 -0500
committerAndreas Kling <kling@serenityos.org>2022-02-10 23:11:13 +0100
commit2397836f8e2895d2dc2ecb9685bb383d11145d70 (patch)
treeeaf54c7f590f38c3651b8fa3111b077840a34a0f /Userland/Libraries/LibSQL/Result.cpp
parent64096184131a7746a2c963a588c7a5162f11f8d7 (diff)
downloadserenity-2397836f8e2895d2dc2ecb9685bb383d11145d70.zip
LibSQL+SQLServer: Introduce and use ResultOr<ValueType>
The result of a SQL statement execution is either: 1. An error. 2. The list of rows inserted, deleted, selected, etc. (2) is currently represented by a combination of the Result class and the ResultSet list it holds. This worked okay, but issues start to arise when trying to use Result in non-statement contexts (for example, when introducing Result to SQL expression execution). What we really need is for Result to be a thin wrapper that represents both (1) and (2), and to not have any explicit members like a ResultSet. So this commit removes ResultSet from Result, and introduces ResultOr, which is just an alias for AK::ErrorOrr. Statement execution now returns ResultOr<ResultSet> instead of Result. This further opens the door for expression execution to return ResultOr<Value> in the future. Lastly, this moves some other context held by Result over to ResultSet. This includes the row count (which is really just the size of ResultSet) and the command for which the result is for.
Diffstat (limited to 'Userland/Libraries/LibSQL/Result.cpp')
-rw-r--r--Userland/Libraries/LibSQL/Result.cpp24
1 files changed, 0 insertions, 24 deletions
diff --git a/Userland/Libraries/LibSQL/Result.cpp b/Userland/Libraries/LibSQL/Result.cpp
index 104c8ee4d3..8e8804e17f 100644
--- a/Userland/Libraries/LibSQL/Result.cpp
+++ b/Userland/Libraries/LibSQL/Result.cpp
@@ -9,30 +9,6 @@
namespace SQL {
-void Result::insert(Tuple const& row, Tuple const& sort_key)
-{
- if (!m_result_set.has_value())
- m_result_set = ResultSet {};
- m_result_set->insert_row(row, sort_key);
-}
-
-void Result::limit(size_t offset, size_t limit)
-{
- VERIFY(has_results());
-
- if (offset > 0) {
- if (offset > m_result_set->size()) {
- m_result_set->clear();
- return;
- }
-
- m_result_set->remove(0, offset);
- }
-
- if (m_result_set->size() > limit)
- m_result_set->remove(limit, m_result_set->size() - limit);
-}
-
String Result::error_string() const
{
VERIFY(is_error());