rom-sql 3.6.3 → 3.6.5

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: 10de6edf52d1ae5d345bc22f2c884ab9f35d39f52ed1b31afc227c39c97e2922
4
- data.tar.gz: 865b5d0f4aabdd7fc5911ec269e43977257212517d9373574861c47fa79e1af8
3
+ metadata.gz: cbc16afacec4f00a9b508c4bed68298b6761644be79903b69835531a0ec91141
4
+ data.tar.gz: 78e3d647bee05b90821261073034ee7d6bd18f12dd240c32e92068b873bd37d5
5
5
  SHA512:
6
- metadata.gz: 1630dea45a0f30921a6298ea279d817e48d0bff6953639164304d4c308eb48a442b3ffe68dde0259e28ec0412a8b4ecea0c36bfc1c739d7ccbdaaa7dc49b2ac5
7
- data.tar.gz: df51ba2b2674e601f7f44fb492e65bf753ed1cc258599eedd2a2f0fc8100f7dd694899cc461492e93f3c5d98cad2dfe4901e7754965f177e147c636b3d7d14d1
6
+ metadata.gz: fd5ba27726315fa0dcf547c98aee77790e361830060054bdccbcfaf0c114a49d0ab4c22036dee0b77118f5a87ccbad939caafa6d1e2f1a7e723e44550c5fd90e
7
+ data.tar.gz: 2dec52f75e5eb999618515c841af58e4af76595a2222a29087f5c9f823c7769d0e2acbf6ff5f1696fe6f8bfcd123ebf789fc7c1c181aaa5aee8fd1c97ac311c1
data/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  <!--- DO NOT EDIT THIS FILE - IT'S AUTOMATICALLY GENERATED VIA DEVTOOLS --->
2
2
 
3
+ ## 3.6.5 2024-12-25
4
+
5
+
6
+ ### Fixed
7
+
8
+ - Fix syntax error under Ruby 3.4 (@flash-gordon)
9
+
10
+ [Compare v3.6.4...v3.6.5](https://github.com/rom-rb/rom-sql/compare/v3.6.4...v3.6.5)
11
+
12
+ ## 3.6.4 2024-07-01
13
+
14
+
15
+ ### Fixed
16
+
17
+ - Excessive logging when same gateway is shared between multiple containers (@flash-gordon)
18
+ - Warning about using color option from active-support log subscriber (@flash-gordon + @bendangelo)
19
+
20
+
21
+ [Compare v3.6.3...v3.6.4](https://github.com/rom-rb/rom-sql/compare/v3.6.3...v3.6.4)
22
+
3
23
  ## 3.6.3 2024-05-06
4
24
 
5
25
 
@@ -35,6 +35,8 @@ module ROM
35
35
  db_notifications = relations.values.map { |r| [r.dataset.db, r.notifications] }.uniq.to_h
36
36
 
37
37
  db_notifications.each do |db, notifications|
38
+ next if db.respond_to?(:rom_instrumentation?)
39
+
38
40
  instrumenter = Instrumenter.new(db.database_type, notifications)
39
41
  db.extend(instrumenter)
40
42
  end
@@ -56,6 +58,8 @@ module ROM
56
58
 
57
59
  # @api private
58
60
  def initialize(name, notifications)
61
+ super()
62
+
59
63
  @name = name
60
64
  @notifications = notifications
61
65
  define_log_connection_yield
@@ -68,6 +72,8 @@ module ROM
68
72
  name = self.name
69
73
  notifications = self.notifications
70
74
 
75
+ define_method(:rom_instrumentation?) { true }
76
+
71
77
  define_method(:log_connection_yield) do |*args, &block|
72
78
  notifications.instrument(:sql, name: name, query: args[0]) do
73
79
  super(*args, &block)
@@ -5,6 +5,21 @@ require 'active_support/log_subscriber'
5
5
  module ROM
6
6
  module SQL
7
7
  class RailsLogSubscriber < ActiveSupport::LogSubscriber
8
+ as_version =
9
+ begin
10
+ require "active_support/gem_version"
11
+ ActiveSupport.gem_version
12
+ rescue LoadError
13
+ nil
14
+ end
15
+
16
+ COLOR_OPTION =
17
+ if as_version && as_version >= Gem::Version.new("7.2")
18
+ {color: true}
19
+ else
20
+ true
21
+ end
22
+
8
23
  def sql(event)
9
24
  return unless logger.debug?
10
25
 
@@ -15,10 +30,10 @@ module ROM
15
30
  binds = payload[:binds].to_a.inspect if payload[:binds]
16
31
 
17
32
  if odd?
18
- name = color(name, :cyan, true)
19
- sql = color(sql, nil, true)
33
+ name = color(name, :cyan, COLOR_OPTION)
34
+ sql = color(sql, nil, COLOR_OPTION)
20
35
  else
21
- name = color(name, :magenta, true)
36
+ name = color(name, :magenta, COLOR_OPTION)
22
37
  end
23
38
 
24
39
  debug " #{name} #{sql} #{binds}"
@@ -40,7 +40,7 @@ module ROM
40
40
  WINDOW_FRAMES[nil] = nil
41
41
  WINDOW_FRAMES[:all] = WINDOW_FRAMES[rows: [:start, :end]]
42
42
  WINDOW_FRAMES[:rows] = WINDOW_FRAMES[rows: [:start, :current]]
43
- WINDOW_FRAMES[range: :current] = WINDOW_FRAMES[range: [:current, :current]]
43
+ WINDOW_FRAMES[{ range: :current }] = WINDOW_FRAMES[range: [:current, :current]]
44
44
 
45
45
  # Return a new attribute with an alias
46
46
  #
@@ -37,6 +37,10 @@ module ROM
37
37
 
38
38
  numeric_pk_type Types::Serial
39
39
 
40
+ TYPE_GUESSES = {
41
+ /datetime\((\d+)\)/ => :datetime
42
+ }.freeze
43
+
40
44
  def call(primary_key:, db_type:, type:, allow_null:, **rest)
41
45
  if primary_key
42
46
  map_pk_type(type, db_type, **rest)
@@ -64,7 +68,7 @@ module ROM
64
68
 
65
69
  # @api private
66
70
  def map_type(ruby_type, db_type, **kw)
67
- type = self.class.ruby_type_mapping[ruby_type]
71
+ type = self.class.ruby_type_mapping[ruby_type || guess_type(db_type)]
68
72
 
69
73
  if db_type.is_a?(String) && db_type.include?('numeric') || db_type.include?('decimal')
70
74
  map_decimal_type(db_type)
@@ -75,6 +79,15 @@ module ROM
75
79
  end
76
80
  end
77
81
 
82
+ # @api private
83
+ def guess_type(db_type)
84
+ TYPE_GUESSES.find do |regex, type|
85
+ if db_type.is_a?(String) && db_type.match(regex)
86
+ break type
87
+ end
88
+ end
89
+ end
90
+
78
91
  # @api private
79
92
  def map_decimal_type(type)
80
93
  precision = DECIMAL_REGEX.match(type)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module ROM
4
4
  module SQL
5
- VERSION = '3.6.3'
5
+ VERSION = "3.6.5"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rom-sql
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.6.3
4
+ version: 3.6.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Piotr Solnica
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2024-05-06 00:00:00.000000000 Z
10
+ date: 2024-12-25 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: sequel
@@ -220,7 +219,6 @@ metadata:
220
219
  documentation_uri: https://api.rom-rb.org/rom-sql/
221
220
  mailing_list_uri: https://discourse.rom-rb.org/
222
221
  bug_tracker_uri: https://github.com/rom-rb/rom-sql/issues
223
- post_install_message:
224
222
  rdoc_options: []
225
223
  require_paths:
226
224
  - lib
@@ -235,8 +233,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
235
233
  - !ruby/object:Gem::Version
236
234
  version: '0'
237
235
  requirements: []
238
- rubygems_version: 3.5.3
239
- signing_key:
236
+ rubygems_version: 3.6.2
240
237
  specification_version: 4
241
238
  summary: SQL databases support for ROM
242
239
  test_files: []