mobility 0.7.6 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/CHANGELOG.md +14 -3
- data/Gemfile.lock +57 -0
- data/README.md +15 -4
- data/lib/mobility.rb +17 -1
- data/lib/mobility/active_record/uniqueness_validator.rb +1 -1
- data/lib/mobility/arel/nodes.rb +0 -3
- data/lib/mobility/arel/nodes/pg_ops.rb +0 -4
- data/lib/mobility/attributes.rb +42 -25
- data/lib/mobility/backends/active_record.rb +2 -2
- data/lib/mobility/backends/active_record/column.rb +2 -2
- data/lib/mobility/backends/active_record/key_value.rb +6 -9
- data/lib/mobility/backends/active_record/table.rb +6 -7
- data/lib/mobility/backends/column.rb +2 -2
- data/lib/mobility/backends/key_value.rb +5 -0
- data/lib/mobility/backends/sequel.rb +24 -11
- data/lib/mobility/backends/sequel/column.rb +4 -3
- data/lib/mobility/backends/sequel/container.rb +21 -12
- data/lib/mobility/backends/sequel/hstore.rb +11 -3
- data/lib/mobility/backends/sequel/json.rb +11 -3
- data/lib/mobility/backends/sequel/jsonb.rb +35 -3
- data/lib/mobility/backends/sequel/key_value.rb +97 -17
- data/lib/mobility/backends/sequel/serialized.rb +5 -4
- data/lib/mobility/backends/sequel/table.rb +95 -26
- data/lib/mobility/backends/table.rb +4 -0
- data/lib/mobility/configuration.rb +1 -1
- data/lib/mobility/plugins/active_record/query.rb +52 -26
- data/lib/mobility/plugins/locale_accessors.rb +3 -2
- data/lib/mobility/plugins/query.rb +3 -0
- data/lib/mobility/plugins/sequel/query.rb +140 -0
- data/lib/mobility/sequel.rb +0 -14
- data/lib/mobility/sequel/sql.rb +16 -0
- data/lib/mobility/version.rb +1 -1
- data/lib/rails/generators/mobility/templates/column_translations.rb +1 -1
- data/lib/rails/generators/mobility/templates/initializer.rb +3 -2
- data/lib/rails/generators/mobility/translations_generator.rb +1 -1
- metadata +27 -46
- metadata.gz.sig +1 -1
- data/lib/mobility/backends/active_record/query_methods.rb +0 -50
- data/lib/mobility/backends/sequel/column/query_methods.rb +0 -29
- data/lib/mobility/backends/sequel/container/json_query_methods.rb +0 -41
- data/lib/mobility/backends/sequel/container/jsonb_query_methods.rb +0 -41
- data/lib/mobility/backends/sequel/hstore/query_methods.rb +0 -34
- data/lib/mobility/backends/sequel/json/query_methods.rb +0 -34
- data/lib/mobility/backends/sequel/jsonb/query_methods.rb +0 -34
- data/lib/mobility/backends/sequel/key_value/query_methods.rb +0 -58
- data/lib/mobility/backends/sequel/pg_query_methods.rb +0 -114
- data/lib/mobility/backends/sequel/query_methods.rb +0 -36
- data/lib/mobility/backends/sequel/serialized/query_methods.rb +0 -22
- data/lib/mobility/backends/sequel/table/query_methods.rb +0 -58
data/lib/mobility/sequel.rb
CHANGED
@@ -5,19 +5,5 @@ Module loading Sequel-specific classes for Mobility models.
|
|
5
5
|
|
6
6
|
=end
|
7
7
|
module Sequel
|
8
|
-
def self.included(model_class)
|
9
|
-
model_class.extend DatasetMethod.new(Mobility.query_method)
|
10
|
-
end
|
11
|
-
|
12
|
-
class DatasetMethod < Module
|
13
|
-
def initialize(query_method)
|
14
|
-
module_eval <<-EOM, __FILE__, __LINE__ + 1
|
15
|
-
def #{query_method}
|
16
|
-
dataset
|
17
|
-
end
|
18
|
-
EOM
|
19
|
-
end
|
20
|
-
end
|
21
|
-
private_constant :DatasetMethod
|
22
8
|
end
|
23
9
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Mobility
|
2
|
+
module Sequel
|
3
|
+
module SQL
|
4
|
+
class QualifiedIdentifier < ::Sequel::SQL::QualifiedIdentifier
|
5
|
+
attr_reader :backend_class, :locale, :attribute_name
|
6
|
+
|
7
|
+
def initialize(table, column, locale, backend_class, attribute_name: nil)
|
8
|
+
@backend_class = backend_class
|
9
|
+
@locale = locale
|
10
|
+
@attribute_name = attribute_name || column
|
11
|
+
super(table, column)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/lib/mobility/version.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
class <%= migration_class_name %> < <%= activerecord_migration_class %>
|
2
2
|
def change
|
3
3
|
<% attributes.each do |attribute| -%>
|
4
|
-
<%
|
4
|
+
<% Mobility.available_locales.each do |locale| -%>
|
5
5
|
<% column_name = Mobility.normalize_locale_accessor(attribute.name, locale) -%>
|
6
6
|
<% if connection.column_exists?(table_name, column_name) -%>
|
7
7
|
<% warn "#{column_name} already exists, skipping." -%>
|
@@ -62,8 +62,9 @@ Mobility.configure do |config|
|
|
62
62
|
# config.default_options[:default] = ...
|
63
63
|
|
64
64
|
# Uncomment to enable locale_accessors by default on models. A true value
|
65
|
-
# will use the locales defined in
|
66
|
-
#
|
65
|
+
# will use the locales defined either in
|
66
|
+
# Rails.application.config.i18n.available_locales or I18n.available_locales.
|
67
|
+
# If you want something else, pass an array of locales instead.
|
67
68
|
#
|
68
69
|
# config.default_options[:locale_accessors] = true
|
69
70
|
|
@@ -23,7 +23,7 @@ For the +table+ backend, the generator will either create a translation table
|
|
23
23
|
exists.
|
24
24
|
|
25
25
|
For the +column+ backend, the generator will add columns for all locales in
|
26
|
-
+
|
26
|
+
+Mobility.available_locales+. If some columns already exist, they will simply be
|
27
27
|
skipped.
|
28
28
|
|
29
29
|
Other backends are not supported, for obvious reasons:
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mobility
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Salzberg
|
@@ -10,27 +10,32 @@ bindir: exe
|
|
10
10
|
cert_chain:
|
11
11
|
- |
|
12
12
|
-----BEGIN CERTIFICATE-----
|
13
|
-
|
13
|
+
MIIEcDCCAtigAwIBAgIBATANBgkqhkiG9w0BAQsFADA/MQ4wDAYDVQQDDAVjaHJp
|
14
14
|
czEYMBYGCgmSJomT8ixkARkWCGRlamltYXRhMRMwEQYKCZImiZPyLGQBGRYDY29t
|
15
|
-
|
15
|
+
MB4XDTE4MDkxMTA3MTIxOVoXDTE5MDkxMTA3MTIxOVowPzEOMAwGA1UEAwwFY2hy
|
16
16
|
aXMxGDAWBgoJkiaJk/IsZAEZFghkZWppbWF0YTETMBEGCgmSJomT8ixkARkWA2Nv
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
17
|
+
bTCCAaIwDQYJKoZIhvcNAQEBBQADggGPADCCAYoCggGBANhITJvJIMVXZJm7M4ci
|
18
|
+
SEY+ou/ugebCkfEZ7kJ+hKoprQixv/ox9WfFo8Mfdtw5XUHkmDate3yQ//yJ319Q
|
19
|
+
VxhM9/DDGffMJIQ0R5MRHF0wplKwlJfuoLqDRashBWqMaTzQZIGmUaYLFlLsbGhG
|
20
|
+
pYui/LixfEoGM6BJPJQa22gCTayLoOedj0UZRY60o50a7HquAl175DbC/pcvL/2u
|
21
|
+
sWfVUbY4ml+E/Y8ImSzzQ9281sf/qKAccbM4tOTRXCzf45aBpkfpgoNez7QUcO75
|
22
|
+
u84QlyBfrSjF3If7/i0N8XQoTm59XJqeoyoRUrs/9onzEK8FWcwRpjc2jnwwrS3G
|
23
|
+
FOS69dScNMJRhF/WCD0CiFr/x9TbcddANAv1dTo09ZIa9F4qYIXmrTbRVxedYp4J
|
24
|
+
53yhhrmYKgPIIFgRwpZ4PLopBzcoqDQEDN2S7bF0uQKZEOFWmxFW0gSkais/kUQs
|
25
|
+
+KBOLR+hZE+XY9e9AF5sPFPI1cCVlzWycYYyj+q3esZNMQIDAQABo3cwdTAJBgNV
|
26
|
+
HRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNVHQ4EFgQUnl91HnXC+LP5WR3+xHTBPFpe
|
27
|
+
7BwwHQYDVR0RBBYwFIESY2hyaXNAZGVqaW1hdGEuY29tMB0GA1UdEgQWMBSBEmNo
|
28
|
+
cmlzQGRlamltYXRhLmNvbTANBgkqhkiG9w0BAQsFAAOCAYEAbRUo4qXHMGMniB7t
|
29
|
+
2TGnmV+pOhih+gMPUN15/fQNLITc2GCgNYeZNWLdhXvKI15EWD+kyZYuRy9TI7IJ
|
30
|
+
8MJuh7C0llSB0MB8Q83T/V1cyG714fvrove6Ki8RgjQ+JMjN23zleaVIenhJu5mS
|
31
|
+
7Yg4RkKmt3DaYiLP7GCzAaFMUFVhNyEmXVFcuVXgE2FO5SPUABegJS4S8hY/f/Wr
|
32
|
+
nLKv9tCpXO8np++HNp2ryj7Z54/eQ1KaqzodRL31HBuFkpzmm5Y34Hf9faaITeOJ
|
33
|
+
wLSx9yXQpNtMvtxj66ztwWR75HPP2ZsujTtLMxhRO74gADdIujX9FTQHmn3YaJ24
|
34
|
+
8abCZ79sPvLP9FaOM2lLbzA+C/QWSTDAzNtyxS3+hOZsCyjRew8rpmhbGSoiCkJy
|
35
|
+
m46ezJjnr4uXgSNuTs+RdM6DtrKaFG2HuziSP+dzmWqZiUgj1eTACYsPwfF/Z1Z6
|
36
|
+
2DiDkec/SK4qJBMlNYPo/PTZuh5m1jROtf/hyS0VXJmm+uWc
|
32
37
|
-----END CERTIFICATE-----
|
33
|
-
date: 2018-
|
38
|
+
date: 2018-09-11 00:00:00.000000000 Z
|
34
39
|
dependencies:
|
35
40
|
- !ruby/object:Gem::Dependency
|
36
41
|
name: request_store
|
@@ -66,20 +71,6 @@ dependencies:
|
|
66
71
|
- - "<"
|
67
72
|
- !ruby/object:Gem::Version
|
68
73
|
version: '1.1'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: bundler
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - "~>"
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '1.12'
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - "~>"
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '1.12'
|
83
74
|
- !ruby/object:Gem::Dependency
|
84
75
|
name: database_cleaner
|
85
76
|
requirement: !ruby/object:Gem::Requirement
|
@@ -192,7 +183,6 @@ files:
|
|
192
183
|
- lib/mobility/backends/active_record/jsonb.rb
|
193
184
|
- lib/mobility/backends/active_record/key_value.rb
|
194
185
|
- lib/mobility/backends/active_record/pg_hash.rb
|
195
|
-
- lib/mobility/backends/active_record/query_methods.rb
|
196
186
|
- lib/mobility/backends/active_record/serialized.rb
|
197
187
|
- lib/mobility/backends/active_record/table.rb
|
198
188
|
- lib/mobility/backends/column.rb
|
@@ -205,25 +195,14 @@ files:
|
|
205
195
|
- lib/mobility/backends/null.rb
|
206
196
|
- lib/mobility/backends/sequel.rb
|
207
197
|
- lib/mobility/backends/sequel/column.rb
|
208
|
-
- lib/mobility/backends/sequel/column/query_methods.rb
|
209
198
|
- lib/mobility/backends/sequel/container.rb
|
210
|
-
- lib/mobility/backends/sequel/container/json_query_methods.rb
|
211
|
-
- lib/mobility/backends/sequel/container/jsonb_query_methods.rb
|
212
199
|
- lib/mobility/backends/sequel/hstore.rb
|
213
|
-
- lib/mobility/backends/sequel/hstore/query_methods.rb
|
214
200
|
- lib/mobility/backends/sequel/json.rb
|
215
|
-
- lib/mobility/backends/sequel/json/query_methods.rb
|
216
201
|
- lib/mobility/backends/sequel/jsonb.rb
|
217
|
-
- lib/mobility/backends/sequel/jsonb/query_methods.rb
|
218
202
|
- lib/mobility/backends/sequel/key_value.rb
|
219
|
-
- lib/mobility/backends/sequel/key_value/query_methods.rb
|
220
203
|
- lib/mobility/backends/sequel/pg_hash.rb
|
221
|
-
- lib/mobility/backends/sequel/pg_query_methods.rb
|
222
|
-
- lib/mobility/backends/sequel/query_methods.rb
|
223
204
|
- lib/mobility/backends/sequel/serialized.rb
|
224
|
-
- lib/mobility/backends/sequel/serialized/query_methods.rb
|
225
205
|
- lib/mobility/backends/sequel/table.rb
|
226
|
-
- lib/mobility/backends/sequel/table/query_methods.rb
|
227
206
|
- lib/mobility/backends/serialized.rb
|
228
207
|
- lib/mobility/backends/table.rb
|
229
208
|
- lib/mobility/configuration.rb
|
@@ -249,11 +228,13 @@ files:
|
|
249
228
|
- lib/mobility/plugins/query.rb
|
250
229
|
- lib/mobility/plugins/sequel.rb
|
251
230
|
- lib/mobility/plugins/sequel/dirty.rb
|
231
|
+
- lib/mobility/plugins/sequel/query.rb
|
252
232
|
- lib/mobility/sequel.rb
|
253
233
|
- lib/mobility/sequel/backend_resetter.rb
|
254
234
|
- lib/mobility/sequel/column_changes.rb
|
255
235
|
- lib/mobility/sequel/hash_initializer.rb
|
256
236
|
- lib/mobility/sequel/model_translation.rb
|
237
|
+
- lib/mobility/sequel/sql.rb
|
257
238
|
- lib/mobility/sequel/string_translation.rb
|
258
239
|
- lib/mobility/sequel/text_translation.rb
|
259
240
|
- lib/mobility/sequel/translation.rb
|
@@ -286,7 +267,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
286
267
|
requirements:
|
287
268
|
- - ">="
|
288
269
|
- !ruby/object:Gem::Version
|
289
|
-
version: 2.
|
270
|
+
version: 2.3.7
|
290
271
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
291
272
|
requirements:
|
292
273
|
- - ">="
|
metadata.gz.sig
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
�m�y����}P$��@���g����;����e�w��>/�iz��5D�K9+�PT��l^�'ړ��pN��lj�l���w�1rx�yUyV\82|�h9\��-�I�K�ޙf������<�[��X#�Y�3��վ*��YR���_8���|�^��f�5��Ove�\��*�����h�L�;+gV�ԍ+��!���t��t��)����qߛmn<�J:p���j3H�(/3��1�R,i~�y���)�n�\y*����T
|
@@ -1,50 +0,0 @@
|
|
1
|
-
module Mobility
|
2
|
-
module Backends
|
3
|
-
module ActiveRecord
|
4
|
-
=begin
|
5
|
-
|
6
|
-
Defines query method overrides to handle translated attributes for ActiveRecord
|
7
|
-
models. For details see backend-specific subclasses.
|
8
|
-
|
9
|
-
=end
|
10
|
-
class QueryMethods < Module
|
11
|
-
# @param [Array<String>] attributes Translated attributes
|
12
|
-
def initialize(attributes, _)
|
13
|
-
@attributes = attributes
|
14
|
-
|
15
|
-
attributes.each do |attribute|
|
16
|
-
define_method :"find_by_#{attribute}" do |value|
|
17
|
-
find_by(attribute.to_sym => value)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
# @param [ActiveRecord::Relation] relation Relation being extended
|
23
|
-
# @note Only want to define this once, even if multiple QueryMethods
|
24
|
-
# modules are included, so include it here into the singleton class.
|
25
|
-
def extended(relation)
|
26
|
-
relation.singleton_class.include WhereChainable
|
27
|
-
end
|
28
|
-
|
29
|
-
def extract_attributes(opts)
|
30
|
-
opts.is_a?(Hash) && (opts.keys.map(&:to_s) & @attributes).presence
|
31
|
-
end
|
32
|
-
|
33
|
-
def collapse(value)
|
34
|
-
value.is_a?(Array) ? value.uniq : value
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
module WhereChainable
|
39
|
-
def where(opts = :chain, *rest)
|
40
|
-
opts == :chain ? mobility_where_chain.new(spawn) : super
|
41
|
-
end
|
42
|
-
|
43
|
-
def mobility_where_chain
|
44
|
-
@mobility_where_chain ||= Class.new(::ActiveRecord::QueryMethods::WhereChain)
|
45
|
-
end
|
46
|
-
end
|
47
|
-
private_constant :QueryMethods, :WhereChainable
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
require "mobility/backends/sequel/query_methods"
|
3
|
-
|
4
|
-
module Mobility
|
5
|
-
module Backends
|
6
|
-
module Sequel
|
7
|
-
class Column::QueryMethods < QueryMethods
|
8
|
-
def initialize(attributes, _)
|
9
|
-
super
|
10
|
-
q = self
|
11
|
-
|
12
|
-
%w[exclude or where].each do |method_name|
|
13
|
-
define_method method_name do |*conds, &block|
|
14
|
-
if i18n_keys = q.extract_attributes(conds.first)
|
15
|
-
cond = conds.first.dup
|
16
|
-
i18n_keys.each do |attr|
|
17
|
-
cond[Backends::Column.column_name_for(attr)] = q.collapse cond.delete(attr)
|
18
|
-
end
|
19
|
-
super(cond, &block)
|
20
|
-
else
|
21
|
-
super(*conds, &block)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
@@ -1,41 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
require "mobility/backends/sequel/pg_query_methods"
|
3
|
-
require "mobility/backends/sequel/query_methods"
|
4
|
-
|
5
|
-
Sequel.extension :pg_json, :pg_json_ops
|
6
|
-
|
7
|
-
module Mobility
|
8
|
-
module Backends
|
9
|
-
module Sequel
|
10
|
-
class Container::JsonQueryMethods < QueryMethods
|
11
|
-
include PgQueryMethods
|
12
|
-
attr_reader :column_name
|
13
|
-
|
14
|
-
def initialize(attributes, options)
|
15
|
-
super
|
16
|
-
@column_name = options[:column_name]
|
17
|
-
define_query_methods
|
18
|
-
end
|
19
|
-
|
20
|
-
def matches(key, locale)
|
21
|
-
build_op(column_name)[locale].get_text(key.to_s)
|
22
|
-
end
|
23
|
-
|
24
|
-
def exists(key, locale)
|
25
|
-
matches(key, locale) !~ nil
|
26
|
-
end
|
27
|
-
|
28
|
-
def quote(value)
|
29
|
-
value && value.to_s
|
30
|
-
end
|
31
|
-
|
32
|
-
private
|
33
|
-
|
34
|
-
def build_op(key)
|
35
|
-
::Sequel.pg_json_op(key)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
Container.private_constant :JsonQueryMethods
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
@@ -1,41 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
require "mobility/backends/sequel/pg_query_methods"
|
3
|
-
require "mobility/backends/sequel/query_methods"
|
4
|
-
|
5
|
-
Sequel.extension :pg_json, :pg_json_ops
|
6
|
-
|
7
|
-
module Mobility
|
8
|
-
module Backends
|
9
|
-
module Sequel
|
10
|
-
class Container::JsonbQueryMethods < QueryMethods
|
11
|
-
include PgQueryMethods
|
12
|
-
attr_reader :column_name
|
13
|
-
|
14
|
-
def initialize(attributes, options)
|
15
|
-
super
|
16
|
-
@column_name = options[:column_name]
|
17
|
-
define_query_methods
|
18
|
-
end
|
19
|
-
|
20
|
-
def matches(key, locale)
|
21
|
-
build_op(column_name)[locale][key.to_s]
|
22
|
-
end
|
23
|
-
|
24
|
-
def exists(key, locale)
|
25
|
-
build_op(column_name).has_key?(locale) & build_op(column_name)[locale].has_key?(key.to_s)
|
26
|
-
end
|
27
|
-
|
28
|
-
def quote(value)
|
29
|
-
value && value.to_json
|
30
|
-
end
|
31
|
-
|
32
|
-
private
|
33
|
-
|
34
|
-
def build_op(key)
|
35
|
-
::Sequel.pg_jsonb_op(key)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
Container.private_constant :JsonbQueryMethods
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
@@ -1,34 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
require 'mobility/backends/sequel/pg_query_methods'
|
3
|
-
require "mobility/backends/sequel/query_methods"
|
4
|
-
|
5
|
-
Sequel.extension :pg_hstore, :pg_hstore_ops
|
6
|
-
|
7
|
-
module Mobility
|
8
|
-
module Backends
|
9
|
-
module Sequel
|
10
|
-
class Hstore::QueryMethods < QueryMethods
|
11
|
-
include PgQueryMethods
|
12
|
-
|
13
|
-
def matches(key, locale)
|
14
|
-
build_op(key)[locale]
|
15
|
-
end
|
16
|
-
|
17
|
-
def exists(key, locale)
|
18
|
-
build_op(key).has_key?(locale)
|
19
|
-
end
|
20
|
-
|
21
|
-
def quote(value)
|
22
|
-
value && value.to_s
|
23
|
-
end
|
24
|
-
|
25
|
-
private
|
26
|
-
|
27
|
-
def build_op(key)
|
28
|
-
::Sequel.hstore_op(column_name(key))
|
29
|
-
end
|
30
|
-
end
|
31
|
-
Hstore.private_constant :QueryMethods
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
@@ -1,34 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
require "mobility/backends/sequel/pg_query_methods"
|
3
|
-
require "mobility/backends/sequel/query_methods"
|
4
|
-
|
5
|
-
Sequel.extension :pg_json, :pg_json_ops
|
6
|
-
|
7
|
-
module Mobility
|
8
|
-
module Backends
|
9
|
-
module Sequel
|
10
|
-
class Json::QueryMethods < QueryMethods
|
11
|
-
include PgQueryMethods
|
12
|
-
|
13
|
-
def matches(key, locale)
|
14
|
-
build_op(key).get_text(locale)
|
15
|
-
end
|
16
|
-
|
17
|
-
def exists(key, locale)
|
18
|
-
matches(key, locale) !~ nil
|
19
|
-
end
|
20
|
-
|
21
|
-
def quote(value)
|
22
|
-
value && value.to_s
|
23
|
-
end
|
24
|
-
|
25
|
-
private
|
26
|
-
|
27
|
-
def build_op(key)
|
28
|
-
::Sequel.pg_json_op(column_name(key))
|
29
|
-
end
|
30
|
-
end
|
31
|
-
Json.private_constant :QueryMethods
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|