motor-admin 0.3.5 → 0.3.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/motor/active_record_utils/active_record_filter.rb +60 -60
- data/lib/motor/version.rb +1 -1
- data/lib/motor.rb +0 -1
- metadata +2 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eda6baf4fb621527782a8529725aa8b8d794a95e17739f657d8ce03bc377de65
|
4
|
+
data.tar.gz: 262bceb177a009a497c84ba318254efe97894d474c98d3fcb3c34d35581d05a9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9b7500eb106243d61258e8c244a62c6a7cf0b70727a2a69c401fd727a49f7922b1d2e0df097e5ac6c5ba5c6ca176fedc95c46dee873b1308cf9445122ce2f7e1
|
7
|
+
data.tar.gz: 8fdaa674012474e2db6fd95679476aa0ebbf59bfb2d54589e5816d819b4ec6b327c43929a832bccc969b161e90a5efad59246dc68db9e9944c21cac1244b73c9
|
@@ -5,14 +5,44 @@ module ActiveRecord
|
|
5
5
|
end
|
6
6
|
end
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
8
|
+
module Arel
|
9
|
+
module Attributes
|
10
|
+
class Relation < Attribute
|
11
|
+
attr_accessor :collection, :for_write
|
12
|
+
|
13
|
+
def initialize(relation, name, collection = false, for_write = false)
|
14
|
+
self[:relation] = relation
|
15
|
+
self[:name] = name
|
16
|
+
@collection = collection
|
17
|
+
@for_write = for_write
|
18
|
+
end
|
19
|
+
|
20
|
+
delegate :able_to_type_cast?, to: :relation
|
21
|
+
|
22
|
+
def table_name
|
23
|
+
nil
|
24
|
+
end
|
25
|
+
|
26
|
+
def eql?(other)
|
27
|
+
self.class == other.class &&
|
28
|
+
relation == other.relation &&
|
29
|
+
name == other.name &&
|
30
|
+
collection == other.collection
|
31
|
+
end
|
32
|
+
|
33
|
+
delegate :type_cast_for_database, to: :relation
|
34
|
+
end
|
13
35
|
end
|
36
|
+
end
|
14
37
|
|
15
|
-
|
38
|
+
module Arel
|
39
|
+
module Visitors
|
40
|
+
class ToSql
|
41
|
+
def visit_Arel_Attributes_Relation(o, collector)
|
42
|
+
visit(o.relation, collector)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
16
46
|
end
|
17
47
|
|
18
48
|
module ActiveRecord
|
@@ -64,29 +94,30 @@ module ActiveRecord
|
|
64
94
|
end
|
65
95
|
elsif reflection = klass._reflections[key.to_s]
|
66
96
|
if value.is_a?(Hash)
|
67
|
-
relations <<
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
97
|
+
relations <<
|
98
|
+
if reflection.polymorphic?
|
99
|
+
value = value.dup
|
100
|
+
join_klass = value.delete(:as).safe_constantize
|
101
|
+
right_table = join_klass.arel_table
|
102
|
+
left_table = reflection.active_record.arel_table
|
103
|
+
|
104
|
+
on = right_table[join_klass.primary_key]
|
105
|
+
.eq(left_table[reflection.foreign_key])
|
106
|
+
.and(left_table[reflection.foreign_type].eq(join_klass.name))
|
107
|
+
|
108
|
+
cross_boundry_joins = join_klass.left_outer_joins(ActiveRecord::PredicateBuilder.filter_joins(join_klass, value).flatten).send(
|
109
|
+
:build_joins, []
|
110
|
+
)
|
111
|
+
|
112
|
+
[
|
113
|
+
left_table.join(right_table, Arel::Nodes::OuterJoin).on(on).join_sources,
|
114
|
+
cross_boundry_joins
|
115
|
+
]
|
116
|
+
else
|
117
|
+
{
|
118
|
+
key => build_filter_joins(reflection.klass, value, [], custom)
|
119
|
+
}
|
120
|
+
end
|
90
121
|
elsif value.is_a?(Array)
|
91
122
|
value.each do |v|
|
92
123
|
relations << {
|
@@ -233,37 +264,6 @@ module ActiveRecord
|
|
233
264
|
attribute.has_any_key(*Array(value).map { |x| Arel::Nodes.build_quoted(x) })
|
234
265
|
when :in
|
235
266
|
attribute.in(value)
|
236
|
-
when :intersects
|
237
|
-
# geometry_value = if value.is_a?(Hash) # GeoJSON
|
238
|
-
# Arel::Nodes::NamedFunction.new('ST_GeomFromGeoJSON', [JSON.generate(value)])
|
239
|
-
# elsif # EWKB
|
240
|
-
# elsif # WKB
|
241
|
-
# elsif # EWKT
|
242
|
-
# elsif # WKT
|
243
|
-
# end
|
244
|
-
|
245
|
-
# TODO: us above if to determin if SRID sent
|
246
|
-
geometry_value = if value.is_a?(Hash)
|
247
|
-
Arel::Nodes::NamedFunction.new('ST_SetSRID',
|
248
|
-
[
|
249
|
-
Arel::Nodes::NamedFunction.new('ST_GeomFromGeoJSON',
|
250
|
-
[Arel::Nodes.build_quoted(JSON.generate(subvalue))]), 4326
|
251
|
-
])
|
252
|
-
elsif value[0, 1] == "\x00" || value[0, 1] == "\x01" || value[0, 4] =~ /[0-9a-fA-F]{4}/
|
253
|
-
Arel::Nodes::NamedFunction.new('ST_SetSRID',
|
254
|
-
[
|
255
|
-
Arel::Nodes::NamedFunction.new('ST_GeomFromEWKB',
|
256
|
-
[Arel::Nodes.build_quoted(subvalue)]), 4326
|
257
|
-
])
|
258
|
-
else
|
259
|
-
Arel::Nodes::NamedFunction.new('ST_SetSRID',
|
260
|
-
[
|
261
|
-
Arel::Nodes::NamedFunction.new('ST_GeomFromText',
|
262
|
-
[Arel::Nodes.build_quoted(subvalue)]), 4326
|
263
|
-
])
|
264
|
-
end
|
265
|
-
|
266
|
-
Arel::Nodes::NamedFunction.new('ST_Intersects', [attribute, geometry_value])
|
267
267
|
when :less_than, :lt
|
268
268
|
attribute.lt(value)
|
269
269
|
when :less_than_or_equal_to, :lteq, :lte
|
data/lib/motor/version.rb
CHANGED
data/lib/motor.rb
CHANGED
metadata
CHANGED
@@ -1,29 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: motor-admin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pete Matsyburka
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-08-
|
11
|
+
date: 2022-08-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: arel-extensions
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ">="
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '6.0'
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ">="
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '6.0'
|
27
13
|
- !ruby/object:Gem::Dependency
|
28
14
|
name: ar_lazy_preload
|
29
15
|
requirement: !ruby/object:Gem::Requirement
|