Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to crystal-db ~> 0.7.0 #363

Merged
merged 1 commit into from
Sep 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions shard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/adapter/base.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
6 changes: 3 additions & 3 deletions src/adapter/mysql.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand All @@ -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

Expand Down
8 changes: 4 additions & 4 deletions src/adapter/pg.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand All @@ -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

Expand Down
6 changes: 3 additions & 3 deletions src/adapter/sqlite.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/granite/query/assemblers/base.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/granite/query/executors/list.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/granite/query/executors/multi_value.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/granite/query/executors/value.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions src/granite/querying.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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)
Expand Down