sequel-rails 1.2.1 → 1.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +16 -10
- data/.gitignore +1 -0
- data/Gemfile +1 -1
- data/History.md +11 -0
- data/README.md +39 -19
- data/ci/rails-5.2.gemfile +1 -1
- data/ci/rails-6.0.gemfile +1 -1
- data/ci/rails-6.1.gemfile +1 -1
- data/ci/rails-7.0.gemfile +1 -1
- data/ci/rails-7.1.gemfile +27 -0
- data/lib/sequel_rails/railties/log_subscriber.rb +1 -7
- data/lib/sequel_rails/version.rb +1 -1
- data/spec/internal/Rakefile +6 -1
- data/spec/internal/db/migrate/1365762738_add_display_name_to_users.rb +7 -0
- data/spec/internal/db/migrate/1365762739_add_github_username_to_users.rb +7 -0
- data/spec/lib/sequel_rails/railties/database_rake_spec.rb +81 -12
- data/spec/lib/sequel_rails/railties/log_subscriber_spec.rb +124 -9
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2aff64f558081a4bd3fd000cdfd10d0f311f8df566191c10b9667854f3963318
|
4
|
+
data.tar.gz: 4893182c4f44909bacfc5addab1b7e57ad1d789e550b448ce4ef685be7630b81
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5857f2559c24d2f1c06d1b5f671a18f886614cae46a76c918b9a311e70c6680c0b36e740605847eef202cc8f0ada7d08670d27c64cc3fb5c5bf5b08de49b1e3a
|
7
|
+
data.tar.gz: 58af2a634a6d2483a686a99d7196a4250ff086b672e252409c5c15fd160a06bdaed16b47926209c6de63d6666a4c24fd24c20d255208aeb2367f4df1febc82ba
|
data/.github/workflows/ci.yml
CHANGED
@@ -39,10 +39,9 @@ jobs:
|
|
39
39
|
fail-fast: false
|
40
40
|
matrix:
|
41
41
|
rails:
|
42
|
-
- "5.2"
|
43
|
-
- "6.0"
|
44
42
|
- "6.1"
|
45
43
|
- "7.0"
|
44
|
+
- "7.1"
|
46
45
|
sequel:
|
47
46
|
- "~> 5.0"
|
48
47
|
ruby:
|
@@ -50,24 +49,31 @@ jobs:
|
|
50
49
|
- "2.7"
|
51
50
|
- "3.0"
|
52
51
|
- "3.1"
|
52
|
+
- "3.2"
|
53
53
|
# - "jruby"
|
54
|
-
|
55
|
-
- ruby: "2.
|
56
|
-
rails: "5.2"
|
57
|
-
- ruby: "3.0"
|
58
|
-
rails: "5.2"
|
59
|
-
- ruby: "3.1"
|
54
|
+
include:
|
55
|
+
- ruby: "2.6"
|
60
56
|
rails: "5.2"
|
61
|
-
|
57
|
+
sequel: "~> 5.0"
|
58
|
+
- ruby: "2.6"
|
62
59
|
rails: "6.0"
|
63
|
-
|
60
|
+
sequel: "~> 5.0"
|
61
|
+
- ruby: "2.7"
|
64
62
|
rails: "6.0"
|
63
|
+
sequel: "~> 5.0"
|
64
|
+
exclude:
|
65
65
|
- ruby: "3.1"
|
66
66
|
rails: "6.1"
|
67
|
+
- ruby: "3.2"
|
68
|
+
rails: "6.1"
|
67
69
|
- ruby: "2.6"
|
68
70
|
rails: "7.0"
|
69
71
|
- ruby: "jruby"
|
70
72
|
rails: "7.0"
|
73
|
+
- ruby: "2.6"
|
74
|
+
rails: "7.1"
|
75
|
+
- ruby: "jruby"
|
76
|
+
rails: "7.1"
|
71
77
|
name: Rails ${{ matrix.rails }}, Sequel ${{ matrix.sequel }}, Ruby ${{ matrix.ruby }}
|
72
78
|
|
73
79
|
env:
|
data/.gitignore
CHANGED
data/Gemfile
CHANGED
data/History.md
CHANGED
@@ -1,3 +1,14 @@
|
|
1
|
+
1.2.2 (2023-12-18)
|
2
|
+
==================
|
3
|
+
|
4
|
+
* Simplify `binds` handling in `LogSubscriber` to support bound variables and prepare statements (Jonathan Tron)
|
5
|
+
[#201](https://github.com/TalentBox/sequel-rails/pull/201)
|
6
|
+
* Update CI to run against rails 7.1 & ruby 3.2, add spec for `db:rollback` (@PikachuEXE)
|
7
|
+
[#199](https://github.com/TalentBox/sequel-rails/pull/199)
|
8
|
+
* Update instructions for Rails 7 (@opensourceame)
|
9
|
+
[#197](https://github.com/TalentBox/sequel-rails/pull/197)
|
10
|
+
|
11
|
+
|
1
12
|
1.2.1 (2023-10-18)
|
2
13
|
==================
|
3
14
|
|
data/README.md
CHANGED
@@ -27,7 +27,7 @@ Since January 2013, we've become the official maintainers of the gem after
|
|
27
27
|
Using sequel-rails
|
28
28
|
==================
|
29
29
|
|
30
|
-
Using sequel with Rails (5.2.x, 6.x, 7.x) requires a
|
30
|
+
Using sequel with Rails (5.2.x, 6.x, 7.x) requires a few minor changes.
|
31
31
|
|
32
32
|
First, add the following to your Gemfile (after the `Rails` lines):
|
33
33
|
|
@@ -50,35 +50,37 @@ The top of your `config/application.rb` will probably look something like:
|
|
50
50
|
# require 'rails/all'
|
51
51
|
|
52
52
|
# Instead of 'rails/all', require these:
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
53
|
+
%w(
|
54
|
+
action_cable/engine
|
55
|
+
action_controller/railtie
|
56
|
+
action_mailer/railtie
|
57
|
+
action_view/railtie
|
58
|
+
active_job/railtie
|
59
|
+
rails/test_unit/railtie
|
60
|
+
).each do |railtie|
|
61
|
+
begin
|
62
|
+
require railtie
|
63
|
+
rescue LoadError
|
64
|
+
end
|
65
|
+
end
|
62
66
|
```
|
63
67
|
|
64
|
-
Then you need to get rid of `ActiveRecord` configurations, that is if you
|
68
|
+
Then you need to get rid of `ActiveRecord` and `ActiveStorage` configurations, that is if you
|
65
69
|
didn't generate the new app with `-O` (or the long form `--skip-active-record`):
|
66
70
|
|
67
|
-
For example in a fresh `Rails
|
68
|
-
|
69
|
-
```
|
70
|
-
config/initializers/new_framework_defaults.rb
|
71
|
-
line 18: Rails.application.config.active_record.belongs_to_required_by_default = true
|
72
|
-
```
|
71
|
+
For example in a fresh `Rails 7`, you would need to remove those lines:
|
73
72
|
|
74
73
|
```
|
75
74
|
config/environments/development.rb
|
76
|
-
line
|
75
|
+
line 37: # config.active_storage.service = :local
|
76
|
+
line 54: # config.active_record.migration_error = :page_load
|
77
|
+
line 57: # config.active_record.verbose_query_logs = true
|
77
78
|
```
|
78
79
|
|
79
80
|
```
|
80
81
|
config/environments/production.rb
|
81
|
-
line
|
82
|
+
line 41: # config.active_storage.service = :local
|
83
|
+
line 92: # config.active_record.dump_schema_after_migration = false
|
82
84
|
```
|
83
85
|
|
84
86
|
Starting with sequel-rails 0.4.0.pre3 we don't change default Sequel behaviour
|
@@ -90,6 +92,22 @@ with content:
|
|
90
92
|
require "sequel_rails/railties/legacy_model_config"
|
91
93
|
```
|
92
94
|
|
95
|
+
## Rails 7
|
96
|
+
|
97
|
+
Rake `db:*` mappings are currently not supported in Rails 7, so you'll need to use
|
98
|
+
the `sequel:*` tasks instead. For example, to migrate your database, you'll need to
|
99
|
+
run `rails sequel:migrate` instead of `rails db:migrate`.
|
100
|
+
|
101
|
+
The rake command to create your db requires that Sequel does not attempt to connect
|
102
|
+
to load models before creating the db. Add this to your `config/application.rb`
|
103
|
+
|
104
|
+
```
|
105
|
+
# config/application.rb
|
106
|
+
if defined?(Rake.application) && Rake.application.top_level_tasks.include?('sequel:create')
|
107
|
+
config.sequel.skip_connect = true
|
108
|
+
end
|
109
|
+
```
|
110
|
+
|
93
111
|
After those changes, you should be good to go!
|
94
112
|
|
95
113
|
Features provided by `sequel-rails`
|
@@ -458,6 +476,8 @@ Improvements have been made by those awesome contributors:
|
|
458
476
|
* Yuri Smirnov (@tycooon)
|
459
477
|
* Mickael Kurmann (@elbouillon)
|
460
478
|
* Radoslaw Wojnarowski (@rwojnarowski)
|
479
|
+
* David Kelly (@opensourceame)
|
480
|
+
* PikachuEXE (@PikachuEXE)
|
461
481
|
|
462
482
|
Credits
|
463
483
|
=======
|
data/ci/rails-5.2.gemfile
CHANGED
data/ci/rails-6.0.gemfile
CHANGED
data/ci/rails-6.1.gemfile
CHANGED
data/ci/rails-7.0.gemfile
CHANGED
@@ -0,0 +1,27 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
gem 'railties', '~> 7.1.0'
|
4
|
+
gem 'activemodel', '~> 7.1.0'
|
5
|
+
gem 'actionpack', '~> 7.1.0'
|
6
|
+
|
7
|
+
gemspec :path => '../'
|
8
|
+
|
9
|
+
gem 'sequel', "#{ENV['SEQUEL']}"
|
10
|
+
|
11
|
+
gem 'fakefs', '>= 1.8.0', :require => 'fakefs/safe'
|
12
|
+
|
13
|
+
gem 'rspec-rails', '~> 5.0'
|
14
|
+
|
15
|
+
# MRI/Rubinius Adapter Dependencies
|
16
|
+
platform :ruby do
|
17
|
+
gem 'pg'
|
18
|
+
gem 'mysql2'
|
19
|
+
gem 'sqlite3'
|
20
|
+
end
|
21
|
+
|
22
|
+
# JRuby Adapter Dependencies
|
23
|
+
platform :jruby do
|
24
|
+
gem 'jdbc-sqlite3'
|
25
|
+
gem 'jdbc-mysql'
|
26
|
+
gem 'jdbc-postgres'
|
27
|
+
end
|
@@ -38,13 +38,7 @@ module SequelRails
|
|
38
38
|
|
39
39
|
name = format('%s (%.1fms)', payload[:name], event.duration)
|
40
40
|
sql = payload[:sql].squeeze(' ')
|
41
|
-
binds =
|
42
|
-
|
43
|
-
unless (payload[:binds] || []).empty?
|
44
|
-
binds = ' ' + payload[:binds].map do |col, v|
|
45
|
-
[col.name, v]
|
46
|
-
end.inspect
|
47
|
-
end
|
41
|
+
binds = " #{payload[:binds].inspect}" unless (payload[:binds] || []).empty?
|
48
42
|
|
49
43
|
if odd?
|
50
44
|
name = color(name, :cyan, :bold => true)
|
data/lib/sequel_rails/version.rb
CHANGED
data/spec/internal/Rakefile
CHANGED
@@ -6,5 +6,10 @@ end
|
|
6
6
|
Bundler.require :default, :development, :test
|
7
7
|
|
8
8
|
Combustion.path = ''
|
9
|
-
Combustion.initialize! 'sequel_rails'
|
9
|
+
Combustion.initialize! 'sequel_rails' do
|
10
|
+
if Rails.gem_version >= Gem::Version.new('7.1.0')
|
11
|
+
# Suppress warning about `cache_format_version`
|
12
|
+
config.active_support.cache_format_version = 7.1
|
13
|
+
end
|
14
|
+
end
|
10
15
|
Combustion::Application.load_tasks
|
@@ -25,28 +25,36 @@ describe 'Database rake tasks', :no_transaction => true do
|
|
25
25
|
it 'append the migration schema information if any' do
|
26
26
|
Dir.chdir app_root do
|
27
27
|
`rake db:migrate db:schema:dump`
|
28
|
-
|
29
|
-
|
30
|
-
|
28
|
+
sqls = [
|
29
|
+
Sequel::Model.db.from(
|
30
|
+
:schema_migrations
|
31
|
+
).insert_sql(:filename => '1273253849_add_twitter_handle_to_users.rb'),
|
32
|
+
Sequel::Model.db.from(
|
33
|
+
:schema_migrations
|
34
|
+
).insert_sql(:filename => '1365762738_add_display_name_to_users.rb'),
|
35
|
+
Sequel::Model.db.from(
|
36
|
+
:schema_migrations
|
37
|
+
).insert_sql(:filename => '1365762739_add_github_username_to_users.rb')
|
38
|
+
]
|
31
39
|
content = if ENV['TEST_ADAPTER'] == 'postgresql'
|
32
|
-
<<-EOS
|
40
|
+
<<-EOS
|
33
41
|
Sequel.migration do
|
34
42
|
change do
|
35
43
|
self << "SET search_path TO \\"$user\\", public"
|
36
|
-
self << #{sql.inspect}
|
44
|
+
#{sqls.map { |sql| "self << #{sql.inspect}" }.join("\n")}
|
37
45
|
end
|
38
46
|
end
|
39
47
|
EOS
|
40
48
|
else
|
41
|
-
<<-EOS
|
49
|
+
<<-EOS
|
42
50
|
Sequel.migration do
|
43
51
|
change do
|
44
|
-
self << #{sql.inspect}
|
52
|
+
#{sqls.map { |sql| "self << #{sql.inspect}" }.join("\n")}
|
45
53
|
end
|
46
54
|
end
|
47
55
|
EOS
|
48
|
-
end
|
49
|
-
expect(File.read(schema)).to include content
|
56
|
+
end.gsub(/^\s+/, '').strip
|
57
|
+
expect(File.read(schema).gsub(/^\s+/, '')).to include content
|
50
58
|
end
|
51
59
|
end
|
52
60
|
end
|
@@ -74,19 +82,80 @@ describe 'Database rake tasks', :no_transaction => true do
|
|
74
82
|
end
|
75
83
|
|
76
84
|
describe 'db:rollback' do
|
85
|
+
let(:version) { nil }
|
86
|
+
let(:rake_task_call) do
|
87
|
+
if version
|
88
|
+
proc { `rake db:rollback VERSION=#{version}` }
|
89
|
+
else
|
90
|
+
proc { `rake db:rollback` }
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
77
94
|
it 'revert latest migration' do
|
78
95
|
Dir.chdir app_root do
|
79
96
|
begin
|
80
97
|
expect do
|
81
|
-
|
98
|
+
rake_task_call.call
|
82
99
|
end.to change { SequelRails::Migrations.current_migration }.from(
|
83
|
-
'
|
84
|
-
).to(
|
100
|
+
'1365762739_add_github_username_to_users.rb'
|
101
|
+
).to('1365762738_add_display_name_to_users.rb')
|
85
102
|
ensure
|
86
103
|
SequelRails::Migrations.migrate_up!
|
87
104
|
end
|
88
105
|
end
|
89
106
|
end
|
107
|
+
|
108
|
+
context 'when version supplied' do
|
109
|
+
context 'same as current version' do
|
110
|
+
let(:version) { '1365762739' }
|
111
|
+
|
112
|
+
it 'does not revert' do
|
113
|
+
Dir.chdir app_root do
|
114
|
+
begin
|
115
|
+
expect do
|
116
|
+
rake_task_call.call
|
117
|
+
end.not_to change { SequelRails::Migrations.current_migration }
|
118
|
+
ensure
|
119
|
+
SequelRails::Migrations.migrate_up!
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
context 'same as last version' do
|
125
|
+
let(:version) { '1365762738' }
|
126
|
+
|
127
|
+
it 'revert latest migration' do
|
128
|
+
Dir.chdir app_root do
|
129
|
+
begin
|
130
|
+
expect do
|
131
|
+
rake_task_call.call
|
132
|
+
end.to change { SequelRails::Migrations.current_migration }.from(
|
133
|
+
'1365762739_add_github_username_to_users.rb'
|
134
|
+
).to('1365762738_add_display_name_to_users.rb')
|
135
|
+
ensure
|
136
|
+
SequelRails::Migrations.migrate_up!
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
141
|
+
context 'smaller than last version' do
|
142
|
+
let(:version) { '1273253849' }
|
143
|
+
|
144
|
+
it 'revert until migration specified by version' do
|
145
|
+
Dir.chdir app_root do
|
146
|
+
begin
|
147
|
+
expect do
|
148
|
+
rake_task_call.call
|
149
|
+
end.to change { SequelRails::Migrations.current_migration }.from(
|
150
|
+
'1365762739_add_github_username_to_users.rb'
|
151
|
+
).to('1273253849_add_twitter_handle_to_users.rb')
|
152
|
+
ensure
|
153
|
+
SequelRails::Migrations.migrate_up!
|
154
|
+
end
|
155
|
+
end
|
156
|
+
end
|
157
|
+
end
|
158
|
+
end
|
90
159
|
end
|
91
160
|
|
92
161
|
describe 'db:migrate:redo' do
|
@@ -14,20 +14,135 @@ describe SequelRails::Railties::LogSubscriber do
|
|
14
14
|
end
|
15
15
|
after { teardown }
|
16
16
|
|
17
|
-
it 'logs queries, runtime and count' do
|
18
|
-
expect(described_class.count).to eq 0
|
19
|
-
User.all
|
20
|
-
wait
|
21
|
-
expect(@logger.logged(:debug).last).to match(/SELECT \* FROM ("|`)users("|`)/)
|
22
|
-
expect(described_class.count).to be > 0
|
23
|
-
end
|
24
|
-
|
25
17
|
it 'does not log query when logger level is not debug, but track runtime and count' do
|
26
18
|
expect(described_class.count).to eq 0
|
27
|
-
@logger.level = :info
|
19
|
+
@logger.level = defined?(Logger::Severity) ? Logger::Severity::INFO : :info
|
28
20
|
User.all
|
29
21
|
wait
|
30
22
|
expect(@logger.logged(:debug).size).to eq 0
|
31
23
|
expect(described_class.count).to be > 0
|
32
24
|
end
|
25
|
+
|
26
|
+
describe 'for postgresql', :postgres do
|
27
|
+
it 'logs queries, runtime and count' do
|
28
|
+
expect(described_class.count).to eq 0
|
29
|
+
User.all
|
30
|
+
User.where(:id => 1).select_map(:id)
|
31
|
+
wait
|
32
|
+
expect(@logger.logged(:debug)[-2]).to match(/SELECT \* FROM "users"/)
|
33
|
+
expect(@logger.logged(:debug)[-1]).to match(/SELECT "id" FROM "users" WHERE \("id" = 1\)/)
|
34
|
+
expect(described_class.count).to be > 0
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'works with bound variables' do
|
38
|
+
ds = Sequel::Model.db[:users].where(:id => :$id)
|
39
|
+
ds.call(:select, :id => 1)
|
40
|
+
wait
|
41
|
+
expect(@logger.logged(:debug).last).to match(
|
42
|
+
/SELECT \* FROM "users" WHERE \("id" = \$1\) \[1\]/
|
43
|
+
)
|
44
|
+
expect(described_class.count).to be > 0
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'works with prepared statements' do
|
48
|
+
ds = Sequel::Model.db[:users].where(:id => :$id).prepare(:select, :users_by_id)
|
49
|
+
ds.call(:id => 1)
|
50
|
+
wait
|
51
|
+
expect(@logger.logged(:debug)[-2]).to match(
|
52
|
+
/PREPARE users_by_id AS SELECT \* FROM "users" WHERE \("id" = \$1\)/
|
53
|
+
)
|
54
|
+
expect(@logger.logged(:debug)[-1]).to match(
|
55
|
+
/EXECUTE users_by_id \[1\]/
|
56
|
+
)
|
57
|
+
expect(described_class.count).to be > 0
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
describe 'for mysql', :mysql do
|
62
|
+
it 'logs queries, runtime and count' do
|
63
|
+
expect(described_class.count).to eq 0
|
64
|
+
User.all
|
65
|
+
User.where(:id => 1).select_map(:id)
|
66
|
+
wait
|
67
|
+
expect(@logger.logged(:debug)[-2]).to match(/SELECT \* FROM `users`/)
|
68
|
+
expect(@logger.logged(:debug)[-1]).to match(/SELECT `id` FROM `users` WHERE \(`id` = 1\)/)
|
69
|
+
expect(described_class.count).to be > 0
|
70
|
+
end
|
71
|
+
|
72
|
+
it 'works with plain queries', :mysql do
|
73
|
+
Sequel::Model.db[:users].where(:id => 1).to_a
|
74
|
+
wait
|
75
|
+
expect(@logger.logged(:debug).last).to match(
|
76
|
+
/SELECT \* FROM `users` WHERE \(`id` = 1\)/
|
77
|
+
)
|
78
|
+
expect(described_class.count).to be > 0
|
79
|
+
end
|
80
|
+
|
81
|
+
it 'works with bound variables' do
|
82
|
+
ds = Sequel::Model.db[:users].where(:id => :$id)
|
83
|
+
ds.call(:select, :id => 1)
|
84
|
+
wait
|
85
|
+
expect(@logger.logged(:debug).last).to match(
|
86
|
+
/Executing SELECT \* FROM `users` WHERE \(`id` = \?\) \[1\]/
|
87
|
+
)
|
88
|
+
expect(described_class.count).to be > 0
|
89
|
+
end
|
90
|
+
|
91
|
+
it 'works with prepared statements' do
|
92
|
+
ds = Sequel::Model.db[:users].where(:id => :$id).prepare(:select, :users_by_id)
|
93
|
+
ds.call(:id => 1)
|
94
|
+
wait
|
95
|
+
expect(@logger.logged(:debug)[-2]).to match(
|
96
|
+
/Preparing users_by_id: SELECT \* FROM `users` WHERE \(`id` = \?\)/
|
97
|
+
)
|
98
|
+
expect(@logger.logged(:debug)[-1]).to match(
|
99
|
+
/Executing users_by_id \[1\]/
|
100
|
+
)
|
101
|
+
expect(described_class.count).to be > 0
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
describe 'for sqlite', :sqlite do
|
106
|
+
it 'logs queries, runtime and count' do
|
107
|
+
expect(described_class.count).to eq 0
|
108
|
+
User.all
|
109
|
+
User.where(:id => 1).select_map(:id)
|
110
|
+
wait
|
111
|
+
expect(@logger.logged(:debug)[-2]).to match(/SELECT \* FROM `users`/)
|
112
|
+
expect(@logger.logged(:debug)[-1]).to match(/SELECT `id` FROM `users` WHERE \(`id` = 1\)/)
|
113
|
+
expect(described_class.count).to be > 0
|
114
|
+
end
|
115
|
+
|
116
|
+
it 'works with plain queries', :mysql do
|
117
|
+
Sequel::Model.db[:users].where(:id => 1).to_a
|
118
|
+
wait
|
119
|
+
expect(@logger.logged(:debug).last).to match(
|
120
|
+
/SELECT \* FROM `users` WHERE \(`id` = 1\)/
|
121
|
+
)
|
122
|
+
expect(described_class.count).to be > 0
|
123
|
+
end
|
124
|
+
|
125
|
+
it 'works with bound variables' do
|
126
|
+
ds = Sequel::Model.db[:users].where(:id => :$id)
|
127
|
+
ds.call(:select, :id => 1)
|
128
|
+
wait
|
129
|
+
expect(@logger.logged(:debug).last).to match(
|
130
|
+
/SELECT \* FROM `users` WHERE \(`id` = :id\) {"id"=>1}/
|
131
|
+
)
|
132
|
+
expect(described_class.count).to be > 0
|
133
|
+
end
|
134
|
+
|
135
|
+
it 'works with prepared statements' do
|
136
|
+
ds = Sequel::Model.db[:users].where(:id => :$id).prepare(:select, :users_by_id)
|
137
|
+
ds.call(:id => 1)
|
138
|
+
wait
|
139
|
+
expect(@logger.logged(:debug)[-2]).to match(
|
140
|
+
/PREPARE users_by_id: SELECT \* FROM `users` WHERE \(`id` = :id\)/
|
141
|
+
)
|
142
|
+
expect(@logger.logged(:debug)[-1]).to match(
|
143
|
+
/EXECUTE users_by_id {"id"=>1}/
|
144
|
+
)
|
145
|
+
expect(described_class.count).to be > 0
|
146
|
+
end
|
147
|
+
end
|
33
148
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sequel-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brasten Sager (brasten)
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2023-
|
12
|
+
date: 2023-12-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activemodel
|
@@ -223,6 +223,7 @@ files:
|
|
223
223
|
- ci/rails-6.0.gemfile
|
224
224
|
- ci/rails-6.1.gemfile
|
225
225
|
- ci/rails-7.0.gemfile
|
226
|
+
- ci/rails-7.1.gemfile
|
226
227
|
- config.ru
|
227
228
|
- lib/action_dispatch/middleware/session/sequel_store.rb
|
228
229
|
- lib/generators/sequel.rb
|
@@ -268,6 +269,8 @@ files:
|
|
268
269
|
- spec/internal/config/initializers/session_store.rb
|
269
270
|
- spec/internal/config/routes.rb
|
270
271
|
- spec/internal/db/migrate/1273253849_add_twitter_handle_to_users.rb
|
272
|
+
- spec/internal/db/migrate/1365762738_add_display_name_to_users.rb
|
273
|
+
- spec/internal/db/migrate/1365762739_add_github_username_to_users.rb
|
271
274
|
- spec/internal/db/schema.rb.init
|
272
275
|
- spec/internal/public/favicon.ico
|
273
276
|
- spec/lib/generators/sequel/migration_spec.rb
|
@@ -319,6 +322,8 @@ test_files:
|
|
319
322
|
- spec/internal/config/initializers/session_store.rb
|
320
323
|
- spec/internal/config/routes.rb
|
321
324
|
- spec/internal/db/migrate/1273253849_add_twitter_handle_to_users.rb
|
325
|
+
- spec/internal/db/migrate/1365762738_add_display_name_to_users.rb
|
326
|
+
- spec/internal/db/migrate/1365762739_add_github_username_to_users.rb
|
322
327
|
- spec/internal/db/schema.rb.init
|
323
328
|
- spec/internal/public/favicon.ico
|
324
329
|
- spec/lib/generators/sequel/migration_spec.rb
|