dbee 2.1.0 → 2.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +16 -0
- data/dbee.gemspec +1 -1
- data/lib/dbee/query.rb +5 -17
- data/lib/dbee/version.rb +1 -1
- data/spec/dbee/query_spec.rb +0 -8
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b3c9c1444028bdfd5a4aa9eeb8c98055184f1b2cec2b819376e3f5344850d3b9
|
4
|
+
data.tar.gz: '059ac6adca29bae5a1eb0fc9f13247159047f1e8c82b3b31398d4492913ef595'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f67474cd84508029e3f3ca6e91ee2a1192b3cb1f8bf36f6b2d18a9c51e75ba3af897b01ea16676c6c79b000bd8d44d1381a7785fa56a9b81b906d47332e1c687
|
7
|
+
data.tar.gz: 6d6d061db4ef0c39cc1af32368d725c8354af5fc143a562f10e3beed7c3d260f7ddc93ab2aaff6016c483f370e9ccfec5e54c72dffcb8044c723025cb40dfdb5
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -363,6 +363,22 @@ You execute a Query against a Data Model, using a Provider. The sample provider
|
|
363
363
|
|
364
364
|
Here are some sample executions based off the preceding examples:
|
365
365
|
|
366
|
+
##### Base Case
|
367
|
+
|
368
|
+
If a query has no fields then it is implied you would like all fields on the root table. For example:
|
369
|
+
|
370
|
+
````ruby
|
371
|
+
require 'dbee/providers/active_record_provider'
|
372
|
+
|
373
|
+
class Practice < Dbee::Base; end
|
374
|
+
|
375
|
+
provider = Dbee::Providers::ActiveRecordProvider.new
|
376
|
+
query = {}
|
377
|
+
sql = Dbee.sql(Practice, query, provider)
|
378
|
+
````
|
379
|
+
|
380
|
+
It equivalent to saying: `SELECT practices.* FROM practices`. This helps to establish a deterministic base-case: it returns the same implicit columns that is independent of sql joins (sorters and/or filters may require sql joins.)
|
381
|
+
|
366
382
|
##### Code-First Execution
|
367
383
|
|
368
384
|
````ruby
|
data/dbee.gemspec
CHANGED
@@ -37,6 +37,6 @@ Gem::Specification.new do |s|
|
|
37
37
|
s.add_development_dependency('rake', '~> 13')
|
38
38
|
s.add_development_dependency('rspec')
|
39
39
|
s.add_development_dependency('rubocop', '~>0.88.0')
|
40
|
-
s.add_development_dependency('simplecov', '~>0.
|
40
|
+
s.add_development_dependency('simplecov', '~>0.18.5')
|
41
41
|
s.add_development_dependency('simplecov-console', '~>0.7.0')
|
42
42
|
end
|
data/lib/dbee/query.rb
CHANGED
@@ -21,37 +21,25 @@ module Dbee
|
|
21
21
|
extend Forwardable
|
22
22
|
acts_as_hashable
|
23
23
|
|
24
|
-
class NoFieldsError < StandardError; end
|
25
|
-
|
26
24
|
attr_reader :fields,
|
27
25
|
:filters,
|
28
|
-
:groupers,
|
29
26
|
:limit,
|
30
27
|
:sorters
|
31
28
|
|
32
29
|
def_delegator :fields, :sort, :sorted_fields
|
33
30
|
def_delegator :filters, :sort, :sorted_filters
|
34
31
|
def_delegator :sorters, :sort, :sorted_sorters
|
35
|
-
def_delegator :groupers, :sort, :sorted_groupers
|
36
32
|
|
37
33
|
def initialize(
|
38
|
-
fields
|
34
|
+
fields: [],
|
39
35
|
filters: [],
|
40
|
-
groupers: [],
|
41
36
|
limit: nil,
|
42
37
|
sorters: []
|
43
38
|
)
|
44
|
-
@fields
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
# have implications in downstream SQL generators.
|
49
|
-
raise NoFieldsError if @fields.empty?
|
50
|
-
|
51
|
-
@filters = Filters.array(filters).uniq
|
52
|
-
@groupers = Array(groupers).map { |k| KeyPath.get(k) }.uniq
|
53
|
-
@limit = limit.to_s.empty? ? nil : limit.to_i
|
54
|
-
@sorters = Sorters.array(sorters).uniq
|
39
|
+
@fields = Field.array(fields)
|
40
|
+
@filters = Filters.array(filters).uniq
|
41
|
+
@limit = limit.to_s.empty? ? nil : limit.to_i
|
42
|
+
@sorters = Sorters.array(sorters).uniq
|
55
43
|
|
56
44
|
freeze
|
57
45
|
end
|
data/lib/dbee/version.rb
CHANGED
data/spec/dbee/query_spec.rb
CHANGED
@@ -36,14 +36,6 @@ describe Dbee::Query do
|
|
36
36
|
end
|
37
37
|
|
38
38
|
describe '#initialize' do
|
39
|
-
it 'should raise an ArgumentError if fields keyword is missing' do
|
40
|
-
expect { described_class.new }.to raise_error(ArgumentError)
|
41
|
-
end
|
42
|
-
|
43
|
-
it 'should raise a NoFieldsError if no fields were passed in' do
|
44
|
-
expect { described_class.new(fields: []) }.to raise_error(Dbee::Query::NoFieldsError)
|
45
|
-
end
|
46
|
-
|
47
39
|
it 'should remove duplicate filters (keep first instance)' do
|
48
40
|
query_hash = {
|
49
41
|
fields: [
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dbee
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthew Ruggio
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-07-
|
11
|
+
date: 2020-07-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: acts_as_hashable
|
@@ -120,14 +120,14 @@ dependencies:
|
|
120
120
|
requirements:
|
121
121
|
- - "~>"
|
122
122
|
- !ruby/object:Gem::Version
|
123
|
-
version: 0.
|
123
|
+
version: 0.18.5
|
124
124
|
type: :development
|
125
125
|
prerelease: false
|
126
126
|
version_requirements: !ruby/object:Gem::Requirement
|
127
127
|
requirements:
|
128
128
|
- - "~>"
|
129
129
|
- !ruby/object:Gem::Version
|
130
|
-
version: 0.
|
130
|
+
version: 0.18.5
|
131
131
|
- !ruby/object:Gem::Dependency
|
132
132
|
name: simplecov-console
|
133
133
|
requirement: !ruby/object:Gem::Requirement
|