From ec3f645c70f5ad90a517a7591935cf4254e03156 Mon Sep 17 00:00:00 2001 From: Russ Smith Date: Wed, 20 Jun 2018 15:18:36 -0700 Subject: [PATCH] Providing a execute method on a specific connection. --- src/clear/sql/sql.cr | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/clear/sql/sql.cr b/src/clear/sql/sql.cr index e0d935809..bf4701284 100644 --- a/src/clear/sql/sql.cr +++ b/src/clear/sql/sql.cr @@ -161,6 +161,14 @@ module Clear log_query(sql) { Clear::SQL.connection("default").exec(sql) } end + # Execute a SQL request on a specific connection. + # + # Usage: + # Clear::SQL.execute("seconddatabase", "SELECT 1 FROM users") + def execute(connection : Symbolic, sql) + log_query(sql) { Clear::SQL.connection(connection).exec(sql) } + end + # :nodoc: def sel_str(s : Selectable) s.is_a?(Symbolic) ? s.to_s : s.to_sql