1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 15:48:12 +00:00

SQLServer+SQLStudio+sql: Rename a couple of SQL IPC commands for clarity

Rename sql_statement to prepare_statement and statement_execute to
execute_statement. The former aligns more with other database libraries
(e.g. Java's JDBC prepareStatement). The latter reads less awkwardly.
This commit is contained in:
Timothy Flynn 2022-10-27 13:04:42 -04:00 committed by Linus Groh
parent 17988bab75
commit 0986b383cd
7 changed files with 17 additions and 17 deletions

View file

@ -478,8 +478,8 @@ String MainWidget::read_next_sql_statement_of_editor()
m_editor_line_level = last_token_ended_statement ? 0 : (m_editor_line_level > 0 ? m_editor_line_level : 1); m_editor_line_level = last_token_ended_statement ? 0 : (m_editor_line_level > 0 ? m_editor_line_level : 1);
} while ((m_editor_line_level > 0) || piece.is_empty()); } while ((m_editor_line_level > 0) || piece.is_empty());
auto statement_id = m_sql_client->sql_statement(m_connection_id, piece.to_string()); auto statement_id = m_sql_client->prepare_statement(m_connection_id, piece.to_string());
m_sql_client->async_statement_execute(statement_id); m_sql_client->async_execute_statement(statement_id);
return piece.to_string(); return piece.to_string();
} }

View file

@ -51,13 +51,13 @@ void ConnectionFromClient::disconnect(int connection_id)
dbgln("Database connection has disappeared"); dbgln("Database connection has disappeared");
} }
Messages::SQLServer::SqlStatementResponse ConnectionFromClient::sql_statement(int connection_id, String const& sql) Messages::SQLServer::PrepareStatementResponse ConnectionFromClient::prepare_statement(int connection_id, String const& sql)
{ {
dbgln_if(SQLSERVER_DEBUG, "ConnectionFromClient::sql_statement(connection_id: {}, sql: '{}')", connection_id, sql); dbgln_if(SQLSERVER_DEBUG, "ConnectionFromClient::prepare_statement(connection_id: {}, sql: '{}')", connection_id, sql);
auto database_connection = DatabaseConnection::connection_for(connection_id); auto database_connection = DatabaseConnection::connection_for(connection_id);
if (database_connection) { if (database_connection) {
auto statement_id = database_connection->sql_statement(sql); auto statement_id = database_connection->prepare_statement(sql);
dbgln_if(SQLSERVER_DEBUG, "ConnectionFromClient::sql_statement -> statement_id = {}", statement_id); dbgln_if(SQLSERVER_DEBUG, "ConnectionFromClient::prepare_statement -> statement_id = {}", statement_id);
return { statement_id }; return { statement_id };
} else { } else {
dbgln("Database connection has disappeared"); dbgln("Database connection has disappeared");
@ -65,9 +65,9 @@ Messages::SQLServer::SqlStatementResponse ConnectionFromClient::sql_statement(in
} }
} }
void ConnectionFromClient::statement_execute(int statement_id) void ConnectionFromClient::execute_statement(int statement_id)
{ {
dbgln_if(SQLSERVER_DEBUG, "ConnectionFromClient::statement_execute_query(statement_id: {})", statement_id); dbgln_if(SQLSERVER_DEBUG, "ConnectionFromClient::execute_query_statement(statement_id: {})", statement_id);
auto statement = SQLStatement::statement_for(statement_id); auto statement = SQLStatement::statement_for(statement_id);
if (statement && statement->connection()->client_id() == client_id()) { if (statement && statement->connection()->client_id() == client_id()) {
statement->execute(); statement->execute();

View file

@ -28,8 +28,8 @@ private:
explicit ConnectionFromClient(NonnullOwnPtr<Core::Stream::LocalSocket>, int client_id); explicit ConnectionFromClient(NonnullOwnPtr<Core::Stream::LocalSocket>, int client_id);
virtual Messages::SQLServer::ConnectResponse connect(String const&) override; virtual Messages::SQLServer::ConnectResponse connect(String const&) override;
virtual Messages::SQLServer::SqlStatementResponse sql_statement(int, String const&) override; virtual Messages::SQLServer::PrepareStatementResponse prepare_statement(int, String const&) override;
virtual void statement_execute(int) override; virtual void execute_statement(int) override;
virtual void disconnect(int) override; virtual void disconnect(int) override;
}; };

View file

@ -67,9 +67,9 @@ void DatabaseConnection::disconnect()
}); });
} }
int DatabaseConnection::sql_statement(String const& sql) int DatabaseConnection::prepare_statement(String const& sql)
{ {
dbgln_if(SQLSERVER_DEBUG, "DatabaseConnection::sql_statement(connection_id {}, database '{}', sql '{}'", connection_id(), m_database_name, sql); dbgln_if(SQLSERVER_DEBUG, "DatabaseConnection::prepare_statement(connection_id {}, database '{}', sql '{}'", connection_id(), m_database_name, sql);
auto client_connection = ConnectionFromClient::client_connection_for(client_id()); auto client_connection = ConnectionFromClient::client_connection_for(client_id());
if (!client_connection) { if (!client_connection) {
warnln("Cannot notify client of database disconnection. Client disconnected"); warnln("Cannot notify client of database disconnection. Client disconnected");

View file

@ -23,7 +23,7 @@ public:
int client_id() const { return m_client_id; } int client_id() const { return m_client_id; }
RefPtr<SQL::Database> database() { return m_database; } RefPtr<SQL::Database> database() { return m_database; }
void disconnect(); void disconnect();
int sql_statement(String const& sql); int prepare_statement(String const& sql);
private: private:
DatabaseConnection(String database_name, int client_id); DatabaseConnection(String database_name, int client_id);

View file

@ -1,7 +1,7 @@
endpoint SQLServer endpoint SQLServer
{ {
connect(String name) => (int connection_id) connect(String name) => (int connection_id)
sql_statement(int connection_id, String statement) => (int statement_id) prepare_statement(int connection_id, String statement) => (int statement_id)
statement_execute(int statement_id) =| execute_statement(int statement_id) =|
disconnect(int connection_id) =| disconnect(int connection_id) =|
} }

View file

@ -291,8 +291,8 @@ private:
read_sql(); read_sql();
}); });
} else { } else {
auto statement_id = m_sql_client->sql_statement(m_connection_id, piece); auto statement_id = m_sql_client->prepare_statement(m_connection_id, piece);
m_sql_client->async_statement_execute(statement_id); m_sql_client->async_execute_statement(statement_id);
} }
// ...But m_keep_running can also be set to false by a command handler. // ...But m_keep_running can also be set to false by a command handler.