Skip to content

Commit bd55f36

Browse files
committed
Fixed bind params for SQLite
1 parent aae3f54 commit bd55f36

File tree

6 files changed

+7
-3
lines changed

6 files changed

+7
-3
lines changed

.github/workflows/build.yml

+1
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,4 @@ jobs:
2828
database: blazer_test
2929
- run: bundle exec rake test
3030
- run: bundle exec rake test:postgresql
31+
- run: bundle exec rake test:sqlite

Gemfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ gem "minitest", ">= 5"
77
gem "combustion"
88
gem "rails", "~> 8.0.0"
99
gem "pg"
10+
gem "sqlite3"
1011
gem "propshaft"
1112

1213
# data sources
@@ -27,7 +28,6 @@ gem "propshaft"
2728
# gem "opensearch-ruby"
2829
# gem "presto-client"
2930
# gem "restforce"
30-
# gem "sqlite3"
3131
# gem "tiny_tds"
3232
# gem "trilogy"
3333
# gem "activerecord-sqlserver-adapter"

gemfiles/rails70.gemfile

+1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ gem "minitest", ">= 5"
77
gem "combustion"
88
gem "rails", "~> 7.0.0"
99
gem "pg"
10+
gem "sqlite3", "< 2"
1011
gem "sprockets-rails"

gemfiles/rails71.gemfile

+1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ gem "minitest", ">= 5"
77
gem "combustion"
88
gem "rails", "~> 7.1.0"
99
gem "pg"
10+
gem "sqlite3"
1011
gem "sprockets-rails"

gemfiles/rails72.gemfile

+1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ gem "minitest", ">= 5"
77
gem "combustion"
88
gem "rails", "~> 7.2.0"
99
gem "pg"
10+
gem "sqlite3"
1011
gem "sprockets-rails"

lib/blazer/adapters/sql_adapter.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ def run_statement(statement, comment, bind_params = [])
2424
result = nil
2525
in_transaction do
2626
set_timeout(data_source.timeout) if data_source.timeout
27+
binds = bind_params.map { |v| ActiveRecord::Relation::QueryAttribute.new(nil, v, ActiveRecord::Type::Value.new) }
2728
if sqlite?
2829
type_map = connection_model.connection.send(:type_map)
2930
connection_model.connection.raw_connection.prepare("#{statement} /*#{comment}*/") do |stmt|
30-
stmt.bind_params(bind_params)
31+
stmt.bind_params(connection_model.connection.send(:type_casted_binds, binds))
3132
types = stmt.columns.zip(stmt.types).to_h { |c, t| [c, type_map.lookup(t)] }
3233
result = ActiveRecord::Result.new(stmt.columns, stmt.to_a, types)
3334
end
3435
else
35-
binds = bind_params.map { |v| ActiveRecord::Relation::QueryAttribute.new(nil, v, ActiveRecord::Type::Value.new) }
3636
result = connection_model.connection.select_all("#{statement} /*#{comment}*/", nil, binds)
3737
end
3838
end

0 commit comments

Comments
 (0)