elasticsearch_record 1.5.1 → 1.5.3
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 +4 -4
- data/README.md +2 -0
- data/docs/CHANGELOG.md +7 -0
- data/docs/CODE_OF_CONDUCT.md +1 -1
- data/lib/arel/visitors/elasticsearch_query.rb +9 -7
- data/lib/arel/visitors/elasticsearch_schema.rb +1 -2
- data/lib/elasticsearch_record/gem_version.rb +1 -1
- data/lib/elasticsearch_record/persistence.rb +5 -9
- data/lib/elasticsearch_record/relation/query_methods.rb +17 -18
- data/lib/elasticsearch_record/relation/value_methods.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 238cf0f5e82cb385fc6d0f4e7f0416192f1cf65134b9726de16149be5fe6dc6b
|
4
|
+
data.tar.gz: 002b7d91869f2c0a9f03729c9c2c0db3719abfa9d523925cfeaf5bacf101e563
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b58fc1dbdd310c1e5c8c47bb54398a4300042c063afd6a49543a5c6b2a270f2ffe7fb168b357ff1da5cb738ab602550bbf8a1297d4464089c5c0d8809a4e3a8c
|
7
|
+
data.tar.gz: 10be3f8fa2ea798bf58f2187ee7ea23099545ddad32036642e3b16d5e48cde7ccbabaff2bc68bc0baa2c71c41409de14abebedd11d6b0bcbe026c0e8200f0db2
|
data/README.md
CHANGED
@@ -337,6 +337,8 @@ SearchUser.where(name: 'Peter').limit(nil)
|
|
337
337
|
# returns up to 10_000 items ...
|
338
338
|
# => [...]
|
339
339
|
|
340
|
+
# hint: setting the 'max_result_window' can also be done by providing '__max__' wto the limit method: SearchUser.limit('__max__')
|
341
|
+
|
340
342
|
# hint: if you want more than 10_000 use the +#pit_results+ method!
|
341
343
|
```
|
342
344
|
|
data/docs/CHANGELOG.md
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
# ElasticsearchRecord - CHANGELOG
|
2
2
|
|
3
|
+
## [1.5.3] - 2023-07-14
|
4
|
+
* [fix] `ElasticsearchRecord::Relation#where!` on nested, provided `:none` key
|
5
|
+
* [ref] minor code tweaks and comment updates
|
6
|
+
|
7
|
+
## [1.5.2] - 2023-07-12
|
8
|
+
* [fix] `ElasticsearchRecord::Relation#limit` setter method `limit_value=` to work with **delegate_query_nil_limit?**
|
9
|
+
|
3
10
|
## [1.5.1] - 2023-07-11
|
4
11
|
* [fix] `ElasticsearchRecord::ModelApi` 'drop!' & 'truncate!' methods to support correct parameter 'confirm'
|
5
12
|
* [ref] improved yard documentation
|
data/docs/CODE_OF_CONDUCT.md
CHANGED
@@ -39,7 +39,7 @@ This Code of Conduct applies within all community spaces, and also applies when
|
|
39
39
|
|
40
40
|
## Enforcement
|
41
41
|
|
42
|
-
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at
|
42
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at info@ruby-smart.org. All complaints will be reviewed and investigated promptly and fairly.
|
43
43
|
|
44
44
|
All community leaders are obligated to respect the privacy and security of the reporter of any incident.
|
45
45
|
|
@@ -138,12 +138,11 @@ module Arel # :nodoc: all
|
|
138
138
|
|
139
139
|
# CUSTOM node by elasticsearch_record
|
140
140
|
def visit_Query(o)
|
141
|
-
#
|
142
|
-
# in
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
kind ||= o.kind.present? ? visit(o.kind.expr) : nil
|
141
|
+
# resolves the query kind.
|
142
|
+
# PLEASE NOTE: in some cases there is no kind, but an existing +where+ conditions.
|
143
|
+
# This will then be treat as +:bool+.
|
144
|
+
kind = o.kind.present? ? visit(o.kind.expr).presence : nil
|
145
|
+
kind ||= :bool if o.wheres.present?
|
147
146
|
|
148
147
|
# check for existing kind - we cannot create a node if we don't have any kind
|
149
148
|
return unless kind
|
@@ -423,6 +422,7 @@ module Arel # :nodoc: all
|
|
423
422
|
o
|
424
423
|
end
|
425
424
|
|
425
|
+
# alias for RAW returns
|
426
426
|
alias :visit_Integer :visit_Struct_Raw
|
427
427
|
alias :visit_Symbol :visit_Struct_Raw
|
428
428
|
alias :visit_Hash :visit_Struct_Raw
|
@@ -430,7 +430,6 @@ module Arel # :nodoc: all
|
|
430
430
|
alias :visit_String :visit_Struct_Raw
|
431
431
|
alias :visit_Arel_Nodes_SqlLiteral :visit_Struct_Raw
|
432
432
|
|
433
|
-
|
434
433
|
# used by insert / update statements.
|
435
434
|
# does not claim / assign any values!
|
436
435
|
# returns a Hash of key => value pairs
|
@@ -453,6 +452,7 @@ module Arel # :nodoc: all
|
|
453
452
|
o.name
|
454
453
|
end
|
455
454
|
|
455
|
+
# alias for ATTRIBUTE returns
|
456
456
|
alias :visit_Arel_Attributes_Attribute :visit_Struct_Attribute
|
457
457
|
alias :visit_Arel_Nodes_UnqualifiedColumn :visit_Struct_Attribute
|
458
458
|
alias :visit_ActiveModel_Attribute_FromUser :visit_Struct_Attribute
|
@@ -473,6 +473,7 @@ module Arel # :nodoc: all
|
|
473
473
|
o.value
|
474
474
|
end
|
475
475
|
|
476
|
+
# alias for BIND returns
|
476
477
|
alias :visit_ActiveModel_Attribute :visit_Struct_BindValue
|
477
478
|
alias :visit_ActiveRecord_Relation_QueryAttribute :visit_Struct_BindValue
|
478
479
|
|
@@ -484,6 +485,7 @@ module Arel # :nodoc: all
|
|
484
485
|
collect(o)
|
485
486
|
end
|
486
487
|
|
488
|
+
# alias for ARRAY returns
|
487
489
|
alias :visit_Set :visit_Array
|
488
490
|
end
|
489
491
|
end
|
@@ -89,8 +89,7 @@ module Arel # :nodoc: all
|
|
89
89
|
# prepare query
|
90
90
|
claim(:type, ::ElasticsearchRecord::Query::TYPE_INDEX_UPDATE_SETTING)
|
91
91
|
|
92
|
-
#
|
93
|
-
# todo: refactor this in future versions
|
92
|
+
# overcomplicated blocks to assign a hash of settings directly to the body
|
94
93
|
assign(:__query__, {}) do
|
95
94
|
assign(:body, {}) do
|
96
95
|
resolve(o.items, :visit_TableSettingDefinition)
|
@@ -61,21 +61,17 @@ module ElasticsearchRecord
|
|
61
61
|
|
62
62
|
private
|
63
63
|
|
64
|
-
# WARNING: BETA!!!
|
65
64
|
# Resolves the +auto_increment+ status from the tables +_meta+ attributes.
|
66
65
|
def _insert_with_auto_increment(values)
|
67
|
-
# check, if the primary_key's
|
68
|
-
# so, no need to resolve a +auto_increment+ value, but provide
|
69
|
-
if values[self.primary_key].present?
|
70
|
-
# resolve id from values
|
71
|
-
id = values[self.primary_key]
|
72
|
-
|
66
|
+
# check, if the primary_key's value is provided.
|
67
|
+
# so, no need to resolve a +auto_increment+ value, but provide the id directly
|
68
|
+
if (id = values[self.primary_key]).present?
|
73
69
|
yield({id: id})
|
74
70
|
elsif auto_increment?
|
75
71
|
ids = [
|
76
|
-
#
|
72
|
+
# try to resolve the current-auto-increment value from the tables meta
|
77
73
|
connection.table_metas(self.table_name).dig('auto_increment').to_i + 1,
|
78
|
-
# for secure reasons
|
74
|
+
# for secure reasons: also resolve the current maximum value for the primary key
|
79
75
|
self.unscoped.all.maximum(self.primary_key).to_i + 1
|
80
76
|
]
|
81
77
|
|
@@ -184,35 +184,36 @@ module ElasticsearchRecord
|
|
184
184
|
|
185
185
|
# creates a condition on the relation.
|
186
186
|
# There are several possibilities to call this method.
|
187
|
+
#
|
187
188
|
# @example
|
188
189
|
# # create a simple 'term' condition on the query[:filter] param
|
189
|
-
#
|
190
|
-
#
|
190
|
+
# where({name: 'hans'})
|
191
|
+
# #> query[:filter] << { term: { name: 'hans' } }
|
191
192
|
#
|
192
193
|
# # create a simple 'terms' condition on the query[:filter] param
|
193
|
-
#
|
194
|
-
#
|
194
|
+
# where({name: ['hans','peter']})
|
195
|
+
# #> query[:filter] << { terms: { name: ['hans','peter'] } }
|
195
196
|
#
|
196
|
-
#
|
197
|
-
#
|
197
|
+
# where(:must_not, term: {name: 'horst'})
|
198
|
+
# where(:query_string, "(new york OR dublin)", fields: ['name','description'])
|
198
199
|
#
|
199
200
|
# # nested array
|
200
201
|
# where([ [:filter, {...}], [:must_not, {...}]])
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
end
|
206
|
-
|
202
|
+
#
|
203
|
+
# # invalidate query
|
204
|
+
# where(:none)
|
205
|
+
#
|
207
206
|
def where!(opts, *rest)
|
208
207
|
# :nodoc:
|
209
208
|
case opts
|
210
|
-
# check the first provided parameter +opts+ and validate, if this is an alias for "must, must_not, should or filter"
|
211
|
-
# if true, we expect the rest[0] to be a hash.
|
212
|
-
# For this correlation we forward this as RAW-data without check & manipulation
|
213
209
|
when Symbol
|
214
210
|
case opts
|
211
|
+
when :none
|
212
|
+
none!
|
215
213
|
when :filter, :must, :must_not, :should
|
214
|
+
# check the first provided parameter +opts+ and validate, if this is an alias for "must, must_not, should or filter".
|
215
|
+
# if true, we expect the rest[0] to be a hash.
|
216
|
+
# For this correlation we forward this as RAW-data without check & manipulation
|
216
217
|
send("#{opts}!", *rest)
|
217
218
|
else
|
218
219
|
raise ArgumentError, "Unsupported prefix type '#{opts}'. Allowed types are: :filter, :must, :must_not, :should"
|
@@ -220,9 +221,7 @@ module ElasticsearchRecord
|
|
220
221
|
when Array
|
221
222
|
# check if this is a nested array of multiple [<kind>,<data>]
|
222
223
|
if opts[0].is_a?(Array)
|
223
|
-
opts.each { |item|
|
224
|
-
where!(*item)
|
225
|
-
}
|
224
|
+
opts.each { |item| where!(*item) }
|
226
225
|
else
|
227
226
|
where!(*opts, *rest)
|
228
227
|
end
|
@@ -44,11 +44,11 @@ module ElasticsearchRecord
|
|
44
44
|
end
|
45
45
|
|
46
46
|
# overwrite the limit_value setter, to provide a special behaviour of auto-setting the +max_result_window+.
|
47
|
-
def
|
47
|
+
def limit_value=(limit)
|
48
48
|
if limit == '__max__' || (limit.nil? && delegate_query_nil_limit?)
|
49
49
|
super(max_result_window)
|
50
50
|
else
|
51
|
-
super
|
51
|
+
super(limit)
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: elasticsearch_record
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.
|
4
|
+
version: 1.5.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tobias Gonsior
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-07-
|
11
|
+
date: 2023-07-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|