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 +4 -4
- data/lib/olaf/errors.rb +6 -0
- data/lib/olaf/query_definition.rb +14 -7
- data/olaf.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 24eb5d8b71bc154b8992eed23b9763dc12fee835e8f5acdd8382aa7ac39242d0
|
4
|
+
data.tar.gz: 7949ac30157805f95507deba9f3190cb34dd35646eb161c99800344828d38b17
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: af792e74b54c3f674bfe40fe1ddbcf1e2870ce329434e6cbffe639ab7c2818be4945481162b0d7b38b2bae7415715cde352c2a6f51a5d2b3f0250bc8a276795d
|
7
|
+
data.tar.gz: 461661997ad0507dff54b36dd73688b46d2ab241236a79abecb7afc2394ab178f2d519cc761fae7e05dc10b6d78566a77bfd88955931df4476973441b5a51578
|
data/lib/olaf/errors.rb
CHANGED
@@ -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
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
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
|
data/olaf.gemspec
CHANGED
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.
|
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-
|
11
|
+
date: 2020-11-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sequel
|