sequel-activerecord_connection 1.2.9 → 1.2.10

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: 9cd2f9d2df2e116227a94f6a005a5f7470178e4ecfc22218fe0a3dc456a2ecd2
4
- data.tar.gz: 64e96f773827d185768d6190468a350162c3e7e4923a5f5dc565d50ec8064f79
3
+ metadata.gz: 53c5925926ff3924bcef9f86b9450449c801e260196b9d25b85fefa2ce569239
4
+ data.tar.gz: c7b26f34a3b40ea1691f82e28aa1dd83cf598593c2dd96aa4f7ba3f450cd97fd
5
5
  SHA512:
6
- metadata.gz: 58862596df481839c1668ce4f3062f56255dc5115a2aa8bfb08499c10b76eac0859b51485f639c5fa16459cff170c2531b7c86c0e38efe9d5dfe6bc94a6a2891
7
- data.tar.gz: 1aa33eb5cd5eb85be84252bd3ddd02ec537e7bf89481882604fc691d72d055d4bd85e6ad97562c44b39c90beabb661ba04ba1a311775b707aa71984f23dc8e25
6
+ metadata.gz: 29c0ff34e41b468d04b24f0ab17dcea10ff63b562873a63669f137b24eb31c3b78869d35154879719c1bc270bc161893250c29ab22dd89fb45ddd4abc0d0678f
7
+ data.tar.gz: 4de28a717d23a9879420c716c81ff7609768f76d224394c254f91b76338f6b7b38399584a63152745e0b4efc165a34e223ca5f113fcc54cdbb65abf92ca9448d
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 1.2.10 (2022-12-13)
2
+
3
+ * Fix incorrect PG type mapping when using prepared statements in Sequel (@janko)
4
+
1
5
  ## 1.2.9 (2022-03-15)
2
6
 
3
7
  * Remove `sequel_pg` and `pg` runtime dependencies introduced in the previous version (@janko)
data/README.md CHANGED
@@ -9,10 +9,10 @@ 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
11
  It works on ActiveRecord 4.2+ and fully supports PostgresSQL, MySQL and SQLite
12
- adapters, both native and JDBC (JRuby). There is attempted suppport for [Oracle
13
- enhanced] and [SQL Server] Active Record adapters (`oracle` and `tinytds` in
14
- Sequel). Other adapters might work too, but their integration hasn't been
15
- tested.
12
+ adapters, both native 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.
16
16
 
17
17
  ## Why reuse the database connection?
18
18
 
@@ -38,35 +38,36 @@ 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
- ## Installation
41
+ ## Framework Agnostic
42
42
 
43
- Add this line to your application's Gemfile:
43
+ The only hard dependencies are:
44
44
 
45
- ```rb
46
- gem "sequel-activerecord_connection", "~> 1.0"
47
- ```
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
48
 
49
- And then execute:
49
+ ...which means you can use it with any Rack / Ruby based framework:
50
+ Rails / Roda / Sinatra etc. or even without a framework.
50
51
 
51
- ```sh
52
- $ bundle install
53
- ```
52
+ ## Installation
54
53
 
55
- Or install it yourself as:
54
+ Add the gem to your project:
56
55
 
57
56
  ```sh
58
- $ gem install sequel-activerecord_connection
57
+ $ bundle add sequel-activerecord_connection
59
58
  ```
60
59
 
61
60
  ## Usage
62
61
 
63
62
  Assuming you've configured your ActiveRecord connection, you can initialize the
64
- appropriate Sequel adapter and load the `activerecord_connection` extension:
63
+ appropriate Sequel adapter and load the `activerecord_connection` extension: e.g.
65
64
 
66
65
  ```rb
67
- require "sequel"
66
+ # Place in relevant initializer
67
+ # e.g. Rails: config/initializers/sequel.rb
68
68
 
69
- DB = Sequel.postgres(extensions: :activerecord_connection)
69
+ require "sequel"
70
+ DB = Sequel.postgres(extensions: :activerecord_connection) # postgres
70
71
  ```
71
72
 
72
73
  Now any Sequel operations that you make will internaly be done using the
@@ -216,6 +217,35 @@ end
216
217
  DB.activerecord_model = MyModel
217
218
  ```
218
219
 
220
+ ### Normalizing SQL logs
221
+
222
+ Active Record injects values into queries using bound variables, and displays
223
+ them at the end of SQL logs:
224
+
225
+ ```sql
226
+ SELECT accounts.* FROM accounts WHERE accounts.email = $1 LIMIT $2 [["email", "user@example.com"], ["LIMIT", 1]]
227
+ ```
228
+
229
+ Sequel interpolates values into its queries, so by default its SQL logs include
230
+ them inline:
231
+
232
+ ```sql
233
+ SELECT accounts.* FROM accounts WHERE accounts.email = 'user@example.com' LIMIT 1
234
+ ```
235
+
236
+ If you want to normalize logs to group similar queries, or you want to protect
237
+ sensitive data from being stored in the logs, you can use the
238
+ [sql_log_normalizer] extension to remove literal strings and numbers from
239
+ logged SQL queries:
240
+
241
+ ```rb
242
+ DB = Sequel.postgres(extensions: :activerecord_connection)
243
+ DB.extension :sql_log_normalizer
244
+ ```
245
+ ```sql
246
+ SELECT accounts.* FROM accounts WHERE accounts.email = ? LIMIT ?
247
+ ```
248
+
219
249
  ## Tests
220
250
 
221
251
  You'll first want to run the rake tasks for setting up databases and users:
@@ -238,6 +268,10 @@ $ rake db_teardown_postgres
238
268
  $ rake db_teardown_mysql
239
269
  ```
240
270
 
271
+ ## Support
272
+
273
+ Please feel free to raise a new disucssion in [Github issues](https://github.com/janko/sequel-activerecord_connection/discussions), or search amongst the existing questions there.
274
+
241
275
  ## License
242
276
 
243
277
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -252,3 +286,4 @@ Everyone interacting in this project's codebases, issue trackers, chat rooms and
252
286
  [sequel transaction hooks]: http://sequel.jeremyevans.net/rdoc/files/doc/transactions_rdoc.html#label-Transaction+Hooks
253
287
  [Oracle enhanced]: https://github.com/rsim/oracle-enhanced
254
288
  [SQL Server]: https://github.com/rails-sqlserver/activerecord-sqlserver-adapter
289
+ [sql_log_normalizer]: https://sequel.jeremyevans.net/rdoc-plugins/files/lib/sequel/extensions/sql_log_normalizer_rb.html
@@ -31,6 +31,14 @@ module Sequel
31
31
  raise
32
32
  end
33
33
 
34
+ private
35
+
36
+ def _execute(conn, *)
37
+ Utils.set_value(conn, :type_map_for_results, PG::TypeMapAllStrings.new) do
38
+ super
39
+ end
40
+ end
41
+
34
42
  # Copy-pasted from Sequel::Postgres::Adapter.
35
43
  module ConnectionMethods
36
44
  # The underlying exception classes to reraise as disconnect errors
@@ -87,9 +95,7 @@ module Sequel
87
95
  # Return the PG::Result containing the query results.
88
96
  def execute_query(sql, args)
89
97
  @db.log_connection_yield(sql, self, args) do
90
- Utils.set_value(self, :type_map_for_results, PG::TypeMapAllStrings.new) do
91
- args ? async_exec_params(sql, args) : async_exec(sql)
92
- end
98
+ args ? async_exec_params(sql, args) : async_exec(sql)
93
99
  end
94
100
  end
95
101
  end
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "sequel-activerecord_connection"
3
- spec.version = "1.2.9"
3
+ spec.version = "1.2.10"
4
4
  spec.authors = ["Janko Marohnić"]
5
5
  spec.email = ["janko.marohnic@gmail.com"]
6
6
 
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.2.9
4
+ version: 1.2.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Janko Marohnić
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-03-15 00:00:00.000000000 Z
11
+ date: 2022-12-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sequel