mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-27 23:09:08 +00:00
LibSQL+SQLServer: Return a NonnullRefPtr from Database::get_schema
Database::get_schema currently either returns a RefPtr to an existing schema, a nullptr if the schema doesn't exist, or an Error if some internal error occured. Change this to return a NonnullRefPtr to an exisiting schema, or a SQL::Result with any error, including if the schema was not found. Callers can then handle that specific error code if they want. Returning a NonnullRefPtr will enable some further cleanup. This had some fallout of needing to change some other methods' return types from AK::ErrorOr to SQL::Result so that TRY may continue to be used.
This commit is contained in:
parent
7464dfa974
commit
56843baff9
Notes:
sideshowbarker
2024-07-17 03:52:21 +09:00
Author: https://github.com/trflynn89
Commit: 56843baff9
Pull-request: https://github.com/SerenityOS/serenity/pull/16239
Reviewed-by: https://github.com/gmta
Reviewed-by: https://github.com/linusg
7 changed files with 49 additions and 57 deletions
|
@ -11,13 +11,8 @@ namespace SQL::AST {
|
|||
|
||||
ResultOr<ResultSet> CreateTable::execute(ExecutionContext& context) const
|
||||
{
|
||||
auto schema_name = m_schema_name.is_empty() ? String { "default"sv } : m_schema_name;
|
||||
|
||||
auto schema_def = TRY(context.database->get_schema(schema_name));
|
||||
if (!schema_def)
|
||||
return Result { SQLCommand::Create, SQLErrorCode::SchemaDoesNotExist, schema_name };
|
||||
|
||||
auto table_def = TRY(context.database->get_table(schema_name, m_table_name));
|
||||
auto schema_def = TRY(context.database->get_schema(m_schema_name));
|
||||
auto table_def = TRY(context.database->get_table(m_schema_name, m_table_name));
|
||||
if (table_def) {
|
||||
if (m_is_error_if_table_exists)
|
||||
return Result { SQLCommand::Create, SQLErrorCode::TableExists, m_table_name };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue