motor-admin 0.4.32 → 0.4.34

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: 95d575b62467d856f7458dbd4780874c4fedbf16f73a21c7e1311cfed705d4f5
4
- data.tar.gz: c186b45675f5596f58e1ac5741861945f91c5a32bb3d3b3ccf348fe18295ec6d
3
+ metadata.gz: b8c50645e3228b532c70c3455ed170c59c21d7e69f5a0170f13c43174fe6e0c9
4
+ data.tar.gz: 3a50a9787112c88af0a5f39ebc2cb23394f240f694ea8a335641456ab64669d2
5
5
  SHA512:
6
- metadata.gz: 911204a500ef90741cb9e055850a54a5326fef55e2f5e2785c8818ef90f706604c6f798fc34a7a175da1ddd7324eee50cb35f2a13b69b575371b1b34a5469682
7
- data.tar.gz: 81baa7e705ee2e4e65aacc1a5ea53f49df337188a2378beb411c0bff7ca7e43fb40e130d82dce3ccd50e85d76e116abd8eda932f6eaee1f531a6f8f653c3f291
6
+ metadata.gz: 194f2226d32361a5e1a7ace3f8a49431d4a3d190714741930e8716f1482083907459769b65399235b5c4da0702adc1acc27cd1da0b44427ba97978cbdb58a872
7
+ data.tar.gz: 5a26102b3cd126a565ddbe479c10c30ac99e36c1675a088229b5fd3b09965e2387fad2b9fe219819764bb482496468b5e7ba4ccc59856d62114aa33a2b4b57e3
@@ -1,17 +1,19 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Motor
4
- class Audit < Audited::Audit
5
- self.table_name = 'motor_audits'
3
+ unless defined?(Motor::Audit)
4
+ module Motor
5
+ class Audit < Audited::Audit
6
+ self.table_name = 'motor_audits'
6
7
 
7
- if Rails.version.to_f >= 7.2
8
- superclass.abstract_class = true
9
- end
8
+ if Rails.version.to_f >= 7.2
9
+ superclass.abstract_class = true
10
+ end
10
11
 
11
- if Rails.version.to_f >= 7.1
12
- serialize :audited_changes, coder: HashSerializer
13
- else
14
- serialize :audited_changes, HashSerializer
12
+ if Rails.version.to_f >= 7.1
13
+ serialize :audited_changes, coder: HashSerializer
14
+ else
15
+ serialize :audited_changes, HashSerializer
16
+ end
15
17
  end
16
18
  end
17
19
  end
@@ -6,21 +6,30 @@ module Motor
6
6
  module_function
7
7
 
8
8
  def call(conn, statement)
9
- conn.send(:execute_and_clear, *statement) do |result|
10
- types = {}
11
- fields = result.fields
12
-
13
- fields.each_with_index do |fname, i|
14
- ftype = result.ftype i
15
- fmod = result.fmod i
16
- types[fname] = conn.send(:get_oid_type, ftype, fmod, fname)
9
+ if Rails.version.to_f >= 8.0
10
+ result = conn.send(:internal_execute, *statement)
11
+ process_result(conn, result)
12
+ else
13
+ conn.send(:execute_and_clear, *statement) do |result|
14
+ process_result(conn, result)
17
15
  end
16
+ end
17
+ end
18
18
 
19
- if conn.respond_to?(:build_result, true)
20
- conn.send(:build_result, columns: fields, rows: result.values, column_types: types)
21
- else
22
- ActiveRecord::Result.new(fields, result.values, types)
23
- end
19
+ def process_result(conn, result)
20
+ types = {}
21
+ fields = result.fields
22
+
23
+ fields.each_with_index do |fname, i|
24
+ ftype = result.ftype i
25
+ fmod = result.fmod i
26
+ types[fname] = conn.send(:get_oid_type, ftype, fmod, fname)
27
+ end
28
+
29
+ if conn.respond_to?(:build_result, true)
30
+ conn.send(:build_result, columns: fields, rows: result.values, column_types: types)
31
+ else
32
+ ActiveRecord::Result.new(fields, result.values, types)
24
33
  end
25
34
  end
26
35
  end
@@ -110,15 +110,27 @@ module Motor
110
110
 
111
111
  columns = Resources::CustomSqlColumnsCache.call(config[:custom_sql])
112
112
 
113
+ base_column = klass.connection.schema_cache.columns_hash(klass.table_name).first.last
114
+
113
115
  columns_hash =
114
116
  columns.each_with_object({}) do |column, acc|
115
117
  acc[column[:name]] =
116
- ActiveRecord::ConnectionAdapters::Column.new(
117
- column[:name],
118
- nil,
119
- ActiveRecord::ConnectionAdapters::SqlTypeMetadata.new(sql_type: column[:column_type],
120
- type: column[:column_type].to_sym)
121
- )
118
+ if Rails.version.to_f >= 7.2
119
+ base_column.class.new(
120
+ column[:name],
121
+ nil,
122
+ base_column.sql_type_metadata.class.new(
123
+ ActiveRecord::ConnectionAdapters::SqlTypeMetadata.new(sql_type: column[:column_type],
124
+ type: column[:column_type].to_sym))
125
+ )
126
+ else
127
+ ActiveRecord::ConnectionAdapters::Column.new(
128
+ column[:name],
129
+ nil,
130
+ ActiveRecord::ConnectionAdapters::SqlTypeMetadata.new(sql_type: column[:column_type],
131
+ type: column[:column_type].to_sym)
132
+ )
133
+ end
122
134
  end
123
135
 
124
136
  klass.instance_variable_set(:@__motor_custom_sql_columns_hash, columns_hash)
data/lib/motor/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Motor
4
- VERSION = '0.4.32'
4
+ VERSION = '0.4.34'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: motor-admin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.32
4
+ version: 0.4.34
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pete Matsyburka
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-12-12 00:00:00.000000000 Z
11
+ date: 2024-12-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ar_lazy_preload