torque-postgresql 0.2.16 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.rdoc +76 -3
- data/lib/torque-postgresql.rb +1 -0
- data/lib/torque/postgresql.rb +6 -0
- data/lib/torque/postgresql/adapter.rb +2 -4
- data/lib/torque/postgresql/adapter/database_statements.rb +23 -9
- data/lib/torque/postgresql/adapter/oid.rb +12 -1
- data/lib/torque/postgresql/adapter/oid/box.rb +28 -0
- data/lib/torque/postgresql/adapter/oid/circle.rb +37 -0
- data/lib/torque/postgresql/adapter/oid/enum.rb +9 -5
- data/lib/torque/postgresql/adapter/oid/enum_set.rb +44 -0
- data/lib/torque/postgresql/adapter/oid/line.rb +59 -0
- data/lib/torque/postgresql/adapter/oid/range.rb +52 -0
- data/lib/torque/postgresql/adapter/oid/segment.rb +73 -0
- data/lib/torque/postgresql/adapter/quoting.rb +21 -0
- data/lib/torque/postgresql/adapter/schema_definitions.rb +7 -0
- data/lib/torque/postgresql/adapter/schema_dumper.rb +10 -1
- data/lib/torque/postgresql/arel.rb +3 -0
- data/lib/torque/postgresql/arel/infix_operation.rb +42 -0
- data/lib/torque/postgresql/arel/nodes.rb +32 -0
- data/lib/torque/postgresql/arel/operations.rb +18 -0
- data/lib/torque/postgresql/arel/visitors.rb +28 -2
- data/lib/torque/postgresql/associations.rb +8 -0
- data/lib/torque/postgresql/associations/association.rb +30 -0
- data/lib/torque/postgresql/associations/association_scope.rb +116 -0
- data/lib/torque/postgresql/associations/belongs_to_many_association.rb +117 -0
- data/lib/torque/postgresql/associations/builder.rb +2 -0
- data/lib/torque/postgresql/associations/builder/belongs_to_many.rb +121 -0
- data/lib/torque/postgresql/associations/builder/has_many.rb +15 -0
- data/lib/torque/postgresql/associations/join_dependency/join_association.rb +15 -0
- data/lib/torque/postgresql/associations/preloader.rb +25 -0
- data/lib/torque/postgresql/associations/preloader/association.rb +64 -0
- data/lib/torque/postgresql/attributes.rb +2 -0
- data/lib/torque/postgresql/attributes/builder.rb +1 -0
- data/lib/torque/postgresql/attributes/builder/enum.rb +23 -15
- data/lib/torque/postgresql/attributes/builder/period.rb +452 -0
- data/lib/torque/postgresql/attributes/enum.rb +11 -8
- data/lib/torque/postgresql/attributes/enum_set.rb +256 -0
- data/lib/torque/postgresql/attributes/lazy.rb +1 -1
- data/lib/torque/postgresql/attributes/period.rb +31 -0
- data/lib/torque/postgresql/attributes/type_map.rb +3 -5
- data/lib/torque/postgresql/autosave_association.rb +40 -0
- data/lib/torque/postgresql/auxiliary_statement.rb +201 -198
- data/lib/torque/postgresql/auxiliary_statement/settings.rb +20 -12
- data/lib/torque/postgresql/base.rb +161 -2
- data/lib/torque/postgresql/config.rb +91 -9
- data/lib/torque/postgresql/geometry_builder.rb +92 -0
- data/lib/torque/postgresql/i18n.rb +1 -1
- data/lib/torque/postgresql/railtie.rb +18 -5
- data/lib/torque/postgresql/reflection.rb +21 -0
- data/lib/torque/postgresql/reflection/abstract_reflection.rb +109 -0
- data/lib/torque/postgresql/reflection/association_reflection.rb +30 -0
- data/lib/torque/postgresql/reflection/belongs_to_many_reflection.rb +44 -0
- data/lib/torque/postgresql/reflection/has_many_reflection.rb +13 -0
- data/lib/torque/postgresql/reflection/runtime_reflection.rb +12 -0
- data/lib/torque/postgresql/reflection/through_reflection.rb +11 -0
- data/lib/torque/postgresql/relation.rb +11 -10
- data/lib/torque/postgresql/relation/auxiliary_statement.rb +11 -18
- data/lib/torque/postgresql/relation/inheritance.rb +2 -2
- data/lib/torque/postgresql/relation/merger.rb +11 -7
- data/lib/torque/postgresql/schema_cache.rb +1 -1
- data/lib/torque/postgresql/version.rb +1 -1
- data/lib/torque/range.rb +40 -0
- metadata +41 -9
@@ -134,7 +134,7 @@ module Torque
|
|
134
134
|
# Find a model by a given max namespaced class name thath matches the
|
135
135
|
# given table name
|
136
136
|
def find_model(max_name, table_name, scope = Object)
|
137
|
-
pieces = max_name.is_a?(Array) ? max_name : max_name.split(/(::)/)
|
137
|
+
pieces = max_name.is_a?(::Array) ? max_name : max_name.split(/(::)/)
|
138
138
|
ns_places = (1..(max_name.size - 1)).step(2).to_a
|
139
139
|
|
140
140
|
# Generate all possible combinarions
|
data/lib/torque/range.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
module Torque
|
2
|
+
module Range
|
3
|
+
def intersection(other)
|
4
|
+
raise ArgumentError, 'value must be a Range' unless other.kind_of?(Range)
|
5
|
+
|
6
|
+
new_min = self.cover?(other.min) ? other.min : other.cover?(min) ? min : nil
|
7
|
+
new_max = self.cover?(other.max) ? other.max : other.cover?(max) ? max : nil
|
8
|
+
|
9
|
+
new_min && new_max ? new_min..new_max : nil
|
10
|
+
end
|
11
|
+
alias_method :&, :intersection
|
12
|
+
|
13
|
+
def union(other)
|
14
|
+
raise ArgumentError, 'value must be a Range' unless other.kind_of?(Range)
|
15
|
+
|
16
|
+
([min, other.min].min)..([max, other.max].max)
|
17
|
+
end
|
18
|
+
alias_method :|, :union
|
19
|
+
|
20
|
+
def subtract(other)
|
21
|
+
raise ArgumentError, 'value must be a Range' unless other.kind_of?(Range)
|
22
|
+
return if other.eql?(self)
|
23
|
+
|
24
|
+
other = intersection(other)
|
25
|
+
return self if other.nil?
|
26
|
+
|
27
|
+
min.eql?(other.min) ? other.max..max : min..other.min
|
28
|
+
end
|
29
|
+
alias_method :-, :subtract
|
30
|
+
|
31
|
+
def add(other)
|
32
|
+
raise ArgumentError, 'value must be a Range' unless other.kind_of?(Range)
|
33
|
+
|
34
|
+
intersection(other) ? union(other) : self
|
35
|
+
end
|
36
|
+
alias_method :+, :add
|
37
|
+
end
|
38
|
+
|
39
|
+
::Range.include(Range)
|
40
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: torque-postgresql
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Carlos Silva
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-08-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -119,25 +119,25 @@ dependencies:
|
|
119
119
|
- !ruby/object:Gem::Version
|
120
120
|
version: 3.5.0
|
121
121
|
- !ruby/object:Gem::Dependency
|
122
|
-
name:
|
122
|
+
name: factory_bot
|
123
123
|
requirement: !ruby/object:Gem::Requirement
|
124
124
|
requirements:
|
125
125
|
- - "~>"
|
126
126
|
- !ruby/object:Gem::Version
|
127
|
-
version: '
|
127
|
+
version: '5.0'
|
128
128
|
- - ">="
|
129
129
|
- !ruby/object:Gem::Version
|
130
|
-
version:
|
130
|
+
version: 5.0.2
|
131
131
|
type: :development
|
132
132
|
prerelease: false
|
133
133
|
version_requirements: !ruby/object:Gem::Requirement
|
134
134
|
requirements:
|
135
135
|
- - "~>"
|
136
136
|
- !ruby/object:Gem::Version
|
137
|
-
version: '
|
137
|
+
version: '5.0'
|
138
138
|
- - ">="
|
139
139
|
- !ruby/object:Gem::Version
|
140
|
-
version:
|
140
|
+
version: 5.0.2
|
141
141
|
- !ruby/object:Gem::Dependency
|
142
142
|
name: faker
|
143
143
|
requirement: !ruby/object:Gem::Requirement
|
@@ -158,8 +158,8 @@ dependencies:
|
|
158
158
|
- - ">="
|
159
159
|
- !ruby/object:Gem::Version
|
160
160
|
version: 1.5.0
|
161
|
-
description: Add support to complex resources of PostgreSQL, like data types,
|
162
|
-
|
161
|
+
description: Add support to complex resources of PostgreSQL, like data types, array
|
162
|
+
associations, and auxiliary statements (CTE)
|
163
163
|
email:
|
164
164
|
- carlinhus.fsilva@gmail.com
|
165
165
|
executables: []
|
@@ -174,34 +174,65 @@ files:
|
|
174
174
|
- lib/torque/postgresql/adapter.rb
|
175
175
|
- lib/torque/postgresql/adapter/database_statements.rb
|
176
176
|
- lib/torque/postgresql/adapter/oid.rb
|
177
|
+
- lib/torque/postgresql/adapter/oid/box.rb
|
178
|
+
- lib/torque/postgresql/adapter/oid/circle.rb
|
177
179
|
- lib/torque/postgresql/adapter/oid/enum.rb
|
180
|
+
- lib/torque/postgresql/adapter/oid/enum_set.rb
|
178
181
|
- lib/torque/postgresql/adapter/oid/interval.rb
|
182
|
+
- lib/torque/postgresql/adapter/oid/line.rb
|
183
|
+
- lib/torque/postgresql/adapter/oid/range.rb
|
184
|
+
- lib/torque/postgresql/adapter/oid/segment.rb
|
179
185
|
- lib/torque/postgresql/adapter/quoting.rb
|
180
186
|
- lib/torque/postgresql/adapter/schema_creation.rb
|
181
187
|
- lib/torque/postgresql/adapter/schema_definitions.rb
|
182
188
|
- lib/torque/postgresql/adapter/schema_dumper.rb
|
183
189
|
- lib/torque/postgresql/adapter/schema_statements.rb
|
184
190
|
- lib/torque/postgresql/arel.rb
|
191
|
+
- lib/torque/postgresql/arel/infix_operation.rb
|
185
192
|
- lib/torque/postgresql/arel/join_source.rb
|
193
|
+
- lib/torque/postgresql/arel/nodes.rb
|
194
|
+
- lib/torque/postgresql/arel/operations.rb
|
186
195
|
- lib/torque/postgresql/arel/select_manager.rb
|
187
196
|
- lib/torque/postgresql/arel/visitors.rb
|
197
|
+
- lib/torque/postgresql/associations.rb
|
198
|
+
- lib/torque/postgresql/associations/association.rb
|
199
|
+
- lib/torque/postgresql/associations/association_scope.rb
|
200
|
+
- lib/torque/postgresql/associations/belongs_to_many_association.rb
|
201
|
+
- lib/torque/postgresql/associations/builder.rb
|
202
|
+
- lib/torque/postgresql/associations/builder/belongs_to_many.rb
|
203
|
+
- lib/torque/postgresql/associations/builder/has_many.rb
|
204
|
+
- lib/torque/postgresql/associations/join_dependency/join_association.rb
|
205
|
+
- lib/torque/postgresql/associations/preloader.rb
|
206
|
+
- lib/torque/postgresql/associations/preloader/association.rb
|
188
207
|
- lib/torque/postgresql/attributes.rb
|
189
208
|
- lib/torque/postgresql/attributes/builder.rb
|
190
209
|
- lib/torque/postgresql/attributes/builder/enum.rb
|
210
|
+
- lib/torque/postgresql/attributes/builder/period.rb
|
191
211
|
- lib/torque/postgresql/attributes/enum.rb
|
212
|
+
- lib/torque/postgresql/attributes/enum_set.rb
|
192
213
|
- lib/torque/postgresql/attributes/lazy.rb
|
214
|
+
- lib/torque/postgresql/attributes/period.rb
|
193
215
|
- lib/torque/postgresql/attributes/type_map.rb
|
216
|
+
- lib/torque/postgresql/autosave_association.rb
|
194
217
|
- lib/torque/postgresql/auxiliary_statement.rb
|
195
218
|
- lib/torque/postgresql/auxiliary_statement/settings.rb
|
196
219
|
- lib/torque/postgresql/base.rb
|
197
220
|
- lib/torque/postgresql/coder.rb
|
198
221
|
- lib/torque/postgresql/collector.rb
|
199
222
|
- lib/torque/postgresql/config.rb
|
223
|
+
- lib/torque/postgresql/geometry_builder.rb
|
200
224
|
- lib/torque/postgresql/i18n.rb
|
201
225
|
- lib/torque/postgresql/inheritance.rb
|
202
226
|
- lib/torque/postgresql/migration.rb
|
203
227
|
- lib/torque/postgresql/migration/command_recorder.rb
|
204
228
|
- lib/torque/postgresql/railtie.rb
|
229
|
+
- lib/torque/postgresql/reflection.rb
|
230
|
+
- lib/torque/postgresql/reflection/abstract_reflection.rb
|
231
|
+
- lib/torque/postgresql/reflection/association_reflection.rb
|
232
|
+
- lib/torque/postgresql/reflection/belongs_to_many_reflection.rb
|
233
|
+
- lib/torque/postgresql/reflection/has_many_reflection.rb
|
234
|
+
- lib/torque/postgresql/reflection/runtime_reflection.rb
|
235
|
+
- lib/torque/postgresql/reflection/through_reflection.rb
|
205
236
|
- lib/torque/postgresql/relation.rb
|
206
237
|
- lib/torque/postgresql/relation/auxiliary_statement.rb
|
207
238
|
- lib/torque/postgresql/relation/distinct_on.rb
|
@@ -210,6 +241,7 @@ files:
|
|
210
241
|
- lib/torque/postgresql/schema_cache.rb
|
211
242
|
- lib/torque/postgresql/schema_dumper.rb
|
212
243
|
- lib/torque/postgresql/version.rb
|
244
|
+
- lib/torque/range.rb
|
213
245
|
homepage: https://github.com/crashtech/torque-postgresql
|
214
246
|
licenses:
|
215
247
|
- MIT
|