dbee-active_record 2.1.0.pre.alpha.1 → 2.3.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 (39) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +84 -0
  3. data/.rubocop.yml +4 -18
  4. data/.tool-versions +1 -0
  5. data/CHANGELOG.md +19 -1
  6. data/Guardfile +2 -1
  7. data/README.md +4 -4
  8. data/dbee-active_record.gemspec +11 -13
  9. data/lib/dbee/providers/active_record_provider/expression_builder.rb +81 -59
  10. data/lib/dbee/providers/active_record_provider/maker.rb +37 -0
  11. data/lib/dbee/providers/active_record_provider/{expression_builder → makers}/constraint.rb +1 -1
  12. data/lib/dbee/providers/active_record_provider/{expression_builder → makers}/order.rb +1 -1
  13. data/lib/dbee/providers/active_record_provider/{expression_builder → makers}/select.rb +13 -3
  14. data/lib/dbee/providers/active_record_provider/{expression_builder → makers}/where.rb +27 -7
  15. data/lib/dbee/providers/active_record_provider/version.rb +1 -1
  16. data/lib/dbee/providers/active_record_provider.rb +3 -3
  17. data/spec/db_helper.rb +7 -3
  18. data/spec/dbee/providers/active_record_provider/expression_builder_spec.rb +90 -0
  19. data/spec/dbee/providers/active_record_provider/makers/where_spec.rb +260 -0
  20. data/spec/dbee/providers/active_record_provider_spec.rb +15 -18
  21. data/spec/fixtures/active_record_snapshots/five_table_query.yaml +1 -0
  22. data/spec/fixtures/active_record_snapshots/multiple_same_table_query_with_static_constraints.yaml +1 -0
  23. data/spec/fixtures/active_record_snapshots/one_table_empty_query.yaml +11 -0
  24. data/spec/fixtures/active_record_snapshots/one_table_query.yaml +1 -0
  25. data/spec/fixtures/active_record_snapshots/one_table_query_with_ascending_sort.yaml +1 -0
  26. data/spec/fixtures/active_record_snapshots/one_table_query_with_descending_sort.yaml +1 -0
  27. data/spec/fixtures/active_record_snapshots/one_table_query_with_filters.yaml +1 -0
  28. data/spec/fixtures/active_record_snapshots/one_table_query_with_limit.yaml +1 -0
  29. data/spec/fixtures/active_record_snapshots/one_table_query_with_multiple_sorts.yaml +1 -0
  30. data/spec/fixtures/active_record_snapshots/partitioner_example_1_query.yaml +1 -0
  31. data/spec/fixtures/active_record_snapshots/partitioner_example_2_query.yaml +1 -0
  32. data/spec/fixtures/active_record_snapshots/reverse_polymorphic_query.yaml +1 -0
  33. data/spec/fixtures/active_record_snapshots/two_table_query.yaml +6 -0
  34. data/spec/fixtures/active_record_snapshots/two_table_query_with_aggregation.yaml +1 -0
  35. data/spec/fixtures/active_record_snapshots/two_table_query_with_pivoting.yaml +1 -0
  36. data/spec/fixtures/models.yaml +110 -102
  37. data/spec/spec_helper.rb +13 -2
  38. metadata +108 -27
  39. data/.travis.yml +0 -31
@@ -1,125 +1,133 @@
1
1
  Theaters, Members, and Movies:
2
- name: theaters
3
- table: theaters
4
- models:
5
- - name: members
6
- table: members
7
- constraints:
8
- - type: reference
9
- parent: id
10
- name: tid
11
- - type: reference
12
- parent: partition
13
- name: partition
14
- models:
15
- - name: demos
16
- table: demographics
17
- constraints:
18
- - type: reference
19
- parent: id
20
- name: member_id
21
- models:
22
- - name: phone_numbers
23
- table: phone_numbers
24
- constraints:
25
- - type: reference
26
- parent: id
27
- name: demographic_id
28
- - name: movies
29
- table: movies
30
- constraints:
31
- - type: reference
32
- parent: id
33
- name: member_id
34
- - name: favorite_comic_movies
35
- table: movies
36
- constraints:
37
- - type: reference
38
- parent: id
39
- name: member_id
40
- - type: static
41
- name: genre
42
- value: comic
43
- - name: favorite_mystery_movies
44
- table: movies
45
- constraints:
46
- - type: reference
47
- parent: id
48
- name: member_id
49
- - type: static
50
- name: genre
51
- value: mystery
52
- - name: favorite_comedy_movies
53
- table: movies
54
- constraints:
55
- - type: reference
56
- parent: id
57
- name: member_id
58
- - type: static
59
- name: genre
60
- value: comedy
2
+ theaters:
3
+ relationships:
4
+ members:
5
+ constraints:
6
+ - type: reference
7
+ parent: id
8
+ name: tid
9
+ - type: reference
10
+ parent: partition
11
+ name: partition
12
+ members:
13
+ relationships:
14
+ demos:
15
+ model: demographics
16
+ constraints:
17
+ - type: reference
18
+ parent: id
19
+ name: member_id
20
+ movies:
21
+ constraints:
22
+ - type: reference
23
+ parent: id
24
+ name: member_id
25
+ favorite_comic_movies:
26
+ model: movies
27
+ constraints:
28
+ - type: reference
29
+ parent: id
30
+ name: member_id
31
+ - type: static
32
+ name: genre
33
+ value: comic
34
+ favorite_mystery_movies:
35
+ model: movies
36
+ constraints:
37
+ - type: reference
38
+ parent: id
39
+ name: member_id
40
+ - type: static
41
+ name: genre
42
+ value: mystery
43
+ favorite_comedy_movies:
44
+ model: movies
45
+ constraints:
46
+ - type: reference
47
+ parent: id
48
+ name: member_id
49
+ - type: static
50
+ name: genre
51
+ value: comedy
52
+ demographics:
53
+ table: demographics
54
+ relationships:
55
+ phone_numbers:
56
+ constraints:
57
+ - type: reference
58
+ parent: id
59
+ name: demographic_id
60
+ phone_numbers:
61
+ movies:
62
+
61
63
  Reverse Polymorphic Example:
62
64
  # In this example, an animal has a toy, but that toy is either a dog or cat toy, depending on
63
65
  # the type of the animal. So for this to work in this direction, static constraints pointed
64
66
  # at the parent (animals) is needed.
65
- name: animals
66
- models:
67
- - name: dog_toy
68
- table: dog_toys
67
+ animals:
68
+ relationships:
69
+ dog_toy:
70
+ model: dog_toys
69
71
  constraints:
70
72
  - parent: toy_id
71
73
  name: id
72
74
  - type: static
73
75
  parent: type
74
76
  value: Dog
75
- - name: cat_toy
76
- table: cat_toys
77
+ cat_toy:
78
+ model: cat_toys
77
79
  constraints:
78
80
  - parent: toy_id
79
81
  name: id
80
82
  - type: static
81
83
  parent: type
82
84
  value: Cat
85
+ dog_toys:
86
+ cat_toys:
83
87
 
84
88
  Partitioner Example 1:
85
- name: dogs
86
- table: animals
87
- partitioners:
88
- - name: type
89
- value: Dog
90
- - name: deleted
91
- value: false
89
+ dogs:
90
+ table: animals
91
+ partitioners:
92
+ - name: type
93
+ value: Dog
94
+ - name: deleted
95
+ value: false
92
96
 
93
97
  Partitioner Example 2:
94
- name: owners
95
- models:
96
- - name: dogs
97
- table: animals
98
- constraints:
99
- - name: owner_id
100
- parent: id
101
- partitioners:
102
- - name: type
103
- value: Dog
104
- - name: deleted
105
- value: false
98
+ owners:
99
+ relationships:
100
+ dogs:
101
+ constraints:
102
+ - name: owner_id
103
+ parent: id
104
+ dogs:
105
+ table: animals
106
+ partitioners:
107
+ - name: type
108
+ value: Dog
109
+ - name: deleted
110
+ value: false
106
111
 
107
112
  Patients:
108
- name: patients
109
- models:
110
- - name: patient_payments
111
- constraints:
112
- - type: reference
113
- parent: id
114
- name: patient_id
115
- - name: patient_field_values
116
- constraints:
117
- - type: reference
118
- parent: id
119
- name: patient_id
120
- models:
121
- - name: fields
122
- constraints:
123
- - type: reference
124
- parent: field_id
125
- name: id
113
+ patients:
114
+ relationships:
115
+ patient_payments:
116
+ constraints:
117
+ - type: reference
118
+ parent: id
119
+ name: patient_id
120
+ patient_field_values:
121
+ constraints:
122
+ - type: reference
123
+ parent: id
124
+ name: patient_id
125
+ patient_field_values:
126
+ relationships:
127
+ fields:
128
+ constraints:
129
+ - type: reference
130
+ parent: field_id
131
+ name: id
132
+ patient_payments:
133
+ fields:
data/spec/spec_helper.rb CHANGED
@@ -7,8 +7,15 @@
7
7
  # LICENSE file in the root directory of this source tree.
8
8
  #
9
9
 
10
- require 'yaml'
11
10
  require 'pry'
11
+ require 'super_diff/rspec'
12
+ require 'yaml'
13
+
14
+ RSpec.configure do |config|
15
+ # Allow for disabling auto focus mode in certain environments like CI to
16
+ # prevent false positives when only a subset of the suite passes.
17
+ config.filter_run_when_matching :focus unless ENV['DISABLE_RSPEC_FOCUS'] == 'true'
18
+ end
12
19
 
13
20
  unless ENV['DISABLE_SIMPLECOV'] == 'true'
14
21
  require 'simplecov'
@@ -35,7 +42,7 @@ def fixture(*filename)
35
42
  end
36
43
 
37
44
  def yaml_fixture_files(*directory)
38
- Dir[File.join('spec', 'fixtures', *directory, '*.yaml')].map do |filename|
45
+ Dir[File.join('spec', 'fixtures', *directory, '**', '*.yaml')].map do |filename|
39
46
  [
40
47
  filename,
41
48
  yaml_file_read(filename)
@@ -50,3 +57,7 @@ end
50
57
  def file_read(*filename)
51
58
  File.open(File.join(*filename), 'r:bom|utf-8').read
52
59
  end
60
+
61
+ def models
62
+ yaml_fixture('models.yaml')
63
+ end
metadata CHANGED
@@ -1,14 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dbee-active_record
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0.pre.alpha.1
4
+ version: 2.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew Ruggio
8
- autorequire:
8
+ - Craig Kattner
9
+ autorequire:
9
10
  bindir: exe
10
11
  cert_chain: []
11
- date: 2020-07-09 00:00:00.000000000 Z
12
+ date: 2021-10-04 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: activerecord
@@ -34,16 +35,22 @@ dependencies:
34
35
  name: dbee
35
36
  requirement: !ruby/object:Gem::Requirement
36
37
  requirements:
37
- - - '='
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '3'
41
+ - - ">="
38
42
  - !ruby/object:Gem::Version
39
- version: 2.1.0.pre.alpha
43
+ version: 3.1.0
40
44
  type: :runtime
41
45
  prerelease: false
42
46
  version_requirements: !ruby/object:Gem::Requirement
43
47
  requirements:
44
- - - '='
48
+ - - "~>"
45
49
  - !ruby/object:Gem::Version
46
- version: 2.1.0.pre.alpha
50
+ version: '3'
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: 3.1.0
47
54
  - !ruby/object:Gem::Dependency
48
55
  name: guard-rspec
49
56
  requirement: !ruby/object:Gem::Requirement
@@ -86,6 +93,20 @@ dependencies:
86
93
  - - "~>"
87
94
  - !ruby/object:Gem::Version
88
95
  version: '0'
96
+ - !ruby/object:Gem::Dependency
97
+ name: pry-byebug
98
+ requirement: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ type: :development
104
+ prerelease: false
105
+ version_requirements: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
89
110
  - !ruby/object:Gem::Dependency
90
111
  name: rake
91
112
  requirement: !ruby/object:Gem::Requirement
@@ -114,34 +135,76 @@ dependencies:
114
135
  - - "~>"
115
136
  - !ruby/object:Gem::Version
116
137
  version: '3.8'
138
+ - !ruby/object:Gem::Dependency
139
+ name: rspec_junit_formatter
140
+ requirement: !ruby/object:Gem::Requirement
141
+ requirements:
142
+ - - ">="
143
+ - !ruby/object:Gem::Version
144
+ version: '0'
145
+ type: :development
146
+ prerelease: false
147
+ version_requirements: !ruby/object:Gem::Requirement
148
+ requirements:
149
+ - - ">="
150
+ - !ruby/object:Gem::Version
151
+ version: '0'
117
152
  - !ruby/object:Gem::Dependency
118
153
  name: rubocop
119
154
  requirement: !ruby/object:Gem::Requirement
120
155
  requirements:
121
156
  - - "~>"
122
157
  - !ruby/object:Gem::Version
123
- version: 0.81.0
158
+ version: '1'
124
159
  type: :development
125
160
  prerelease: false
126
161
  version_requirements: !ruby/object:Gem::Requirement
127
162
  requirements:
128
163
  - - "~>"
129
164
  - !ruby/object:Gem::Version
130
- version: 0.81.0
165
+ version: '1'
166
+ - !ruby/object:Gem::Dependency
167
+ name: rubocop-rake
168
+ requirement: !ruby/object:Gem::Requirement
169
+ requirements:
170
+ - - ">="
171
+ - !ruby/object:Gem::Version
172
+ version: '0'
173
+ type: :development
174
+ prerelease: false
175
+ version_requirements: !ruby/object:Gem::Requirement
176
+ requirements:
177
+ - - ">="
178
+ - !ruby/object:Gem::Version
179
+ version: '0'
180
+ - !ruby/object:Gem::Dependency
181
+ name: rubocop-rspec
182
+ requirement: !ruby/object:Gem::Requirement
183
+ requirements:
184
+ - - ">="
185
+ - !ruby/object:Gem::Version
186
+ version: '0'
187
+ type: :development
188
+ prerelease: false
189
+ version_requirements: !ruby/object:Gem::Requirement
190
+ requirements:
191
+ - - ">="
192
+ - !ruby/object:Gem::Version
193
+ version: '0'
131
194
  - !ruby/object:Gem::Dependency
132
195
  name: simplecov
133
196
  requirement: !ruby/object:Gem::Requirement
134
197
  requirements:
135
198
  - - "~>"
136
199
  - !ruby/object:Gem::Version
137
- version: 0.17.0
200
+ version: 0.19.0
138
201
  type: :development
139
202
  prerelease: false
140
203
  version_requirements: !ruby/object:Gem::Requirement
141
204
  requirements:
142
205
  - - "~>"
143
206
  - !ruby/object:Gem::Version
144
- version: 0.17.0
207
+ version: 0.19.0
145
208
  - !ruby/object:Gem::Dependency
146
209
  name: simplecov-console
147
210
  requirement: !ruby/object:Gem::Requirement
@@ -170,19 +233,35 @@ dependencies:
170
233
  - - "~>"
171
234
  - !ruby/object:Gem::Version
172
235
  version: '1'
236
+ - !ruby/object:Gem::Dependency
237
+ name: super_diff
238
+ requirement: !ruby/object:Gem::Requirement
239
+ requirements:
240
+ - - "~>"
241
+ - !ruby/object:Gem::Version
242
+ version: '0.6'
243
+ type: :development
244
+ prerelease: false
245
+ version_requirements: !ruby/object:Gem::Requirement
246
+ requirements:
247
+ - - "~>"
248
+ - !ruby/object:Gem::Version
249
+ version: '0.6'
173
250
  description: " By default Dbee ships with no underlying SQL generator. This library
174
251
  will plug in ActiveRecord into Dbee and Dbee will use it for SQL generation.\n"
175
252
  email:
176
253
  - mruggio@bluemarblepayroll.com
254
+ - ckattner@bluemarblepayroll.com
177
255
  executables: []
178
256
  extensions: []
179
257
  extra_rdoc_files: []
180
258
  files:
259
+ - ".circleci/config.yml"
181
260
  - ".editorconfig"
182
261
  - ".gitignore"
183
262
  - ".rubocop.yml"
184
263
  - ".ruby-version"
185
- - ".travis.yml"
264
+ - ".tool-versions"
186
265
  - CHANGELOG.md
187
266
  - CODE_OF_CONDUCT.md
188
267
  - Gemfile
@@ -195,18 +274,22 @@ files:
195
274
  - exe/.gitkeep
196
275
  - lib/dbee/providers/active_record_provider.rb
197
276
  - lib/dbee/providers/active_record_provider/expression_builder.rb
198
- - lib/dbee/providers/active_record_provider/expression_builder/constraint.rb
199
- - lib/dbee/providers/active_record_provider/expression_builder/order.rb
200
- - lib/dbee/providers/active_record_provider/expression_builder/select.rb
201
- - lib/dbee/providers/active_record_provider/expression_builder/where.rb
277
+ - lib/dbee/providers/active_record_provider/maker.rb
278
+ - lib/dbee/providers/active_record_provider/makers/constraint.rb
279
+ - lib/dbee/providers/active_record_provider/makers/order.rb
280
+ - lib/dbee/providers/active_record_provider/makers/select.rb
281
+ - lib/dbee/providers/active_record_provider/makers/where.rb
202
282
  - lib/dbee/providers/active_record_provider/obfuscated_alias_maker.rb
203
283
  - lib/dbee/providers/active_record_provider/safe_alias_maker.rb
204
284
  - lib/dbee/providers/active_record_provider/version.rb
205
285
  - spec/config/database.yaml.ci
206
286
  - spec/db_helper.rb
287
+ - spec/dbee/providers/active_record_provider/expression_builder_spec.rb
288
+ - spec/dbee/providers/active_record_provider/makers/where_spec.rb
207
289
  - spec/dbee/providers/active_record_provider_spec.rb
208
290
  - spec/fixtures/active_record_snapshots/five_table_query.yaml
209
291
  - spec/fixtures/active_record_snapshots/multiple_same_table_query_with_static_constraints.yaml
292
+ - spec/fixtures/active_record_snapshots/one_table_empty_query.yaml
210
293
  - spec/fixtures/active_record_snapshots/one_table_query.yaml
211
294
  - spec/fixtures/active_record_snapshots/one_table_query_with_ascending_sort.yaml
212
295
  - spec/fixtures/active_record_snapshots/one_table_query_with_descending_sort.yaml
@@ -221,16 +304,11 @@ files:
221
304
  - spec/fixtures/active_record_snapshots/two_table_query_with_pivoting.yaml
222
305
  - spec/fixtures/models.yaml
223
306
  - spec/spec_helper.rb
224
- homepage: https://github.com/bluemarblepayroll/dbee-active_record
307
+ homepage:
225
308
  licenses:
226
309
  - MIT
227
- metadata:
228
- bug_tracker_uri: https://github.com/bluemarblepayroll/dbee-active_record/issues
229
- changelog_uri: https://github.com/bluemarblepayroll/dbee-active_record/blob/master/CHANGELOG.md
230
- documentation_uri: https://www.rubydoc.info/gems/dbee-active_record
231
- homepage_uri: https://github.com/bluemarblepayroll/dbee-active_record
232
- source_code_uri: https://github.com/bluemarblepayroll/dbee-active_record
233
- post_install_message:
310
+ metadata: {}
311
+ post_install_message:
234
312
  rdoc_options: []
235
313
  require_paths:
236
314
  - lib
@@ -241,20 +319,23 @@ required_ruby_version: !ruby/object:Gem::Requirement
241
319
  version: '2.5'
242
320
  required_rubygems_version: !ruby/object:Gem::Requirement
243
321
  requirements:
244
- - - ">"
322
+ - - ">="
245
323
  - !ruby/object:Gem::Version
246
- version: 1.3.1
324
+ version: '0'
247
325
  requirements: []
248
326
  rubygems_version: 3.0.3
249
- signing_key:
327
+ signing_key:
250
328
  specification_version: 4
251
329
  summary: Plugs in ActiveRecord so Dbee can use Arel for SQL generation.
252
330
  test_files:
253
331
  - spec/config/database.yaml.ci
254
332
  - spec/db_helper.rb
333
+ - spec/dbee/providers/active_record_provider/expression_builder_spec.rb
334
+ - spec/dbee/providers/active_record_provider/makers/where_spec.rb
255
335
  - spec/dbee/providers/active_record_provider_spec.rb
256
336
  - spec/fixtures/active_record_snapshots/five_table_query.yaml
257
337
  - spec/fixtures/active_record_snapshots/multiple_same_table_query_with_static_constraints.yaml
338
+ - spec/fixtures/active_record_snapshots/one_table_empty_query.yaml
258
339
  - spec/fixtures/active_record_snapshots/one_table_query.yaml
259
340
  - spec/fixtures/active_record_snapshots/one_table_query_with_ascending_sort.yaml
260
341
  - spec/fixtures/active_record_snapshots/one_table_query_with_descending_sort.yaml
data/.travis.yml DELETED
@@ -1,31 +0,0 @@
1
- env:
2
- global:
3
- - CC_TEST_REPORTER_ID=036a8fd92cf0c323c9704c041015837d14889e47de936bab18287626ff3372c1
4
- language: ruby
5
- services:
6
- - mysql
7
- rvm:
8
- # Build on the latest stable of all supported Rubies (https://www.ruby-lang.org/en/downloads/):
9
- - 2.5.8
10
- - 2.6.6
11
- - 2.7.1
12
- env:
13
- - AR_VERSION=5
14
- - AR_VERSION=6
15
- cache: bundler
16
- before_script:
17
- - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
18
- - chmod +x ./cc-test-reporter
19
- - ./cc-test-reporter before-build
20
- - cp spec/config/database.yaml.ci spec/config/database.yaml
21
- - mysql -e 'CREATE DATABASE IF NOT EXISTS dbee_test;'
22
- script:
23
- - bundle exec rubocop
24
- - bundle exec rspec spec --format documentation
25
- after_script:
26
- - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
27
- addons:
28
- # https://docs.travis-ci.com/user/uploading-artifacts/
29
- artifacts:
30
- paths:
31
- - Gemfile.lock