elasticsearch_record 1.2.1 → 1.2.3
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cdb71bb8689c67cd7a2ef1add3b7ad0ab6710cbb5833313cb3f474267c39e43e
|
4
|
+
data.tar.gz: 06ec37ac16f5adb110da8ffa08c9c44fc20993be3db12bf8033315cfa9611fc3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 929f5df6456203e7bce466d62836805bb9a75ff5a89856c75cd1ba187a95e05f51aa3ad676c3058d7ad95d1295db1422571964240182000bef59a8cdb95181bc
|
7
|
+
data.tar.gz: 7f785864f92bc6f3243ea081236327ff7c600833cdf74a11d59239f31551d928dc7b8bb1b4952ec38aadaa8d0174ac2a7ceeebae100a247c3534ef4c1609e484
|
data/Gemfile.lock
CHANGED
data/docs/CHANGELOG.md
CHANGED
@@ -1,5 +1,14 @@
|
|
1
1
|
# ElasticsearchRecord - CHANGELOG
|
2
2
|
|
3
|
+
## [1.2.3] - 2022-12-12
|
4
|
+
* [fix] `change_table` 'if_exists: true' returns at the wrong state
|
5
|
+
|
6
|
+
## [1.2.2] - 2022-12-12
|
7
|
+
* [add] `:if_exists` option for `change_table`
|
8
|
+
* [fix] executing `_compute_table_name` irregular on some schema methods and some not - not only executes on `create_table` and `change_table`
|
9
|
+
* [ref] private `_compute_table_name` method to public `compute_table_name`
|
10
|
+
* [ref] drop `_compute_table_name` on methods: open_table, close_table, truncate_table, drop_table, block_table, unblock_table & clone_table
|
11
|
+
|
3
12
|
## [1.2.1] - 2022-12-12
|
4
13
|
* [add] `ActiveRecord::ConnectionAdapters::Elasticsearch::SchemaStatements#access_id_fielddata?` which checks the clusters setting 'indices.id_field_data.enabled' to determinate if a general sorting on the +_id+-field is possible or not.
|
5
14
|
* [add] `ElasticsearchRecord::Relation#ordered_relation` which overwrites the original method to check against the `#access_id_fielddata?` method
|
@@ -38,9 +38,6 @@ module ActiveRecord
|
|
38
38
|
# @param [String] table_name
|
39
39
|
# @return [Boolean] acknowledged status
|
40
40
|
def open_table(table_name)
|
41
|
-
# IMPORTANT: compute will add possible configured prefix & suffix
|
42
|
-
table_name = _compute_table_name(table_name)
|
43
|
-
|
44
41
|
schema_cache.clear_data_source_cache!(table_name)
|
45
42
|
api(:indices, :open, { index: table_name }, 'OPEN TABLE').dig('acknowledged')
|
46
43
|
end
|
@@ -59,9 +56,6 @@ module ActiveRecord
|
|
59
56
|
# @param [String] table_name
|
60
57
|
# @return [Boolean] acknowledged status
|
61
58
|
def close_table(table_name)
|
62
|
-
# IMPORTANT: compute will add possible configured prefix & suffix
|
63
|
-
table_name = _compute_table_name(table_name)
|
64
|
-
|
65
59
|
schema_cache.clear_data_source_cache!(table_name)
|
66
60
|
api(:indices, :close, { index: table_name }, 'CLOSE TABLE').dig('acknowledged')
|
67
61
|
end
|
@@ -84,9 +78,6 @@ module ActiveRecord
|
|
84
78
|
# @param [String] table_name
|
85
79
|
# @return [Boolean] acknowledged status
|
86
80
|
def truncate_table(table_name)
|
87
|
-
# IMPORTANT: compute will add possible configured prefix & suffix
|
88
|
-
table_name = _compute_table_name(table_name)
|
89
|
-
|
90
81
|
# force: automatically drops an existing index
|
91
82
|
create_table(table_name, force: true, **table_schema(table_name))
|
92
83
|
end
|
@@ -111,9 +102,6 @@ module ActiveRecord
|
|
111
102
|
# @param [Boolean] if_exists
|
112
103
|
# @return [Array] acknowledged status
|
113
104
|
def drop_table(table_name, if_exists: false, **)
|
114
|
-
# IMPORTANT: compute will add possible configured prefix & suffix
|
115
|
-
table_name = _compute_table_name(table_name)
|
116
|
-
|
117
105
|
schema_cache.clear_data_source_cache!(table_name)
|
118
106
|
api(:indices, :delete, { index: table_name, ignore: (if_exists ? 404 : nil) }, 'DROP TABLE').dig('acknowledged')
|
119
107
|
end
|
@@ -123,9 +111,6 @@ module ActiveRecord
|
|
123
111
|
# @param [Symbol] block_name The block to add (one of :read, :write, :read_only or :metadata)
|
124
112
|
# @return [Boolean] acknowledged status
|
125
113
|
def block_table(table_name, block_name = :write)
|
126
|
-
# IMPORTANT: compute will add possible configured prefix & suffix
|
127
|
-
table_name = _compute_table_name(table_name)
|
128
|
-
|
129
114
|
api(:indices, :add_block, { index: table_name, block: block_name }, "BLOCK #{block_name.to_s.upcase} TABLE").dig('acknowledged')
|
130
115
|
end
|
131
116
|
|
@@ -135,9 +120,6 @@ module ActiveRecord
|
|
135
120
|
# @param [Symbol] block_name The block to add (one of :read, :write, :read_only or :metadata)
|
136
121
|
# @return [Boolean] acknowledged status
|
137
122
|
def unblock_table(table_name, block_name = nil)
|
138
|
-
# IMPORTANT: compute will add possible configured prefix & suffix
|
139
|
-
table_name = _compute_table_name(table_name)
|
140
|
-
|
141
123
|
if block_name.nil?
|
142
124
|
change_table(table_name) do |t|
|
143
125
|
t.change_setting('index.blocks.read', false)
|
@@ -157,10 +139,6 @@ module ActiveRecord
|
|
157
139
|
# @param [Hash] options
|
158
140
|
# @param [Proc] block
|
159
141
|
def clone_table(table_name, target_name, **options, &block)
|
160
|
-
# IMPORTANT: compute will add possible configured prefix & suffix
|
161
|
-
table_name = _compute_table_name(table_name)
|
162
|
-
target_name = _compute_table_name(target_name)
|
163
|
-
|
164
142
|
# create new definition
|
165
143
|
definition = clone_table_definition(table_name, target_name, **extract_table_options!(options), &block)
|
166
144
|
|
@@ -191,7 +169,7 @@ module ActiveRecord
|
|
191
169
|
# @return [Boolean] acknowledged status
|
192
170
|
def create_table(table_name, force: false, copy_from: nil, if_not_exists: false, **options)
|
193
171
|
# IMPORTANT: compute will add possible configured prefix & suffix
|
194
|
-
table_name =
|
172
|
+
table_name = compute_table_name(table_name)
|
195
173
|
|
196
174
|
return if if_not_exists && table_exists?(table_name)
|
197
175
|
|
@@ -226,9 +204,11 @@ module ActiveRecord
|
|
226
204
|
# t.mapping :name, :string
|
227
205
|
# # Other column alterations here
|
228
206
|
# end
|
229
|
-
def change_table(table_name, **options)
|
207
|
+
def change_table(table_name, if_exists: false, **options)
|
230
208
|
# IMPORTANT: compute will add possible configured prefix & suffix
|
231
|
-
table_name =
|
209
|
+
table_name = compute_table_name(table_name)
|
210
|
+
|
211
|
+
return if if_exists && !table_exists?(table_name)
|
232
212
|
|
233
213
|
definition = update_table_definition(table_name, self, **options)
|
234
214
|
|
@@ -303,17 +283,22 @@ module ActiveRecord
|
|
303
283
|
_exec_change_table_with(:delete_alias, table_name, name, **options, &block)
|
304
284
|
end
|
305
285
|
|
306
|
-
|
307
|
-
|
308
|
-
|
286
|
+
# computes a provided +table_name+ with optionally configured +table_name_prefix+ & +table_name_suffix+.
|
287
|
+
# @param [String] table_name
|
288
|
+
# @return [String]
|
289
|
+
def compute_table_name(table_name)
|
290
|
+
table_name = table_name.to_s
|
291
|
+
|
309
292
|
# HINT: +"" creates a new +unfrozen+ string!
|
310
293
|
str = +""
|
311
|
-
str << table_name_prefix unless table_name.
|
294
|
+
str << table_name_prefix unless table_name.start_with?(table_name_prefix)
|
312
295
|
str << table_name
|
313
|
-
str << table_name_suffix unless table_name.
|
296
|
+
str << table_name_suffix unless table_name.end_with?(table_name_suffix)
|
314
297
|
str
|
315
298
|
end
|
316
299
|
|
300
|
+
private
|
301
|
+
|
317
302
|
def _exec_change_table_with(method, table_name, *args, **kwargs, &block)
|
318
303
|
change_table(table_name) do |t|
|
319
304
|
t.send(method, *args, **kwargs, &block)
|