olaf 0.1.2 → 0.2.0

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: 38457075dee68f9c3e32b378eee876418db09bee36922f8fca9e4f56ee4cc942
4
- data.tar.gz: c7dc384252160cdb65f5f0405cd575025a103924d65492df00baba336f40bce9
3
+ metadata.gz: 24eb5d8b71bc154b8992eed23b9763dc12fee835e8f5acdd8382aa7ac39242d0
4
+ data.tar.gz: 7949ac30157805f95507deba9f3190cb34dd35646eb161c99800344828d38b17
5
5
  SHA512:
6
- metadata.gz: 143444dd698a5780ce2524c65e3f6bcc068a6c2adcb6901369f8427f761f72a817e0601d75a59cfcc887507e842a73a69193c716f8d1369f9a0f296cee4635d3
7
- data.tar.gz: 1e13774b2cd3d361ae2847adb7ece1470f304cbc23141e2a57b098baf06677a025ce4e63afafdd99a744d5c8cf464939bb140ae2b813cf1da40f77bb4176ab85
6
+ metadata.gz: af792e74b54c3f674bfe40fe1ddbcf1e2870ce329434e6cbffe639ab7c2818be4945481162b0d7b38b2bae7415715cde352c2a6f51a5d2b3f0250bc8a276795d
7
+ data.tar.gz: 461661997ad0507dff54b36dd73688b46d2ab241236a79abecb7afc2394ab178f2d519cc761fae7e05dc10b6d78566a77bfd88955931df4476973441b5a51578
@@ -23,6 +23,12 @@ module Olaf
23
23
  end
24
24
  end
25
25
 
26
+ class UnknownArgumentsError < StandardError
27
+ def initialize(olaf_query)
28
+ super("Unknown arguments: #{olaf_query.unknown_arguments}")
29
+ end
30
+ end
31
+
26
32
  class QueryExecutionError < StandardError
27
33
  attr_reader :metadata
28
34
 
@@ -27,6 +27,7 @@ module Olaf
27
27
 
28
28
  raise UndefinedArgumentsError, self if undefined_arguments.any?
29
29
  raise MissingArgumentsError, self if missing_arguments.any?
30
+ raise UnknownArgumentsError, self if unknown_arguments.any?
30
31
 
31
32
  literal_arguments = self.class.arguments.select { |_k, v| v[:literal] }.keys
32
33
 
@@ -57,15 +58,21 @@ module Olaf
57
58
  defined_arguments - @variables.keys
58
59
  end
59
60
 
60
- # Find placeholders in the SQL file.
61
61
  # Every placeholder MUST be declared as an `argument` of the query.
62
62
  def undefined_arguments
63
- @sql_template
64
- .scan(/[^:]:(\w+)/)
65
- .flatten
66
- .map(&:to_sym)
67
- .then { |required_arguments| required_arguments - defined_arguments }
68
- .uniq
63
+ placeholders - defined_arguments
64
+ end
65
+
66
+ # Every `argument` declared in the query MUST have a placeholder in the SQL file.
67
+ def unknown_arguments
68
+ defined_arguments - placeholders
69
+ end
70
+
71
+ private
72
+
73
+ # Find placeholders in the SQL file.
74
+ def placeholders
75
+ @placeholders ||= @sql_template.scan(/[^:]:(\w+)/).flatten.map(&:to_sym).uniq
69
76
  end
70
77
  end
71
78
  end
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'olaf'
3
- s.version = '0.1.2'
3
+ s.version = '0.2.0'
4
4
  s.date = Time.now.strftime('%Y-%m-%d')
5
5
  s.summary = 'Ruby wrapper for Snowflake queries.'
6
6
  s.authors = ['Emiliano Mancuso']
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: olaf
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Emiliano Mancuso
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-10-26 00:00:00.000000000 Z
11
+ date: 2020-11-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sequel