mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 08:58:11 +00:00
LibSQL+SQLServer: Return a NonnullRefPtr from Database::get_table
Database::get_table currently either returns a RefPtr to an existing table, a nullptr if the table doesn't exist, or an Error if some internal error occured. Change this to return a NonnullRefPtr to an exisiting table, or a SQL::Result with any error, including if the table 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
56843baff9
commit
4b70908dc4
8 changed files with 56 additions and 79 deletions
|
@ -14,15 +14,9 @@ namespace SQL::AST {
|
|||
|
||||
ResultOr<ResultSet> DescribeTable::execute(ExecutionContext& context) const
|
||||
{
|
||||
auto schema_name = m_qualified_table_name->schema_name();
|
||||
auto table_name = m_qualified_table_name->table_name();
|
||||
|
||||
auto const& schema_name = m_qualified_table_name->schema_name();
|
||||
auto const& table_name = m_qualified_table_name->table_name();
|
||||
auto table_def = TRY(context.database->get_table(schema_name, table_name));
|
||||
if (!table_def) {
|
||||
if (schema_name.is_empty())
|
||||
schema_name = "default"sv;
|
||||
return Result { SQLCommand::Describe, SQLErrorCode::TableDoesNotExist, String::formatted("{}.{}", schema_name, table_name) };
|
||||
}
|
||||
|
||||
auto describe_table_def = MUST(context.database->get_table("master"sv, "internal_describe_table"sv));
|
||||
auto descriptor = describe_table_def->to_tuple_descriptor();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue