sequel-activerecord_connection 1.5.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ecd95c01a950e81d89914199827c09d3ef0b95b106cfe0601afa9dd40f395f62
4
- data.tar.gz: 9f5c69f4291dfd46a1d07476a1fca226aafcdd6e6ef5c0ce697554a3c2d385e3
3
+ metadata.gz: a2912969fb906ae413ccdded0137055b743786a4fdcf8de812c643d8c0facc6a
4
+ data.tar.gz: 75662cc9ae2f373a106b8c7163bc96fc4ae067a7001f39df166a780648dd9998
5
5
  SHA512:
6
- metadata.gz: 85877ab167fbca19e25b366c05f934488f610f23b790cdd360c80e67cf0cecce35104846807f77374671d6e8214008c5aaab88f5ce10d47106060e049dc94f59
7
- data.tar.gz: d25ed24c5444c0c6cdfeb91857b42db90f8d3115f1ca678b4e7ec876845255d65737e8e5d2837c633058356ad7ac32ab5da71085c68c5021134765a19a10b7ee
6
+ metadata.gz: 2a2d9c7f5c1b88bb0c8285968f61ae2c8e3dd27df266df9675b14c5ff6fd9eb06a4e37a9a2c4c7638a7fe11405df2a8bfb6b79ae58dda38e8bbafcd29309b07d
7
+ data.tar.gz: 2e73044828506553458070cd5763ce2196706e6a58713dde428182b14f30266aa52a278dcd2a4c0e9d1b71984bb73bd8099351199140ee211c82dadbe9334985
data/CHANGELOG.md CHANGED
@@ -1,6 +1,14 @@
1
- ## HEAD
1
+ ## 2.0.0 (2024-11-10)
2
2
 
3
- * Avoid permanent checkout of Active Record 7.2+ connections (@janko)
3
+ * The `after_commit_everywhere` gem now needs to be added to the Gemfile manually on Active Record < 7.2 (@janko)
4
+
5
+ ## 1.5.1 (2024-11-08)
6
+
7
+ * Add support for Active Record 8.0 (@phlipper)
8
+
9
+ ## 1.5.0 (2024-10-16)
10
+
11
+ * Avoid permanent connection checkout on Active Record 7.2+ (@janko)
4
12
 
5
13
  ## 1.4.3 (2024-09-26)
6
14
 
data/README.md CHANGED
@@ -8,11 +8,11 @@ This can be useful if you want to use a library that uses Sequel (e.g.
8
8
  or if you just want to use Sequel for more complex queries, and you want to
9
9
  avoid creating new database connections.
10
10
 
11
- It works on ActiveRecord 4.2+ and fully supports PostgresSQL, MySQL and SQLite,
12
- both the native adapters and JDBC (JRuby). The [SQL Server] external adapter is
13
- supported as well (`tinytds` in Sequel), and there is attempted support for
14
- [Oracle enhanced] (`oracle` and in Sequel). Other adapters might work too, but
15
- their integration hasn't been tested.
11
+ It fully supports PostgreSQL, MySQL and SQLite adapters, both the native ones
12
+ and JDBC (JRuby). The [SQL Server] external adapter is supported as well
13
+ (`tinytds` in Sequel), and there is attempted support for [Oracle enhanced]
14
+ (`oracle` and in Sequel). Other adapters might work too, but their integration
15
+ hasn't been tested.
16
16
 
17
17
  ## Why reuse the database connection?
18
18
 
@@ -38,17 +38,6 @@ background to share the same database connection, which is something Sequel
38
38
  wasn't designed for. Reusing Active Record's connection means (dis)connecting
39
39
  and sharing between threads is all handled automatically.
40
40
 
41
- ## Framework Agnostic
42
-
43
- The only hard dependencies are:
44
-
45
- * [ActiveRecord](https://github.com/rails/rails/tree/main/activerecord)
46
- * [Sequel](https://github.com/jeremyevans/sequel)
47
- * [after_commit_everywhere](https://github.com/Envek/after_commit_everywhere)
48
-
49
- ...which means you can use it with any Rack / Ruby based framework:
50
- Rails / Roda / Sinatra etc. or even without a framework.
51
-
52
41
  ## Installation
53
42
 
54
43
  Add the gem to your project:
@@ -57,6 +46,12 @@ Add the gem to your project:
57
46
  $ bundle add sequel-activerecord_connection
58
47
  ```
59
48
 
49
+ If you're using Active Record 7.1 or older, you'll also need to add the [after_commit_everywhere] gem:
50
+
51
+ ```sh
52
+ $ bundle add after_commit_everywhere # on Active Record 7.1 or older
53
+ ```
54
+
60
55
  ## Usage
61
56
 
62
57
  Assuming you've configured your ActiveRecord connection, you can initialize the
@@ -67,7 +62,7 @@ appropriate Sequel adapter and load the `activerecord_connection` extension: e.g
67
62
  # e.g. Rails: config/initializers/sequel.rb
68
63
 
69
64
  require "sequel"
70
- DB = Sequel.postgres(extensions: :activerecord_connection) # postgres
65
+ DB = Sequel.postgres(extensions: :activerecord_connection) # for PostgreSQL
71
66
  ```
72
67
 
73
68
  Now any Sequel operations that you make will internaly be done using the
@@ -245,19 +240,6 @@ Sequel.postgres(extensions: [:activerecord_connection, :sql_log_normalizer])
245
240
  SELECT accounts.* FROM accounts WHERE accounts.email = ? LIMIT ?
246
241
  ```
247
242
 
248
- Note that the `sql_log_normalizer` extension opens a database connection while
249
- it's being loaded. If you're setting up Sequel in a Rails initializer, you'll
250
- probably want to handle the database not existing, so that commands such as
251
- `rails db:create` continue to work.
252
-
253
- ```rb
254
- DB = Sequel.postgres(extensions: :activerecord_connection)
255
- begin
256
- DB.extension :sql_log_normalizer
257
- rescue ActiveRecord::NoDatabaseError
258
- end
259
- ```
260
-
261
243
  ## Tests
262
244
 
263
245
  You'll first want to run the rake tasks for setting up databases and users:
@@ -299,3 +281,4 @@ Everyone interacting in this project's codebases, issue trackers, chat rooms and
299
281
  [Oracle enhanced]: https://github.com/rsim/oracle-enhanced
300
282
  [SQL Server]: https://github.com/rails-sqlserver/activerecord-sqlserver-adapter
301
283
  [sql_log_normalizer]: https://sequel.jeremyevans.net/rdoc-plugins/files/lib/sequel/extensions/sql_log_normalizer_rb.html
284
+ [after_commit_everywhere]: https://github.com/Envek/after_commit_everywhere
@@ -118,8 +118,7 @@ module Sequel
118
118
 
119
119
  # When Active Record holds the transaction, we cannot use Sequel hooks,
120
120
  # because Sequel doesn't have knowledge of when the transaction is
121
- # committed. So in this case we register an Active Record hook using the
122
- # after_commit_everywhere gem.
121
+ # committed. So in this case we register the hook using Active Record.
123
122
  def add_transaction_hook(conn, type, block)
124
123
  if _trans(conn)[:activerecord]
125
124
  activerecord_transaction_callback(type, &block)
@@ -130,8 +129,7 @@ module Sequel
130
129
 
131
130
  # When Active Record holds the savepoint, we cannot use Sequel hooks,
132
131
  # because Sequel doesn't have knowledge of when the savepoint is
133
- # released. So in this case we register an Active Record hook using the
134
- # after_commit_everywhere gem.
132
+ # released. So in this case we register the hook using Active Record.
135
133
  def add_savepoint_hook(conn, type, block)
136
134
  if _trans(conn)[:savepoints].last[:activerecord]
137
135
  activerecord_transaction_callback(type, &block)
@@ -145,7 +143,12 @@ module Sequel
145
143
  activerecord_connection.current_transaction.public_send(type, &block)
146
144
  end
147
145
  else
148
- require "after_commit_everywhere"
146
+ begin
147
+ gem "after_commit_everywhere", "~> 1.1"
148
+ require "after_commit_everywhere"
149
+ rescue LoadError
150
+ fail Error, %q(You need to add `gem "after_commit_everywhere", "~> 1.1"` to your Gemfile when using Active Record < 7.2)
151
+ end
149
152
 
150
153
  def activerecord_transaction_callback(type, &block)
151
154
  AfterCommitEverywhere.public_send(type, &block)
@@ -1,8 +1,8 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "sequel-activerecord_connection"
3
- spec.version = "1.5.0"
3
+ spec.version = "2.0.0"
4
4
  spec.authors = ["Janko Marohnić"]
5
- spec.email = ["janko.marohnic@gmail.com"]
5
+ spec.email = ["janko@hey.com"]
6
6
 
7
7
  spec.summary = %q{Allows Sequel to use ActiveRecord connection for database interaction.}
8
8
  spec.description = %q{Allows Sequel to use ActiveRecord connection for database interaction.}
@@ -12,8 +12,7 @@ Gem::Specification.new do |spec|
12
12
  spec.required_ruby_version = ">= 2.5"
13
13
 
14
14
  spec.add_dependency "sequel", "~> 5.38"
15
- spec.add_dependency "activerecord", ">= 5.0", "< 8"
16
- spec.add_dependency "after_commit_everywhere", "~> 1.1"
15
+ spec.add_dependency "activerecord", ">= 5.0", "< 8.1"
17
16
 
18
17
  spec.add_development_dependency "sequel_pg" unless RUBY_ENGINE == "jruby"
19
18
  spec.add_development_dependency "minitest"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sequel-activerecord_connection
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Janko Marohnić
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-10-16 00:00:00.000000000 Z
11
+ date: 2024-11-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sequel
@@ -33,7 +33,7 @@ dependencies:
33
33
  version: '5.0'
34
34
  - - "<"
35
35
  - !ruby/object:Gem::Version
36
- version: '8'
36
+ version: '8.1'
37
37
  type: :runtime
38
38
  prerelease: false
39
39
  version_requirements: !ruby/object:Gem::Requirement
@@ -43,21 +43,7 @@ dependencies:
43
43
  version: '5.0'
44
44
  - - "<"
45
45
  - !ruby/object:Gem::Version
46
- version: '8'
47
- - !ruby/object:Gem::Dependency
48
- name: after_commit_everywhere
49
- requirement: !ruby/object:Gem::Requirement
50
- requirements:
51
- - - "~>"
52
- - !ruby/object:Gem::Version
53
- version: '1.1'
54
- type: :runtime
55
- prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
- requirements:
58
- - - "~>"
59
- - !ruby/object:Gem::Version
60
- version: '1.1'
46
+ version: '8.1'
61
47
  - !ruby/object:Gem::Dependency
62
48
  name: sequel_pg
63
49
  requirement: !ruby/object:Gem::Requirement
@@ -102,7 +88,7 @@ dependencies:
102
88
  version: '0'
103
89
  description: Allows Sequel to use ActiveRecord connection for database interaction.
104
90
  email:
105
- - janko.marohnic@gmail.com
91
+ - janko@hey.com
106
92
  executables: []
107
93
  extensions: []
108
94
  extra_rdoc_files: []