SQLStudio: Display real column names in the results tab

This commit is contained in:
Timothy Flynn 2023-02-03 10:49:58 -05:00 committed by Andreas Kling
parent 4fe437b4d2
commit e96df1599c
2 changed files with 7 additions and 3 deletions

View file

@ -253,7 +253,8 @@ MainWidget::MainWidget()
};
m_sql_client = SQL::SQLClient::try_create().release_value_but_fixme_should_propagate_errors();
m_sql_client->on_execution_success = [this](auto) {
m_sql_client->on_execution_success = [this](auto result) {
m_result_column_names = move(result.column_names);
read_next_sql_statement_of_editor();
};
m_sql_client->on_execution_error = [this](auto result) {
@ -274,9 +275,11 @@ MainWidget::MainWidget()
return;
if (m_results[0].size() == 0)
return;
Vector<GUI::JsonArrayModel::FieldSpec> query_result_fields;
for (size_t i = 0; i < m_results[0].size(); i++)
query_result_fields.empend(DeprecatedString::formatted("column_{}", i + 1), DeprecatedString::formatted("Column {}", i + 1), Gfx::TextAlignment::CenterLeft);
for (auto& column_name : m_result_column_names)
query_result_fields.empend(column_name, column_name, Gfx::TextAlignment::CenterLeft);
auto query_results_model = GUI::JsonArrayModel::create("{}", move(query_result_fields));
m_query_results_table_view->set_model(MUST(GUI::SortingProxyModel::create(*query_results_model)));
for (auto& result_row : m_results) {

View file

@ -64,6 +64,7 @@ private:
RefPtr<SQL::SQLClient> m_sql_client;
Optional<SQL::ConnectionID> m_connection_id;
Vector<DeprecatedString> m_result_column_names;
Vector<Vector<DeprecatedString>> m_results;
void read_next_sql_statement_of_editor();