diff options
author | Timothy Flynn <trflynn89@pm.me> | 2022-02-09 16:00:45 -0500 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2022-02-10 12:20:35 +0000 |
commit | aff17a2fbd8ee26a5ee5b78425015de842d7b085 (patch) | |
tree | 500750e95a3bd7debf27ba11d0ec1617c8008a2c /Userland/Libraries/LibSQL | |
parent | 6620f19979accce0e00df7ee9175069f181884ff (diff) | |
download | serenity-aff17a2fbd8ee26a5ee5b78425015de842d7b085.zip |
LibSQL: Remove now-unused SQLResult class
Diffstat (limited to 'Userland/Libraries/LibSQL')
-rw-r--r-- | Userland/Libraries/LibSQL/Forward.h | 1 | ||||
-rw-r--r-- | Userland/Libraries/LibSQL/SQLResult.cpp | 20 | ||||
-rw-r--r-- | Userland/Libraries/LibSQL/SQLResult.h | 92 |
3 files changed, 0 insertions, 113 deletions
diff --git a/Userland/Libraries/LibSQL/Forward.h b/Userland/Libraries/LibSQL/Forward.h index 01cd6fbe79..b68e85f73d 100644 --- a/Userland/Libraries/LibSQL/Forward.h +++ b/Userland/Libraries/LibSQL/Forward.h @@ -25,7 +25,6 @@ class Relation; class Result; class Row; class SchemaDef; -class SQLResult; class Serializer; class TableDef; class TreeNode; diff --git a/Userland/Libraries/LibSQL/SQLResult.cpp b/Userland/Libraries/LibSQL/SQLResult.cpp index 57986c355b..0f23a5953f 100644 --- a/Userland/Libraries/LibSQL/SQLResult.cpp +++ b/Userland/Libraries/LibSQL/SQLResult.cpp @@ -9,26 +9,6 @@ namespace SQL { -void SQLResult::insert(Tuple const& row, Tuple const& sort_key) -{ - m_has_results = true; - m_result_set.insert_row(row, sort_key); -} - -void SQLResult::limit(size_t offset, size_t limit) -{ - 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); - } -} - void Result::insert(Tuple const& row, Tuple const& sort_key) { if (!m_result_set.has_value()) diff --git a/Userland/Libraries/LibSQL/SQLResult.h b/Userland/Libraries/LibSQL/SQLResult.h index da28aa1dca..f9cd309170 100644 --- a/Userland/Libraries/LibSQL/SQLResult.h +++ b/Userland/Libraries/LibSQL/SQLResult.h @@ -9,9 +9,6 @@ #include <AK/Error.h> #include <AK/Noncopyable.h> -#include <AK/NonnullOwnPtrVector.h> -#include <AK/Vector.h> -#include <LibCore/Object.h> #include <LibSQL/ResultSet.h> #include <LibSQL/Tuple.h> #include <LibSQL/Type.h> @@ -76,95 +73,6 @@ enum class SQLErrorCode { #undef __ENUMERATE_SQL_ERROR }; -struct SQLError { - SQLErrorCode code { SQLErrorCode::NoError }; - String error_argument { "" }; - - String to_string() const - { - String code_string; - String message; - switch (code) { -#undef __ENUMERATE_SQL_ERROR -#define __ENUMERATE_SQL_ERROR(error, description) \ - case SQLErrorCode::error: \ - code_string = #error; \ - message = description; \ - break; - ENUMERATE_SQL_ERRORS(__ENUMERATE_SQL_ERROR) -#undef __ENUMERATE_SQL_ERROR - default: - VERIFY_NOT_REACHED(); - } - if (!error_argument.is_null() && !error_argument.is_empty()) { - if (message.find("{}").has_value()) { - message = String::formatted(message, error_argument); - } else { - message = String::formatted("{}: {}", message, error_argument); - } - } - if (message.is_null() || (message.is_empty())) { - return code_string; - } else { - return String::formatted("{}: {}", code_string, message); - } - } -}; - -class SQLResult : public Core::Object { - C_OBJECT(SQLResult) - -public: - void insert(Tuple const& row, Tuple const& sort_key); - void limit(size_t offset, size_t limit); - SQLCommand command() const { return m_command; } - int updated() const { return m_update_count; } - int inserted() const { return m_insert_count; } - int deleted() const { return m_delete_count; } - void set_error(SQLErrorCode code, String argument = {}) - { - m_error.code = code; - m_error.error_argument = argument; - } - - bool has_error() const { return m_error.code != SQLErrorCode::NoError; } - SQLError const& error() const { return m_error; } - bool has_results() const { return m_has_results; } - ResultSet const& results() const { return m_result_set; } - -private: - SQLResult() = default; - - explicit SQLResult(SQLCommand command, int update_count = 0, int insert_count = 0, int delete_count = 0) - : m_command(command) - , m_update_count(update_count) - , m_insert_count(insert_count) - , m_delete_count(delete_count) - , m_has_results(command == SQLCommand::Select) - { - } - - SQLResult(SQLCommand command, SQLErrorCode error_code, String error_argument) - : m_command(command) - , m_error({ error_code, move(error_argument) }) - { - } - - SQLResult(SQLCommand command, SQLErrorCode error_code, AK::Error error) - : m_command(command) - , m_error({ error_code, error.string_literal() }) - { - } - - SQLCommand m_command { SQLCommand::Select }; - SQLError m_error { SQLErrorCode::NoError, "" }; - int m_update_count { 0 }; - int m_insert_count { 0 }; - int m_delete_count { 0 }; - bool m_has_results { false }; - ResultSet m_result_set; -}; - class [[nodiscard]] Result { public: ALWAYS_INLINE Result(SQLCommand command, size_t update_count = 0, size_t insert_count = 0, size_t delete_count = 0) |