activerecord-nulldb-adapter 1.2.0 → 1.2.1

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: 8ac9f7843f4785d671294e7e8972f4554dcbfc6d600d604883b0ca19d08ec7f4
4
- data.tar.gz: 650cb1914d1c198222c5cfee766aec3fb73ba737315f6b3aa6f6c297203ccf31
3
+ metadata.gz: d96aa93ee94ff8e5066079bc5a1109013411dae9daa1e9b4ad3006c376cde011
4
+ data.tar.gz: 95f8ba73a83564f08990b90e21caa482dc486f9435092c91eff452b6a376c663
5
5
  SHA512:
6
- metadata.gz: f54127d749048e34ed4ecc921d85a200a71b2e84d582c947855a0d17165475e9d57f2b0cd238b8214fb05f8dbfa771040e00921fa852f5fb45c68012acf6856f
7
- data.tar.gz: 114379440a0dbfa40a509fb79959b214ecc39aea59553f81f1fcbbd969959935d60f25aaab2e5aa443e7446f5c197c56f11e831d2773e7a6e2f457d50e7c43be
6
+ metadata.gz: 8a69a0503e3b4b5a2fc57359c76f7227f22663575af4cb3c786da9a0cea42164b91f5009307733e2aacf420bf32e2be105c9f9ed12bfd06c8fd1604de247c6f7
7
+ data.tar.gz: c6ac3b7d961fc2cb68279201987cbeb9143d79bdc66a62984f1df97fa4cf04f295c136192e3d0c4ccd7e8da91784cd884438b11aad5001f9fade65294fb61444
data/CHANGES.md CHANGED
@@ -1,6 +1,11 @@
1
1
  Unreleased
2
2
  ----------
3
3
 
4
+ 1.2.1 (2025-12-02)
5
+
6
+ - Add `exclusion_constraint` #142
7
+ - Add ActiveRecord 8.2 QueryIntent support #146
8
+
4
9
  1.2.0 (2025-12-01)
5
10
 
6
11
  - ActiveRecord 8.1 support #143
@@ -98,7 +98,7 @@ class ActiveRecord::ConnectionAdapters::NullDBAdapter < ActiveRecord::Connection
98
98
  end
99
99
 
100
100
  # Rails 6.1+
101
- if ActiveRecord::VERSION::MAJOR >= 7 || (ActiveRecord::VERSION::MAJOR >= 6 and ActiveRecord::VERSION::MINOR > 0)
101
+ if ActiveRecord.version >= Gem::Version.new('6.1.a')
102
102
  def remove_index(table_name, column_name = nil, **options )
103
103
  index_name = index_name_for_remove(table_name, column_name, options)
104
104
  index = @indexes[table_name].reject! { |index| index.name == index_name }
@@ -269,9 +269,23 @@ class ActiveRecord::ConnectionAdapters::NullDBAdapter < ActiveRecord::Connection
269
269
  end
270
270
 
271
271
  ### Rails 8.0+ ###
272
- def perform_query(raw_connection, statement, binds, type_casted_binds, prepare:, notification_payload:, batch:)
273
- self.execution_log << Statement.new(entry_point, statement)
274
- NullObject.new
272
+ # Rails 8.2+ uses QueryIntent object, earlier versions use individual arguments
273
+ # https://github.com/rails/rails/pull/55897
274
+ if defined?(ActiveRecord::ConnectionAdapters::QueryIntent)
275
+ def perform_query(raw_connection, intent)
276
+ self.execution_log << Statement.new(entry_point, intent.processed_sql)
277
+ ActiveRecord::Result.empty
278
+ end
279
+
280
+ def cast_result(raw_result)
281
+ # NullDB returns ActiveRecord::Result directly, no casting needed
282
+ raw_result
283
+ end
284
+ else
285
+ def perform_query(raw_connection, statement, binds, type_casted_binds, prepare:, notification_payload:, batch:)
286
+ self.execution_log << Statement.new(entry_point, statement)
287
+ NullObject.new
288
+ end
275
289
  end
276
290
 
277
291
  def affected_rows(raw_result)
@@ -365,7 +379,7 @@ class ActiveRecord::ConnectionAdapters::NullDBAdapter < ActiveRecord::Connection
365
379
  def default_column_arguments(col_def)
366
380
  # ActiveRecord 8.1+ expects: name, cast_type, default, sql_type_metadata, null
367
381
  # Earlier versions expect: name, default, sql_type_metadata, null
368
- if ::ActiveRecord::VERSION::MAJOR >= 8 && ::ActiveRecord::VERSION::MINOR >= 1
382
+ if ::ActiveRecord.version >= Gem::Version.new('8.1.a')
369
383
  cast_type = ActiveRecord::ConnectionAdapters::AbstractAdapter::TYPE_MAP.lookup(col_def.type.to_s)
370
384
  sql_type_meta = sql_type_definition(col_def)
371
385
 
@@ -14,8 +14,9 @@ class ActiveRecord::ConnectionAdapters::NullDBAdapter
14
14
  alias_method :hstore, :json
15
15
 
16
16
  def unique_constraint(*args, **kwargs, &block); end
17
+ def exclusion_constraint(*args); end
17
18
 
18
- if ::ActiveRecord::VERSION::MAJOR >= 7 && ::ActiveRecord::VERSION::MINOR >= 1
19
+ if ::ActiveRecord.version >= Gem::Version.new('7.1.a')
19
20
  # Avoid check for option validity
20
21
  def create_column_definition(name, type, options)
21
22
  ActiveRecord::ConnectionAdapters::ColumnDefinition.new(name, type, options)
@@ -1,3 +1,3 @@
1
1
  module NullDB
2
- VERSION = "1.2.0"
2
+ VERSION = "1.2.1"
3
3
  end
data/spec/nulldb_spec.rb CHANGED
@@ -127,7 +127,7 @@ describe "NullDB" do
127
127
  # In ActiveRecord 8.1+, immutable default values are type-casted by the Column class
128
128
  # For boolean columns for example, "true" is deserialized to true
129
129
  # https://github.com/rails/rails/commit/205cdd5
130
- if ActiveRecord::VERSION::MAJOR >= 8 && ActiveRecord::VERSION::MINOR >= 1
130
+ if ::ActiveRecord.version >= Gem::Version.new('8.1.a')
131
131
  it "should deserialize immutable default values" do
132
132
  expect(Employee.columns_hash['active'].default).to eq true
133
133
  end
@@ -203,9 +203,9 @@ describe "NullDB" do
203
203
  expect( Employee.connection.tables ).to include "schema_info"
204
204
  end
205
205
 
206
- it "should return an empty array from #select" do
206
+ it "should return an empty result from #select" do
207
207
  result = Employee.connection.select_all("who cares", "blah")
208
- expect( result ).to eq []
208
+ expect( result.to_a ).to eq []
209
209
  end
210
210
 
211
211
  it "should provide a way to set log checkpoints" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-nulldb-adapter
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Avdi Grimm
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2025-12-01 00:00:00.000000000 Z
13
+ date: 2025-12-03 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activerecord