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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c8881fb69d8398471e0857f9b8e01a1452aaf6688a3a30aa38868b8254549e9c
4
- data.tar.gz: ca28fbd217d3a8c7daa2c41e5d9ea7d24173ab1b57c48467c9700c5b4871c01e
3
+ metadata.gz: b3c9c1444028bdfd5a4aa9eeb8c98055184f1b2cec2b819376e3f5344850d3b9
4
+ data.tar.gz: '059ac6adca29bae5a1eb0fc9f13247159047f1e8c82b3b31398d4492913ef595'
5
5
  SHA512:
6
- metadata.gz: b1cdd0b920c5ee6c02829eebe6e9d2851401eb996f2573f8524eba027de10102e9c706de9468cfeec503ec2ecf28cce525f2511ef0952c9204bf49462bd262be
7
- data.tar.gz: 6e6e2d772a318b8cc8960300b45ecb830bbde5973e567295eddff15f287ebf453e09df30de1d686d8a0ee157d590d4af0d48cd71e87012cc1d0606d952c2cac6
6
+ metadata.gz: f67474cd84508029e3f3ca6e91ee2a1192b3cb1f8bf36f6b2d18a9c51e75ba3af897b01ea16676c6c79b000bd8d44d1381a7785fa56a9b81b906d47332e1c687
7
+ data.tar.gz: 6d6d061db4ef0c39cc1af32368d725c8354af5fc143a562f10e3beed7c3d260f7ddc93ab2aaff6016c483f370e9ccfec5e54c72dffcb8044c723025cb40dfdb5
@@ -1,3 +1,7 @@
1
+ # 2.1.1 (July 14th, 2020)
2
+
3
+ * Removed guard that ensured a query has at least one field to establish a more rational base-case.
4
+
1
5
  # 2.1.0 (July 13th, 2020)
2
6
 
3
7
  ### Additions:
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
@@ -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.17.0')
40
+ s.add_development_dependency('simplecov', '~>0.18.5')
41
41
  s.add_development_dependency('simplecov-console', '~>0.7.0')
42
42
  end
@@ -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 = Field.array(fields)
45
-
46
- # If no fields were passed into a query then we will have no data to return.
47
- # Let's raise a hard error here and let the consumer deal with it since this may
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
@@ -8,5 +8,5 @@
8
8
  #
9
9
 
10
10
  module Dbee
11
- VERSION = '2.1.0'
11
+ VERSION = '2.1.1'
12
12
  end
@@ -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.0
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-13 00:00:00.000000000 Z
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.17.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.17.0
130
+ version: 0.18.5
131
131
  - !ruby/object:Gem::Dependency
132
132
  name: simplecov-console
133
133
  requirement: !ruby/object:Gem::Requirement