From 85202177de6ab37ba86cbb4d80f77f385226ab60 Mon Sep 17 00:00:00 2001 From: "Brian J. Cardiff" Date: Sun, 22 Sep 2019 11:58:04 -0300 Subject: [PATCH] Update to crystal-db ~> 0.7.0 --- shard.yml | 8 ++++---- src/adapter/base.cr | 4 ++-- src/adapter/mysql.cr | 6 +++--- src/adapter/pg.cr | 8 ++++---- src/adapter/sqlite.cr | 6 +++--- src/granite/query/assemblers/base.cr | 2 +- src/granite/query/executors/list.cr | 2 +- src/granite/query/executors/multi_value.cr | 2 +- src/granite/query/executors/value.cr | 2 +- src/granite/querying.cr | 4 ++-- 10 files changed, 22 insertions(+), 22 deletions(-) diff --git a/shard.yml b/shard.yml index 104afa43..3bc28bab 100644 --- a/shard.yml +++ b/shard.yml @@ -13,20 +13,20 @@ license: MIT dependencies: db: github: crystal-lang/crystal-db - version: ~> 0.6.0 + version: ~> 0.7.0 development_dependencies: mysql: github: crystal-lang/crystal-mysql - version: ~> 0.8.0 + version: ~> 0.9.0 sqlite3: github: crystal-lang/crystal-sqlite3 - version: ~> 0.13.0 + version: ~> 0.14.0 pg: github: will/crystal-pg - version: ~> 0.18.0 + version: ~> 0.19.0 ameba: github: veelenga/ameba diff --git a/src/adapter/base.cr b/src/adapter/base.cr index bee38ba6..fb477ecc 100644 --- a/src/adapter/base.cr +++ b/src/adapter/base.cr @@ -49,7 +49,7 @@ abstract class Granite::Adapter::Base elapsed_time = Time.measure do open do |db| - db.query statement, params do |rs| + db.query statement, args: params do |rs| yield rs end end @@ -65,7 +65,7 @@ abstract class Granite::Adapter::Base exists = false elapsed_time = Time.measure do open do |db| - exists = db.query_one?(statement, params, as: Bool) || exists + exists = db.query_one?(statement, args: params, as: Bool) || exists end end diff --git a/src/adapter/mysql.cr b/src/adapter/mysql.cr index f9a44989..4e7a572f 100644 --- a/src/adapter/mysql.cr +++ b/src/adapter/mysql.cr @@ -43,7 +43,7 @@ class Granite::Adapter::Mysql < Granite::Adapter::Base elapsed_time = Time.measure do open do |db| db.using_connection do |conn| - conn.exec statement, params + conn.exec statement, args: params last_id = conn.scalar(last_val()).as(Int64) if lastval end end @@ -87,7 +87,7 @@ class Granite::Adapter::Mysql < Granite::Adapter::Base elapsed_time = Time.measure do open do |db| - db.exec statement, params + db.exec statement, args: params end end @@ -108,7 +108,7 @@ class Granite::Adapter::Mysql < Granite::Adapter::Base elapsed_time = Time.measure do open do |db| - db.exec statement, params + db.exec statement, args: params end end diff --git a/src/adapter/pg.cr b/src/adapter/pg.cr index 9b4f5fab..5d017d7d 100644 --- a/src/adapter/pg.cr +++ b/src/adapter/pg.cr @@ -54,9 +54,9 @@ class Granite::Adapter::Pg < Granite::Adapter::Base elapsed_time = Time.measure do open do |db| if lastval - last_id = db.scalar(statement, params).as(Int32 | Int64).to_i64 + last_id = db.scalar(statement, args: params).as(Int32 | Int64).to_i64 else - db.exec statement, params + db.exec statement, args: params end end end @@ -105,7 +105,7 @@ class Granite::Adapter::Pg < Granite::Adapter::Base elapsed_time = Time.measure do open do |db| - db.exec statement, params + db.exec statement, args: params end end @@ -122,7 +122,7 @@ class Granite::Adapter::Pg < Granite::Adapter::Base elapsed_time = Time.measure do open do |db| - db.exec statement, params + db.exec statement, args: params end end diff --git a/src/adapter/sqlite.cr b/src/adapter/sqlite.cr index 3292c190..06c5bd31 100644 --- a/src/adapter/sqlite.cr +++ b/src/adapter/sqlite.cr @@ -43,7 +43,7 @@ class Granite::Adapter::Sqlite < Granite::Adapter::Base last_id = -1_i64 elapsed_time = Time.measure do open do |db| - db.exec statement, params + db.exec statement, args: params last_id = db.scalar(last_val()).as(Int64) if lastval end end @@ -79,7 +79,7 @@ class Granite::Adapter::Sqlite < Granite::Adapter::Base elapsed_time = Time.measure do open do |db| - db.exec statement, params + db.exec statement, args: params end end @@ -100,7 +100,7 @@ class Granite::Adapter::Sqlite < Granite::Adapter::Base elapsed_time = Time.measure do open do |db| - db.exec statement, params + db.exec statement, args: params end end diff --git a/src/granite/query/assemblers/base.cr b/src/granite/query/assemblers/base.cr index dcab0a2e..da619d0d 100644 --- a/src/granite/query/assemblers/base.cr +++ b/src/granite/query/assemblers/base.cr @@ -165,7 +165,7 @@ module Granite::Query::Assembler log sql, numbered_parameters Model.adapter.open do |db| - db.exec sql, numbered_parameters + db.exec sql, args: numbered_parameters end end diff --git a/src/granite/query/executors/list.cr b/src/granite/query/executors/list.cr index 06b03cc7..6fbb3e97 100644 --- a/src/granite/query/executors/list.cr +++ b/src/granite/query/executors/list.cr @@ -11,7 +11,7 @@ module Granite::Query::Executor results = [] of Model Model.adapter.open do |db| - db.query @sql, @args do |record_set| + db.query @sql, args: @args do |record_set| record_set.each do results << Model.from_rs record_set end diff --git a/src/granite/query/executors/multi_value.cr b/src/granite/query/executors/multi_value.cr index 176f86f4..c98eaa45 100644 --- a/src/granite/query/executors/multi_value.cr +++ b/src/granite/query/executors/multi_value.cr @@ -12,7 +12,7 @@ module Granite::Query::Executor results = [] of Scalar Model.adapter.open do |db| - db.query @sql, @args do |record_set| + db.query @sql, args: @args do |record_set| record_set.each do results << record_set.read(Scalar) end diff --git a/src/granite/query/executors/value.cr b/src/granite/query/executors/value.cr index 665ca6d5..501f0524 100644 --- a/src/granite/query/executors/value.cr +++ b/src/granite/query/executors/value.cr @@ -13,7 +13,7 @@ module Granite::Query::Executor raise "No default provided" if @default.nil? Model.adapter.open do |db| - db.query_one?(@sql, @args, as: Scalar) || @default.not_nil! + db.query_one?(@sql, args: @args, as: Scalar) || @default.not_nil! end end diff --git a/src/granite/querying.cr b/src/granite/querying.cr index 4b4e6151..113a2e37 100644 --- a/src/granite/querying.cr +++ b/src/granite/querying.cr @@ -43,7 +43,7 @@ module Granite::Querying # find returns the row with the primary key specified. Otherwise nil. def find(value) - first("WHERE #{primary_name} = ?", value) + first("WHERE #{primary_name} = ?", [value]) end # find returns the row with the primary key specified. Otherwise raises an exception. @@ -119,7 +119,7 @@ module Granite::Querying end def query(clause = "", params = [] of Granite::Columns::Type, &block) - adapter.open { |db| yield db.query(clause, params) } + adapter.open { |db| yield db.query(clause, args: params) } end def scalar(clause = "", &block)