torque-postgresql 0.2.16 → 1.0.0

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.
Files changed (64) hide show
  1. checksums.yaml +4 -4
  2. data/README.rdoc +76 -3
  3. data/lib/torque-postgresql.rb +1 -0
  4. data/lib/torque/postgresql.rb +6 -0
  5. data/lib/torque/postgresql/adapter.rb +2 -4
  6. data/lib/torque/postgresql/adapter/database_statements.rb +23 -9
  7. data/lib/torque/postgresql/adapter/oid.rb +12 -1
  8. data/lib/torque/postgresql/adapter/oid/box.rb +28 -0
  9. data/lib/torque/postgresql/adapter/oid/circle.rb +37 -0
  10. data/lib/torque/postgresql/adapter/oid/enum.rb +9 -5
  11. data/lib/torque/postgresql/adapter/oid/enum_set.rb +44 -0
  12. data/lib/torque/postgresql/adapter/oid/line.rb +59 -0
  13. data/lib/torque/postgresql/adapter/oid/range.rb +52 -0
  14. data/lib/torque/postgresql/adapter/oid/segment.rb +73 -0
  15. data/lib/torque/postgresql/adapter/quoting.rb +21 -0
  16. data/lib/torque/postgresql/adapter/schema_definitions.rb +7 -0
  17. data/lib/torque/postgresql/adapter/schema_dumper.rb +10 -1
  18. data/lib/torque/postgresql/arel.rb +3 -0
  19. data/lib/torque/postgresql/arel/infix_operation.rb +42 -0
  20. data/lib/torque/postgresql/arel/nodes.rb +32 -0
  21. data/lib/torque/postgresql/arel/operations.rb +18 -0
  22. data/lib/torque/postgresql/arel/visitors.rb +28 -2
  23. data/lib/torque/postgresql/associations.rb +8 -0
  24. data/lib/torque/postgresql/associations/association.rb +30 -0
  25. data/lib/torque/postgresql/associations/association_scope.rb +116 -0
  26. data/lib/torque/postgresql/associations/belongs_to_many_association.rb +117 -0
  27. data/lib/torque/postgresql/associations/builder.rb +2 -0
  28. data/lib/torque/postgresql/associations/builder/belongs_to_many.rb +121 -0
  29. data/lib/torque/postgresql/associations/builder/has_many.rb +15 -0
  30. data/lib/torque/postgresql/associations/join_dependency/join_association.rb +15 -0
  31. data/lib/torque/postgresql/associations/preloader.rb +25 -0
  32. data/lib/torque/postgresql/associations/preloader/association.rb +64 -0
  33. data/lib/torque/postgresql/attributes.rb +2 -0
  34. data/lib/torque/postgresql/attributes/builder.rb +1 -0
  35. data/lib/torque/postgresql/attributes/builder/enum.rb +23 -15
  36. data/lib/torque/postgresql/attributes/builder/period.rb +452 -0
  37. data/lib/torque/postgresql/attributes/enum.rb +11 -8
  38. data/lib/torque/postgresql/attributes/enum_set.rb +256 -0
  39. data/lib/torque/postgresql/attributes/lazy.rb +1 -1
  40. data/lib/torque/postgresql/attributes/period.rb +31 -0
  41. data/lib/torque/postgresql/attributes/type_map.rb +3 -5
  42. data/lib/torque/postgresql/autosave_association.rb +40 -0
  43. data/lib/torque/postgresql/auxiliary_statement.rb +201 -198
  44. data/lib/torque/postgresql/auxiliary_statement/settings.rb +20 -12
  45. data/lib/torque/postgresql/base.rb +161 -2
  46. data/lib/torque/postgresql/config.rb +91 -9
  47. data/lib/torque/postgresql/geometry_builder.rb +92 -0
  48. data/lib/torque/postgresql/i18n.rb +1 -1
  49. data/lib/torque/postgresql/railtie.rb +18 -5
  50. data/lib/torque/postgresql/reflection.rb +21 -0
  51. data/lib/torque/postgresql/reflection/abstract_reflection.rb +109 -0
  52. data/lib/torque/postgresql/reflection/association_reflection.rb +30 -0
  53. data/lib/torque/postgresql/reflection/belongs_to_many_reflection.rb +44 -0
  54. data/lib/torque/postgresql/reflection/has_many_reflection.rb +13 -0
  55. data/lib/torque/postgresql/reflection/runtime_reflection.rb +12 -0
  56. data/lib/torque/postgresql/reflection/through_reflection.rb +11 -0
  57. data/lib/torque/postgresql/relation.rb +11 -10
  58. data/lib/torque/postgresql/relation/auxiliary_statement.rb +11 -18
  59. data/lib/torque/postgresql/relation/inheritance.rb +2 -2
  60. data/lib/torque/postgresql/relation/merger.rb +11 -7
  61. data/lib/torque/postgresql/schema_cache.rb +1 -1
  62. data/lib/torque/postgresql/version.rb +1 -1
  63. data/lib/torque/range.rb +40 -0
  64. 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
@@ -1,5 +1,5 @@
1
1
  module Torque
2
2
  module PostgreSQL
3
- VERSION = '0.2.16'
3
+ VERSION = '1.0.0'
4
4
  end
5
5
  end
@@ -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.2.16
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-01-09 00:00:00.000000000 Z
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: factory_girl
122
+ name: factory_bot
123
123
  requirement: !ruby/object:Gem::Requirement
124
124
  requirements:
125
125
  - - "~>"
126
126
  - !ruby/object:Gem::Version
127
- version: '4.5'
127
+ version: '5.0'
128
128
  - - ">="
129
129
  - !ruby/object:Gem::Version
130
- version: 4.5.0
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: '4.5'
137
+ version: '5.0'
138
138
  - - ">="
139
139
  - !ruby/object:Gem::Version
140
- version: 4.5.0
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, user-defined
162
- types and auxiliary statements (CTE)
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