activerecord-trilogy-adapter 3.1.2 → 3.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fdefae6851cc1a947548be1483c2b7caf0cfa4c212e44f6729148e21e5a72179
4
- data.tar.gz: 07e1d853816ccf58b1a7cda8c45cdd79e2901b5098b46afa1d9eac7c096ff9f3
3
+ metadata.gz: 3f5d6b4f69f5c1f439b891dca0922cd393772f6e1776e23ac2d0b547bf17365a
4
+ data.tar.gz: 337d3a8f1e675d4af5f0b7601a38efa538c07feaa682ee80fce8e2cc7b8ba528
5
5
  SHA512:
6
- metadata.gz: 776643f73ad3698495123ad6498d59cf02d77d0be66f1353a52e4f08c530946e6013316366fb62279b50a7b027fbce7e044b9bef87165e4acc5d454bb5c73252
7
- data.tar.gz: afffb5839b51028ff2b33a34ee147bf5cce501e920273051eaf8054c73e76836b56a426198ef3762ba3749286222e38f27033d93e82f08cf45d5d066e6d36c0c
6
+ metadata.gz: 4e68d138d1b76e9f97e22883c2652790d39845e1be27878c5ba17eaaf27397505644620febd3694b87a8a4f0ca4b8011ed0d2127eca6cbab859d999ef8bdc414
7
+ data.tar.gz: a1661d07d31cf117a78abb3d3b53fb2aa9316cc9697c67c4e16cd4785a640b72a58bf01eceec53b2dd74eb26dcf7824fb6d9934407954b07606dfdbf1af9a0e0
data/README.md CHANGED
@@ -4,7 +4,7 @@ Ruby on Rails Active Record database adapter for [Trilogy](https://github.com/tr
4
4
 
5
5
  This gem offers Trilogy support for versions of Active Record prior to v7.1. Currently supports:
6
6
 
7
- - ⚠️ Rails v7.1+ includes Trilogy support by default making this gem unnecessary
7
+ - ⚠️ Rails v7.1+ includes Trilogy support by default making this gem unnecessary (and still do add `gem "trilogy"` to your Gemfile)
8
8
  - ✅ Rails v7.0.x
9
9
  - ✅ Rails v6.1.x
10
10
  - ✅ Rails v6.0.x
@@ -21,21 +21,6 @@ module ActiveRecord
21
21
  ActiveRecord::Result.new(result.fields, result.to_a)
22
22
  end
23
23
 
24
- def write_query?(sql) # :nodoc:
25
- !READ_QUERY.match?(sql)
26
- rescue ArgumentError # Invalid encoding
27
- !READ_QUERY.match?(sql.b)
28
- end
29
-
30
- def explain(arel, binds = [])
31
- sql = "EXPLAIN #{to_sql(arel, binds)}"
32
- start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
33
- result = internal_exec_query(sql, "EXPLAIN", binds)
34
- elapsed = Process.clock_gettime(Process::CLOCK_MONOTONIC) - start
35
-
36
- MySQL::ExplainPrettyPrinter.new.pp(result, elapsed)
37
- end
38
-
39
24
  def select_all(*, **) # :nodoc:
40
25
  result = super
41
26
  with_trilogy_connection do |conn|
@@ -80,7 +80,7 @@ module ActiveRecord
80
80
  def new_client(config)
81
81
  config[:ssl_mode] = parse_ssl_mode(config[:ssl_mode]) if config[:ssl_mode]
82
82
  ::Trilogy.new(config)
83
- rescue ::Trilogy::ConnectionError, ::Trilogy::ProtocolError => error
83
+ rescue ::Trilogy::Error => error
84
84
  raise translate_connect_error(config, error)
85
85
  end
86
86
 
@@ -155,6 +155,12 @@ module ActiveRecord
155
155
  end
156
156
 
157
157
  def initialize(connection, logger, connection_options, config)
158
+ config = config.dup
159
+
160
+ # Trilogy ignores `socket` if `host` is set. We want the opposite to allow
161
+ # configuring UNIX domain sockets via `DATABASE_URL`.
162
+ config.delete(:host) if config[:socket]
163
+
158
164
  super
159
165
  # Ensure that we're treating prepared_statements in the same way that Rails 7.1 does
160
166
  @prepared_statements = self.class.type_cast_config_to_boolean(
@@ -214,6 +220,10 @@ module ActiveRecord
214
220
  end
215
221
  end
216
222
 
223
+ def connected?
224
+ !connection.nil?
225
+ end
226
+
217
227
  def active?
218
228
  return false if connection&.closed?
219
229
 
@@ -240,6 +250,10 @@ module ActiveRecord
240
250
  end
241
251
  end
242
252
 
253
+ def error_number(exception)
254
+ exception.error_code if exception.respond_to?(:error_code)
255
+ end
256
+
243
257
  def self.find_cmd_and_exec(commands, *args) # :doc:
244
258
  commands = Array(commands)
245
259
 
@@ -290,10 +304,6 @@ module ActiveRecord
290
304
  nil
291
305
  end
292
306
 
293
- def error_number(exception)
294
- exception.error_code if exception.respond_to?(:error_code)
295
- end
296
-
297
307
  attr_accessor :connection
298
308
 
299
309
  def connect
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TrilogyAdapter
4
- VERSION = "3.1.2"
4
+ VERSION = "3.2.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-trilogy-adapter
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.2
4
+ version: 3.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - GitHub Engineering
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-08-28 00:00:00.000000000 Z
11
+ date: 2025-05-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: trilogy
@@ -100,7 +100,9 @@ dependencies:
100
100
  - - "~>"
101
101
  - !ruby/object:Gem::Version
102
102
  version: '12.3'
103
- description:
103
+ description: "This gem is only needed before Rails 7.1, where the trilogy adapter
104
+ is built in. \nWhen you upgrade to a version after 7.1.a, replace this with `gem
105
+ \"trilogy\"` to ensure\nthat trilogy itself is available.\n"
104
106
  email:
105
107
  - opensource+trilogy@github.com
106
108
  executables: []