elasticsearch_record 5.0.0 → 5.0.2

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: a4f850e5600056256b188825cc8ca7067b4928014a09b05bb18ed37fb648478f
4
- data.tar.gz: 19cec69e3a5a67752f8c94a2b22968e29dd5edf7166e4e205903164387e8606f
3
+ metadata.gz: c40dcd47630a8b238e2aea55c4a1fd11996618606267fac0aeb8ff1f6675cbae
4
+ data.tar.gz: 6cf4bbabec3588fe3f65b97f10a7fb98cb79d163db044c845cca15d8b467fe35
5
5
  SHA512:
6
- metadata.gz: 076f2df28822bba0a2148d2e3043cb403cb04d388c5034056eb7e298004694707b2e2b8c003257f8da4dc5d1bea80ae5bce8b851244cd146232b381ecc35543e
7
- data.tar.gz: 91a406efac0912da2f2427120b0cf1fdbf1ae78166b9853c3af6099b6e19fd4aa09aebf962840f01345d4b32a523a1fd74706f827f86b0804a0f8ffef2199392
6
+ metadata.gz: a22d8ee32007b72c6893e0f4a31f7b796f8f231665c7b3f56bb693fbf795e7ff014000105f69fb4c5817e97a985d93061c76c26f76dba877b16c4a5a4f635130
7
+ data.tar.gz: 2de3a166ea5f5c9e06b96c923475d31e2683fc5c4c12d6e696a08f1efda7c4f100b2b1deb08f80fef2acb2787e78a4bb12126aa4ae4aabfec02d68d1c05c3dec
data/docs/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # ElasticsearchRecord - CHANGELOG
2
2
 
3
+ ## [5.0.2] - 2026-09-17
4
+ * [add] `Arel::Visitors::ElasticsearchQuery#visit_Arel_Nodes_Casted` & `#visit_Arel_Nodes_Quoted` - the value nodes `Arel::Attributes::Attribute#eq` & co. build for plain values
5
+ * [add] specs for `SchemaMigration#delete_version` & `#delete_all_versions`
6
+ * [fix] `Arel::Visitors::ElasticsearchQuery#visit_Arel_Nodes_DeleteStatement` compiles a delete on a plain table _(the `ActiveRecord::SchemaMigration#delete_version` shape)_ into a delete-by-query - rolling a migration back removes its version again instead of raising a `NotImplementedError`
7
+
8
+ ## [5.0.1] - 2026-09-16
9
+ * [add] specs for `Elasticsearch::Column` identity, deduplication & YAML round-trip
10
+ * [fix] `Elasticsearch::Column#==`, `#eql?` & `#hash` also compare `virtual`, `fields`, `properties`, `meta` & `enabled` - same-named columns of different indexes no longer share a single deduplicated object
11
+ * [fix] `Elasticsearch::Column#init_with` & `#encode_with` serialize the elasticsearch-specific attributes
12
+
3
13
  ## [5.0.0] - 2026-09-10
4
14
  * [add] **BREAKING**: requires `activerecord ~> 8.1.0`
5
15
  * [add] `Relation::ValueMethods#limit!` - keeps the `'__max__'` & `Float::INFINITY` limits, which rails now casts through `Integer()`
@@ -22,6 +22,53 @@ module ActiveRecord
22
22
  meta? && meta['comment']
23
23
  end
24
24
 
25
+ def init_with(coder)
26
+ @virtual = coder['virtual']
27
+ @fields = coder['fields']
28
+ @properties = coder['properties']
29
+ @meta = coder['meta']
30
+ @enabled = coder['enabled']
31
+ super
32
+ end
33
+
34
+ def encode_with(coder)
35
+ coder['virtual'] = @virtual
36
+ coder['fields'] = @fields
37
+ coder['properties'] = @properties
38
+ coder['meta'] = @meta
39
+ coder['enabled'] = @enabled
40
+ super
41
+ end
42
+
43
+ # ActiveRecord deduplicates columns process-wide through +Deduplicable+, which
44
+ # keys its registry by +#hash+ & +#eql?+ - so columns that only differ in the
45
+ # elasticsearch-specific attributes must NOT compare equal.
46
+ # Without this a +keyword+ column with a +analyzed+ sub-field would share the
47
+ # object of a same-named +keyword+ column without any fields - whichever index
48
+ # loaded its schema first wins & the other one silently gains or loses its
49
+ # +fields+ (breaking e.g. +where('code.analyzed' => ...)+).
50
+ def ==(other)
51
+ other.is_a?(Column) &&
52
+ super &&
53
+ virtual == other.virtual &&
54
+ fields == other.fields &&
55
+ properties == other.properties &&
56
+ meta == other.meta &&
57
+ enabled == other.enabled
58
+ end
59
+
60
+ alias :eql? :==
61
+
62
+ def hash
63
+ Column.hash ^
64
+ super.hash ^
65
+ virtual.hash ^
66
+ fields.hash ^
67
+ properties.hash ^
68
+ meta.hash ^
69
+ enabled.hash
70
+ end
71
+
25
72
  # returns true if this column is enabled (= searchable by queries)
26
73
  # @return [Boolean]
27
74
  def enabled?
@@ -63,9 +63,16 @@ module Arel # :nodoc: all
63
63
  end
64
64
 
65
65
  # DELETE (by query - not a single record...)
66
+ #
67
+ # A plain +Arel::Table+ relation is the shape of a +DeleteManager+ built straight on a table -
68
+ # +ActiveRecord::SchemaMigration#delete_version+ does exactly that to remove a rolled back version.
69
+ # Elasticsearch has no "delete by column value" apart from a delete-by-query, and a single record
70
+ # never reaches Arel (see @ ElasticsearchRecord::ModelApi#delete), so the conditions of such a
71
+ # statement are compiled into a delete-by-query on that index - the same as a relation's +delete_all+.
72
+ # Without any condition the statement would wipe the whole index, which is not what a delete means.
66
73
  def visit_Arel_Nodes_DeleteStatement(o)
67
- # switch between updating a single Record or multiple by query
68
- if o.relation.is_a?(::Arel::Table)
74
+ # a plain table without conditions is neither a single record nor a query
75
+ if o.relation.is_a?(::Arel::Table) && o.wheres.blank?
69
76
  raise NotImplementedError, "if you've made it this far, something went wrong ..."
70
77
  end
71
78
 
@@ -463,6 +470,16 @@ module Arel # :nodoc: all
463
470
  alias :visit_String :visit_Struct_Raw
464
471
  alias :visit_Arel_Nodes_SqlLiteral :visit_Struct_Raw
465
472
 
473
+ # CASTED / QUOTED values - the nodes +Arel::Attributes::Attribute#eq+ & co. wrap a plain value in
474
+ # (see @ Arel::Nodes.build_quoted). Returns the database value: the attribute of a model table
475
+ # type casts it, the attribute of a plain +Arel::Table+ returns the value unchanged.
476
+ def visit_Arel_Nodes_Casted(o)
477
+ o.value_for_database
478
+ end
479
+
480
+ # alias for QUOTED returns
481
+ alias :visit_Arel_Nodes_Quoted :visit_Arel_Nodes_Casted
482
+
466
483
  # used by insert / update statements.
467
484
  # does not claim / assign any values!
468
485
  # returns a Hash of key => value pairs
@@ -9,7 +9,7 @@ module ElasticsearchRecord
9
9
  module VERSION
10
10
  MAJOR = 5
11
11
  MINOR = 0
12
- TINY = 0
12
+ TINY = 2
13
13
  PRE = nil
14
14
 
15
15
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elasticsearch_record
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.0
4
+ version: 5.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tobias Gonsior