veritas-sql-generator 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/.gemtest +0 -0
- data/.rvmrc +1 -0
- data/.travis.yml +8 -0
- data/Gemfile +20 -10
- data/Guardfile +22 -0
- data/README.rdoc +2 -0
- data/Rakefile +4 -2
- data/TODO +16 -2
- data/config/flay.yml +2 -2
- data/config/flog.yml +1 -1
- data/config/roodi.yml +5 -5
- data/config/site.reek +21 -19
- data/lib/veritas/sql/generator.rb +25 -2
- data/lib/veritas/sql/generator/core_ext/date.rb +20 -0
- data/lib/veritas/sql/generator/core_ext/date_time.rb +45 -0
- data/lib/veritas/sql/generator/direction.rb +3 -1
- data/lib/veritas/sql/generator/function.rb +54 -0
- data/lib/veritas/sql/generator/function/aggregate.rb +134 -0
- data/lib/veritas/sql/generator/function/connective.rb +53 -0
- data/lib/veritas/sql/generator/function/numeric.rb +135 -0
- data/lib/veritas/sql/generator/function/predicate.rb +266 -0
- data/lib/veritas/sql/generator/function/proposition.rb +38 -0
- data/lib/veritas/sql/generator/function/string.rb +29 -0
- data/lib/veritas/sql/generator/identifier.rb +2 -1
- data/lib/veritas/sql/generator/literal.rb +15 -18
- data/lib/veritas/sql/generator/relation.rb +144 -17
- data/lib/veritas/sql/generator/relation/binary.rb +16 -64
- data/lib/veritas/sql/generator/relation/set.rb +30 -22
- data/lib/veritas/sql/generator/relation/unary.rb +131 -78
- data/lib/veritas/sql/generator/version.rb +1 -1
- data/spec/unit/date/iso8601_spec.rb +23 -0
- data/spec/unit/date_time/iso_8601_spec.rb +115 -0
- data/spec/unit/veritas/sql/generator/class_methods/parenthesize_spec.rb +18 -0
- data/spec/unit/veritas/sql/generator/function/aggregate/visit_veritas_aggregate_count_spec.rb +16 -0
- data/spec/unit/veritas/sql/generator/function/aggregate/visit_veritas_aggregate_maximum_spec.rb +16 -0
- data/spec/unit/veritas/sql/generator/function/aggregate/visit_veritas_aggregate_mean_spec.rb +16 -0
- data/spec/unit/veritas/sql/generator/function/aggregate/visit_veritas_aggregate_minimum_spec.rb +16 -0
- data/spec/unit/veritas/sql/generator/function/aggregate/visit_veritas_aggregate_standard_deviation_spec.rb +16 -0
- data/spec/unit/veritas/sql/generator/function/aggregate/visit_veritas_aggregate_sum_spec.rb +16 -0
- data/spec/unit/veritas/sql/generator/function/aggregate/visit_veritas_aggregate_variance_spec.rb +16 -0
- data/spec/unit/veritas/sql/generator/function/connective/visit_veritas_function_connective_conjunction_spec.rb +20 -0
- data/spec/unit/veritas/sql/generator/function/connective/visit_veritas_function_connective_disjunction_spec.rb +20 -0
- data/spec/unit/veritas/sql/generator/function/connective/visit_veritas_function_connective_negation_spec.rb +20 -0
- data/spec/unit/veritas/sql/generator/function/numeric/visit_veritas_function_numeric_absolute_spec.rb +15 -0
- data/spec/unit/veritas/sql/generator/function/numeric/visit_veritas_function_numeric_addition_spec.rb +15 -0
- data/spec/unit/veritas/sql/generator/function/numeric/visit_veritas_function_numeric_division_spec.rb +15 -0
- data/spec/unit/veritas/sql/generator/function/numeric/visit_veritas_function_numeric_exponentiation_spec.rb +15 -0
- data/spec/unit/veritas/sql/generator/function/numeric/visit_veritas_function_numeric_modulo_spec.rb +15 -0
- data/spec/unit/veritas/sql/generator/function/numeric/visit_veritas_function_numeric_multiplication_spec.rb +15 -0
- data/spec/unit/veritas/sql/generator/function/numeric/visit_veritas_function_numeric_square_root_spec.rb +15 -0
- data/spec/unit/veritas/sql/generator/function/numeric/visit_veritas_function_numeric_subtraction_spec.rb +15 -0
- data/spec/unit/veritas/sql/generator/function/numeric/visit_veritas_function_numeric_unary_minus_spec.rb +15 -0
- data/spec/unit/veritas/sql/generator/function/numeric/visit_veritas_function_numeric_unary_plus_spec.rb +15 -0
- data/spec/unit/veritas/sql/generator/{logic/visit_veritas_logic_predicate_equality_spec.rb → function/predicate/visit_veritas_function_predicate_equality_spec.rb} +5 -5
- data/spec/unit/veritas/sql/generator/{logic/visit_veritas_logic_predicate_exclusion_spec.rb → function/predicate/visit_veritas_function_predicate_exclusion_spec.rb} +10 -6
- data/spec/unit/veritas/sql/generator/function/predicate/visit_veritas_function_predicate_greater_than_or_equal_to_spec.rb +15 -0
- data/spec/unit/veritas/sql/generator/{logic/visit_veritas_logic_predicate_greater_than_spec.rb → function/predicate/visit_veritas_function_predicate_greater_than_spec.rb} +5 -5
- data/spec/unit/veritas/sql/generator/{logic/visit_veritas_logic_predicate_inclusion_spec.rb → function/predicate/visit_veritas_function_predicate_inclusion_spec.rb} +10 -6
- data/spec/unit/veritas/sql/generator/{logic/visit_veritas_logic_predicate_inequality_spec.rb → function/predicate/visit_veritas_function_predicate_inequality_spec.rb} +8 -8
- data/spec/unit/veritas/sql/generator/function/predicate/visit_veritas_function_predicate_less_than_or_equal_to_spec.rb +15 -0
- data/spec/unit/veritas/sql/generator/{logic/visit_veritas_logic_predicate_less_than_spec.rb → function/predicate/visit_veritas_function_predicate_less_than_spec.rb} +5 -5
- data/spec/unit/veritas/sql/generator/function/proposition/visit_veritas_function_proposition_contradiction_spec.rb +15 -0
- data/spec/unit/veritas/sql/generator/function/proposition/visit_veritas_function_proposition_tautology_spec.rb +15 -0
- data/spec/unit/veritas/sql/generator/function/string/visit_veritas_function_string_length_spec.rb +15 -0
- data/spec/unit/veritas/sql/generator/literal/class_methods/dup_frozen_spec.rb +2 -2
- data/spec/unit/veritas/sql/generator/relation/binary/base/to_subquery_spec.rb +1 -1
- data/spec/unit/veritas/sql/generator/relation/binary/base/{visit_veritas_base_relation_spec.rb → visit_veritas_relation_base_spec.rb} +3 -3
- data/spec/unit/veritas/sql/generator/relation/binary/to_s_spec.rb +2 -2
- data/spec/unit/veritas/sql/generator/relation/binary/to_subquery_spec.rb +2 -2
- data/spec/unit/veritas/sql/generator/relation/binary/visit_veritas_algebra_join_spec.rb +74 -33
- data/spec/unit/veritas/sql/generator/relation/binary/visit_veritas_algebra_product_spec.rb +63 -19
- data/spec/unit/veritas/sql/generator/relation/class_methods/visit_spec.rb +1 -1
- data/spec/unit/veritas/sql/generator/relation/set/class_methods/normalize_operand_headers_spec.rb +35 -0
- data/spec/unit/veritas/sql/generator/relation/set/to_s_spec.rb +1 -1
- data/spec/unit/veritas/sql/generator/relation/set/to_subquery_spec.rb +4 -4
- data/spec/unit/veritas/sql/generator/relation/set/visit_veritas_algebra_difference_spec.rb +83 -30
- data/spec/unit/veritas/sql/generator/relation/set/visit_veritas_algebra_intersection_spec.rb +80 -30
- data/spec/unit/veritas/sql/generator/relation/set/visit_veritas_algebra_union_spec.rb +80 -30
- data/spec/unit/veritas/sql/generator/relation/to_s_spec.rb +50 -0
- data/spec/unit/veritas/sql/generator/relation/to_subquery_spec.rb +49 -0
- data/spec/unit/veritas/sql/generator/relation/unary/to_s_spec.rb +1 -1
- data/spec/unit/veritas/sql/generator/relation/unary/to_subquery_spec.rb +6 -6
- data/spec/unit/veritas/sql/generator/relation/unary/visit_veritas_algebra_extension_spec.rb +165 -0
- data/spec/unit/veritas/sql/generator/relation/unary/visit_veritas_algebra_projection_spec.rb +84 -29
- data/spec/unit/veritas/sql/generator/relation/unary/visit_veritas_algebra_rename_spec.rb +69 -27
- data/spec/unit/veritas/sql/generator/relation/unary/visit_veritas_algebra_restriction_spec.rb +64 -22
- data/spec/unit/veritas/sql/generator/relation/unary/visit_veritas_algebra_summarization_spec.rb +652 -0
- data/spec/unit/veritas/sql/generator/relation/unary/{visit_veritas_base_relation_spec.rb → visit_veritas_relation_base_spec.rb} +4 -4
- data/spec/unit/veritas/sql/generator/relation/unary/visit_veritas_relation_operation_limit_spec.rb +60 -20
- data/spec/unit/veritas/sql/generator/relation/unary/visit_veritas_relation_operation_offset_spec.rb +60 -20
- data/spec/unit/veritas/sql/generator/relation/unary/visit_veritas_relation_operation_order_spec.rb +63 -23
- data/spec/unit/veritas/sql/generator/relation/unary/visit_veritas_relation_operation_reverse_spec.rb +60 -20
- data/spec/unit/veritas/sql/generator/relation/visited_spec.rb +1 -1
- data/tasks/metrics/ci.rake +7 -0
- data/tasks/{quality → metrics}/flay.rake +0 -0
- data/tasks/{quality → metrics}/flog.rake +0 -0
- data/tasks/{quality → metrics}/heckle.rake +1 -0
- data/tasks/{quality → metrics}/metric_fu.rake +3 -0
- data/tasks/{quality → metrics}/reek.rake +0 -0
- data/tasks/{quality → metrics}/roodi.rake +0 -0
- data/tasks/{quality → metrics}/yardstick.rake +0 -0
- data/tasks/spec.rake +1 -0
- data/veritas-sql-generator.gemspec +82 -114
- metadata +137 -125
- data/lib/veritas/base_relation.rb +0 -36
- data/lib/veritas/sql/generator/logic.rb +0 -349
- data/spec/unit/veritas/base_relation/name_spec.rb +0 -45
- data/spec/unit/veritas/sql/generator/logic/visit_veritas_logic_connective_conjunction_spec.rb +0 -16
- data/spec/unit/veritas/sql/generator/logic/visit_veritas_logic_connective_disjunction_spec.rb +0 -16
- data/spec/unit/veritas/sql/generator/logic/visit_veritas_logic_connective_negation_spec.rb +0 -16
- data/spec/unit/veritas/sql/generator/logic/visit_veritas_logic_predicate_greater_than_or_equal_to_spec.rb +0 -15
- data/spec/unit/veritas/sql/generator/logic/visit_veritas_logic_predicate_less_than_or_equal_to_spec.rb +0 -15
- data/spec/unit/veritas/sql/generator/logic/visit_veritas_logic_proposition_contradiction_spec.rb +0 -15
- data/spec/unit/veritas/sql/generator/logic/visit_veritas_logic_proposition_tautology_spec.rb +0 -15
- data/spec/unit/veritas/sql/generator/relation/binary/class_methods/subquery_spec.rb +0 -42
- data/spec/unit/veritas/sql/generator/relation/class_methods/subquery_spec.rb +0 -33
- data/tasks/quality/ci.rake +0 -2
metadata
CHANGED
@@ -1,8 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: veritas-sql-generator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 23
|
4
5
|
prerelease:
|
5
|
-
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 4
|
10
|
+
version: 0.0.4
|
6
11
|
platform: ruby
|
7
12
|
authors:
|
8
13
|
- Dan Kubb
|
@@ -10,74 +15,104 @@ autorequire:
|
|
10
15
|
bindir: bin
|
11
16
|
cert_chain: []
|
12
17
|
|
13
|
-
date: 2011-
|
18
|
+
date: 2011-06-01 00:00:00 Z
|
14
19
|
dependencies:
|
15
20
|
- !ruby/object:Gem::Dependency
|
16
|
-
|
17
|
-
|
21
|
+
type: :runtime
|
22
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
18
23
|
none: false
|
19
24
|
requirements:
|
20
25
|
- - "="
|
21
26
|
- !ruby/object:Gem::Version
|
22
|
-
|
23
|
-
|
27
|
+
hash: 23
|
28
|
+
segments:
|
29
|
+
- 0
|
30
|
+
- 0
|
31
|
+
- 4
|
32
|
+
version: 0.0.4
|
33
|
+
requirement: *id001
|
34
|
+
name: veritas
|
24
35
|
prerelease: false
|
25
|
-
version_requirements: *id001
|
26
36
|
- !ruby/object:Gem::Dependency
|
27
|
-
|
28
|
-
|
37
|
+
type: :development
|
38
|
+
version_requirements: &id002 !ruby/object:Gem::Requirement
|
29
39
|
none: false
|
30
40
|
requirements:
|
31
41
|
- - ~>
|
32
42
|
- !ruby/object:Gem::Version
|
33
|
-
|
34
|
-
|
43
|
+
hash: 5
|
44
|
+
segments:
|
45
|
+
- 2
|
46
|
+
- 2
|
47
|
+
- 1
|
48
|
+
version: 2.2.1
|
49
|
+
requirement: *id002
|
50
|
+
name: backports
|
35
51
|
prerelease: false
|
36
|
-
version_requirements: *id002
|
37
52
|
- !ruby/object:Gem::Dependency
|
38
|
-
|
39
|
-
|
53
|
+
type: :development
|
54
|
+
version_requirements: &id003 !ruby/object:Gem::Requirement
|
40
55
|
none: false
|
41
56
|
requirements:
|
42
57
|
- - ~>
|
43
58
|
- !ruby/object:Gem::Version
|
44
|
-
|
45
|
-
|
59
|
+
hash: 15
|
60
|
+
segments:
|
61
|
+
- 1
|
62
|
+
- 6
|
63
|
+
- 0
|
64
|
+
version: 1.6.0
|
65
|
+
requirement: *id003
|
66
|
+
name: jeweler
|
46
67
|
prerelease: false
|
47
|
-
version_requirements: *id003
|
48
68
|
- !ruby/object:Gem::Dependency
|
49
|
-
|
50
|
-
|
69
|
+
type: :development
|
70
|
+
version_requirements: &id004 !ruby/object:Gem::Requirement
|
51
71
|
none: false
|
52
72
|
requirements:
|
53
73
|
- - ~>
|
54
74
|
- !ruby/object:Gem::Version
|
55
|
-
|
56
|
-
|
75
|
+
hash: 59
|
76
|
+
segments:
|
77
|
+
- 0
|
78
|
+
- 9
|
79
|
+
- 0
|
80
|
+
version: 0.9.0
|
81
|
+
requirement: *id004
|
82
|
+
name: rake
|
57
83
|
prerelease: false
|
58
|
-
version_requirements: *id004
|
59
84
|
- !ruby/object:Gem::Dependency
|
60
|
-
|
61
|
-
|
85
|
+
type: :development
|
86
|
+
version_requirements: &id005 !ruby/object:Gem::Requirement
|
62
87
|
none: false
|
63
88
|
requirements:
|
64
89
|
- - ~>
|
65
90
|
- !ruby/object:Gem::Version
|
91
|
+
hash: 31
|
92
|
+
segments:
|
93
|
+
- 1
|
94
|
+
- 3
|
95
|
+
- 2
|
66
96
|
version: 1.3.2
|
67
|
-
|
97
|
+
requirement: *id005
|
98
|
+
name: rspec
|
68
99
|
prerelease: false
|
69
|
-
version_requirements: *id005
|
70
100
|
- !ruby/object:Gem::Dependency
|
71
|
-
|
72
|
-
|
101
|
+
type: :development
|
102
|
+
version_requirements: &id006 !ruby/object:Gem::Requirement
|
73
103
|
none: false
|
74
104
|
requirements:
|
75
105
|
- - ~>
|
76
106
|
- !ruby/object:Gem::Version
|
77
|
-
|
78
|
-
|
107
|
+
hash: 1
|
108
|
+
segments:
|
109
|
+
- 0
|
110
|
+
- 7
|
111
|
+
- 1
|
112
|
+
version: 0.7.1
|
113
|
+
requirement: *id006
|
114
|
+
name: yard
|
79
115
|
prerelease: false
|
80
|
-
version_requirements: *id006
|
81
116
|
description: Generate SQL from a veritas relation
|
82
117
|
email: dan.kubb@gmail.com
|
83
118
|
executables: []
|
@@ -89,7 +124,11 @@ extra_rdoc_files:
|
|
89
124
|
- README.rdoc
|
90
125
|
- TODO
|
91
126
|
files:
|
127
|
+
- .gemtest
|
128
|
+
- .rvmrc
|
129
|
+
- .travis.yml
|
92
130
|
- Gemfile
|
131
|
+
- Guardfile
|
93
132
|
- LICENSE
|
94
133
|
- README.rdoc
|
95
134
|
- Rakefile
|
@@ -100,13 +139,20 @@ files:
|
|
100
139
|
- config/site.reek
|
101
140
|
- config/yardstick.yml
|
102
141
|
- lib/veritas-sql-generator.rb
|
103
|
-
- lib/veritas/base_relation.rb
|
104
142
|
- lib/veritas/sql/generator.rb
|
105
143
|
- lib/veritas/sql/generator/attribute.rb
|
144
|
+
- lib/veritas/sql/generator/core_ext/date.rb
|
145
|
+
- lib/veritas/sql/generator/core_ext/date_time.rb
|
106
146
|
- lib/veritas/sql/generator/direction.rb
|
147
|
+
- lib/veritas/sql/generator/function.rb
|
148
|
+
- lib/veritas/sql/generator/function/aggregate.rb
|
149
|
+
- lib/veritas/sql/generator/function/connective.rb
|
150
|
+
- lib/veritas/sql/generator/function/numeric.rb
|
151
|
+
- lib/veritas/sql/generator/function/predicate.rb
|
152
|
+
- lib/veritas/sql/generator/function/proposition.rb
|
153
|
+
- lib/veritas/sql/generator/function/string.rb
|
107
154
|
- lib/veritas/sql/generator/identifier.rb
|
108
155
|
- lib/veritas/sql/generator/literal.rb
|
109
|
-
- lib/veritas/sql/generator/logic.rb
|
110
156
|
- lib/veritas/sql/generator/relation.rb
|
111
157
|
- lib/veritas/sql/generator/relation/base.rb
|
112
158
|
- lib/veritas/sql/generator/relation/binary.rb
|
@@ -120,10 +166,43 @@ files:
|
|
120
166
|
- spec/shared/idempotent_method_behavior.rb
|
121
167
|
- spec/spec.opts
|
122
168
|
- spec/spec_helper.rb
|
123
|
-
- spec/unit/
|
169
|
+
- spec/unit/date/iso8601_spec.rb
|
170
|
+
- spec/unit/date_time/iso_8601_spec.rb
|
124
171
|
- spec/unit/veritas/sql/generator/attribute/visit_veritas_attribute_spec.rb
|
172
|
+
- spec/unit/veritas/sql/generator/class_methods/parenthesize_spec.rb
|
125
173
|
- spec/unit/veritas/sql/generator/direction/visit_veritas_relation_operation_order_ascending_spec.rb
|
126
174
|
- spec/unit/veritas/sql/generator/direction/visit_veritas_relation_operation_order_descending_spec.rb
|
175
|
+
- spec/unit/veritas/sql/generator/function/aggregate/visit_veritas_aggregate_count_spec.rb
|
176
|
+
- spec/unit/veritas/sql/generator/function/aggregate/visit_veritas_aggregate_maximum_spec.rb
|
177
|
+
- spec/unit/veritas/sql/generator/function/aggregate/visit_veritas_aggregate_mean_spec.rb
|
178
|
+
- spec/unit/veritas/sql/generator/function/aggregate/visit_veritas_aggregate_minimum_spec.rb
|
179
|
+
- spec/unit/veritas/sql/generator/function/aggregate/visit_veritas_aggregate_standard_deviation_spec.rb
|
180
|
+
- spec/unit/veritas/sql/generator/function/aggregate/visit_veritas_aggregate_sum_spec.rb
|
181
|
+
- spec/unit/veritas/sql/generator/function/aggregate/visit_veritas_aggregate_variance_spec.rb
|
182
|
+
- spec/unit/veritas/sql/generator/function/connective/visit_veritas_function_connective_conjunction_spec.rb
|
183
|
+
- spec/unit/veritas/sql/generator/function/connective/visit_veritas_function_connective_disjunction_spec.rb
|
184
|
+
- spec/unit/veritas/sql/generator/function/connective/visit_veritas_function_connective_negation_spec.rb
|
185
|
+
- spec/unit/veritas/sql/generator/function/numeric/visit_veritas_function_numeric_absolute_spec.rb
|
186
|
+
- spec/unit/veritas/sql/generator/function/numeric/visit_veritas_function_numeric_addition_spec.rb
|
187
|
+
- spec/unit/veritas/sql/generator/function/numeric/visit_veritas_function_numeric_division_spec.rb
|
188
|
+
- spec/unit/veritas/sql/generator/function/numeric/visit_veritas_function_numeric_exponentiation_spec.rb
|
189
|
+
- spec/unit/veritas/sql/generator/function/numeric/visit_veritas_function_numeric_modulo_spec.rb
|
190
|
+
- spec/unit/veritas/sql/generator/function/numeric/visit_veritas_function_numeric_multiplication_spec.rb
|
191
|
+
- spec/unit/veritas/sql/generator/function/numeric/visit_veritas_function_numeric_square_root_spec.rb
|
192
|
+
- spec/unit/veritas/sql/generator/function/numeric/visit_veritas_function_numeric_subtraction_spec.rb
|
193
|
+
- spec/unit/veritas/sql/generator/function/numeric/visit_veritas_function_numeric_unary_minus_spec.rb
|
194
|
+
- spec/unit/veritas/sql/generator/function/numeric/visit_veritas_function_numeric_unary_plus_spec.rb
|
195
|
+
- spec/unit/veritas/sql/generator/function/predicate/visit_veritas_function_predicate_equality_spec.rb
|
196
|
+
- spec/unit/veritas/sql/generator/function/predicate/visit_veritas_function_predicate_exclusion_spec.rb
|
197
|
+
- spec/unit/veritas/sql/generator/function/predicate/visit_veritas_function_predicate_greater_than_or_equal_to_spec.rb
|
198
|
+
- spec/unit/veritas/sql/generator/function/predicate/visit_veritas_function_predicate_greater_than_spec.rb
|
199
|
+
- spec/unit/veritas/sql/generator/function/predicate/visit_veritas_function_predicate_inclusion_spec.rb
|
200
|
+
- spec/unit/veritas/sql/generator/function/predicate/visit_veritas_function_predicate_inequality_spec.rb
|
201
|
+
- spec/unit/veritas/sql/generator/function/predicate/visit_veritas_function_predicate_less_than_or_equal_to_spec.rb
|
202
|
+
- spec/unit/veritas/sql/generator/function/predicate/visit_veritas_function_predicate_less_than_spec.rb
|
203
|
+
- spec/unit/veritas/sql/generator/function/proposition/visit_veritas_function_proposition_contradiction_spec.rb
|
204
|
+
- spec/unit/veritas/sql/generator/function/proposition/visit_veritas_function_proposition_tautology_spec.rb
|
205
|
+
- spec/unit/veritas/sql/generator/function/string/visit_veritas_function_string_length_spec.rb
|
127
206
|
- spec/unit/veritas/sql/generator/identifier/visit_identifier_spec.rb
|
128
207
|
- spec/unit/veritas/sql/generator/literal/class_methods/dup_frozen_spec.rb
|
129
208
|
- spec/unit/veritas/sql/generator/literal/visit_class_spec.rb
|
@@ -136,41 +215,31 @@ files:
|
|
136
215
|
- spec/unit/veritas/sql/generator/literal/visit_string_spec.rb
|
137
216
|
- spec/unit/veritas/sql/generator/literal/visit_time_spec.rb
|
138
217
|
- spec/unit/veritas/sql/generator/literal/visit_true_class_spec.rb
|
139
|
-
- spec/unit/veritas/sql/generator/logic/visit_veritas_logic_connective_conjunction_spec.rb
|
140
|
-
- spec/unit/veritas/sql/generator/logic/visit_veritas_logic_connective_disjunction_spec.rb
|
141
|
-
- spec/unit/veritas/sql/generator/logic/visit_veritas_logic_connective_negation_spec.rb
|
142
|
-
- spec/unit/veritas/sql/generator/logic/visit_veritas_logic_predicate_equality_spec.rb
|
143
|
-
- spec/unit/veritas/sql/generator/logic/visit_veritas_logic_predicate_exclusion_spec.rb
|
144
|
-
- spec/unit/veritas/sql/generator/logic/visit_veritas_logic_predicate_greater_than_or_equal_to_spec.rb
|
145
|
-
- spec/unit/veritas/sql/generator/logic/visit_veritas_logic_predicate_greater_than_spec.rb
|
146
|
-
- spec/unit/veritas/sql/generator/logic/visit_veritas_logic_predicate_inclusion_spec.rb
|
147
|
-
- spec/unit/veritas/sql/generator/logic/visit_veritas_logic_predicate_inequality_spec.rb
|
148
|
-
- spec/unit/veritas/sql/generator/logic/visit_veritas_logic_predicate_less_than_or_equal_to_spec.rb
|
149
|
-
- spec/unit/veritas/sql/generator/logic/visit_veritas_logic_predicate_less_than_spec.rb
|
150
|
-
- spec/unit/veritas/sql/generator/logic/visit_veritas_logic_proposition_contradiction_spec.rb
|
151
|
-
- spec/unit/veritas/sql/generator/logic/visit_veritas_logic_proposition_tautology_spec.rb
|
152
218
|
- spec/unit/veritas/sql/generator/relation/binary/base/to_subquery_spec.rb
|
153
|
-
- spec/unit/veritas/sql/generator/relation/binary/base/
|
154
|
-
- spec/unit/veritas/sql/generator/relation/binary/class_methods/subquery_spec.rb
|
219
|
+
- spec/unit/veritas/sql/generator/relation/binary/base/visit_veritas_relation_base_spec.rb
|
155
220
|
- spec/unit/veritas/sql/generator/relation/binary/to_s_spec.rb
|
156
221
|
- spec/unit/veritas/sql/generator/relation/binary/to_subquery_spec.rb
|
157
222
|
- spec/unit/veritas/sql/generator/relation/binary/visit_veritas_algebra_join_spec.rb
|
158
223
|
- spec/unit/veritas/sql/generator/relation/binary/visit_veritas_algebra_product_spec.rb
|
159
|
-
- spec/unit/veritas/sql/generator/relation/class_methods/subquery_spec.rb
|
160
224
|
- spec/unit/veritas/sql/generator/relation/class_methods/visit_spec.rb
|
161
225
|
- spec/unit/veritas/sql/generator/relation/name_spec.rb
|
226
|
+
- spec/unit/veritas/sql/generator/relation/set/class_methods/normalize_operand_headers_spec.rb
|
162
227
|
- spec/unit/veritas/sql/generator/relation/set/to_s_spec.rb
|
163
228
|
- spec/unit/veritas/sql/generator/relation/set/to_subquery_spec.rb
|
164
229
|
- spec/unit/veritas/sql/generator/relation/set/visit_veritas_algebra_difference_spec.rb
|
165
230
|
- spec/unit/veritas/sql/generator/relation/set/visit_veritas_algebra_intersection_spec.rb
|
166
231
|
- spec/unit/veritas/sql/generator/relation/set/visit_veritas_algebra_union_spec.rb
|
232
|
+
- spec/unit/veritas/sql/generator/relation/to_s_spec.rb
|
167
233
|
- spec/unit/veritas/sql/generator/relation/to_sql_spec.rb
|
234
|
+
- spec/unit/veritas/sql/generator/relation/to_subquery_spec.rb
|
168
235
|
- spec/unit/veritas/sql/generator/relation/unary/to_s_spec.rb
|
169
236
|
- spec/unit/veritas/sql/generator/relation/unary/to_subquery_spec.rb
|
237
|
+
- spec/unit/veritas/sql/generator/relation/unary/visit_veritas_algebra_extension_spec.rb
|
170
238
|
- spec/unit/veritas/sql/generator/relation/unary/visit_veritas_algebra_projection_spec.rb
|
171
239
|
- spec/unit/veritas/sql/generator/relation/unary/visit_veritas_algebra_rename_spec.rb
|
172
240
|
- spec/unit/veritas/sql/generator/relation/unary/visit_veritas_algebra_restriction_spec.rb
|
173
|
-
- spec/unit/veritas/sql/generator/relation/unary/
|
241
|
+
- spec/unit/veritas/sql/generator/relation/unary/visit_veritas_algebra_summarization_spec.rb
|
242
|
+
- spec/unit/veritas/sql/generator/relation/unary/visit_veritas_relation_base_spec.rb
|
174
243
|
- spec/unit/veritas/sql/generator/relation/unary/visit_veritas_relation_operation_limit_spec.rb
|
175
244
|
- spec/unit/veritas/sql/generator/relation/unary/visit_veritas_relation_operation_offset_spec.rb
|
176
245
|
- spec/unit/veritas/sql/generator/relation/unary/visit_veritas_relation_operation_order_spec.rb
|
@@ -180,14 +249,14 @@ files:
|
|
180
249
|
- spec/unit/veritas/sql/generator/visitor/class_methods/handler_for_spec.rb
|
181
250
|
- spec/unit/veritas/sql/generator/visitor/visit_spec.rb
|
182
251
|
- spec/unit/veritas/sql/generator/visitor/visited_spec.rb
|
183
|
-
- tasks/
|
184
|
-
- tasks/
|
185
|
-
- tasks/
|
186
|
-
- tasks/
|
187
|
-
- tasks/
|
188
|
-
- tasks/
|
189
|
-
- tasks/
|
190
|
-
- tasks/
|
252
|
+
- tasks/metrics/ci.rake
|
253
|
+
- tasks/metrics/flay.rake
|
254
|
+
- tasks/metrics/flog.rake
|
255
|
+
- tasks/metrics/heckle.rake
|
256
|
+
- tasks/metrics/metric_fu.rake
|
257
|
+
- tasks/metrics/reek.rake
|
258
|
+
- tasks/metrics/roodi.rake
|
259
|
+
- tasks/metrics/yardstick.rake
|
191
260
|
- tasks/spec.rake
|
192
261
|
- tasks/yard.rake
|
193
262
|
- veritas-sql-generator.gemspec
|
@@ -204,82 +273,25 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
204
273
|
requirements:
|
205
274
|
- - ">="
|
206
275
|
- !ruby/object:Gem::Version
|
276
|
+
hash: 3
|
277
|
+
segments:
|
278
|
+
- 0
|
207
279
|
version: "0"
|
208
280
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
209
281
|
none: false
|
210
282
|
requirements:
|
211
283
|
- - ">="
|
212
284
|
- !ruby/object:Gem::Version
|
285
|
+
hash: 3
|
286
|
+
segments:
|
287
|
+
- 0
|
213
288
|
version: "0"
|
214
289
|
requirements: []
|
215
290
|
|
216
291
|
rubyforge_project:
|
217
|
-
rubygems_version: 1.
|
292
|
+
rubygems_version: 1.8.5
|
218
293
|
signing_key:
|
219
294
|
specification_version: 3
|
220
295
|
summary: Relational algebra SQL generator
|
221
|
-
test_files:
|
222
|
-
|
223
|
-
- spec/shared/generated_sql_behavior.rb
|
224
|
-
- spec/shared/idempotent_method_behavior.rb
|
225
|
-
- spec/spec_helper.rb
|
226
|
-
- spec/unit/veritas/base_relation/name_spec.rb
|
227
|
-
- spec/unit/veritas/sql/generator/attribute/visit_veritas_attribute_spec.rb
|
228
|
-
- spec/unit/veritas/sql/generator/direction/visit_veritas_relation_operation_order_ascending_spec.rb
|
229
|
-
- spec/unit/veritas/sql/generator/direction/visit_veritas_relation_operation_order_descending_spec.rb
|
230
|
-
- spec/unit/veritas/sql/generator/identifier/visit_identifier_spec.rb
|
231
|
-
- spec/unit/veritas/sql/generator/literal/class_methods/dup_frozen_spec.rb
|
232
|
-
- spec/unit/veritas/sql/generator/literal/visit_class_spec.rb
|
233
|
-
- spec/unit/veritas/sql/generator/literal/visit_date_spec.rb
|
234
|
-
- spec/unit/veritas/sql/generator/literal/visit_date_time_spec.rb
|
235
|
-
- spec/unit/veritas/sql/generator/literal/visit_enumerable_spec.rb
|
236
|
-
- spec/unit/veritas/sql/generator/literal/visit_false_class_spec.rb
|
237
|
-
- spec/unit/veritas/sql/generator/literal/visit_nil_class_spec.rb
|
238
|
-
- spec/unit/veritas/sql/generator/literal/visit_numeric_spec.rb
|
239
|
-
- spec/unit/veritas/sql/generator/literal/visit_string_spec.rb
|
240
|
-
- spec/unit/veritas/sql/generator/literal/visit_time_spec.rb
|
241
|
-
- spec/unit/veritas/sql/generator/literal/visit_true_class_spec.rb
|
242
|
-
- spec/unit/veritas/sql/generator/logic/visit_veritas_logic_connective_conjunction_spec.rb
|
243
|
-
- spec/unit/veritas/sql/generator/logic/visit_veritas_logic_connective_disjunction_spec.rb
|
244
|
-
- spec/unit/veritas/sql/generator/logic/visit_veritas_logic_connective_negation_spec.rb
|
245
|
-
- spec/unit/veritas/sql/generator/logic/visit_veritas_logic_predicate_equality_spec.rb
|
246
|
-
- spec/unit/veritas/sql/generator/logic/visit_veritas_logic_predicate_exclusion_spec.rb
|
247
|
-
- spec/unit/veritas/sql/generator/logic/visit_veritas_logic_predicate_greater_than_or_equal_to_spec.rb
|
248
|
-
- spec/unit/veritas/sql/generator/logic/visit_veritas_logic_predicate_greater_than_spec.rb
|
249
|
-
- spec/unit/veritas/sql/generator/logic/visit_veritas_logic_predicate_inclusion_spec.rb
|
250
|
-
- spec/unit/veritas/sql/generator/logic/visit_veritas_logic_predicate_inequality_spec.rb
|
251
|
-
- spec/unit/veritas/sql/generator/logic/visit_veritas_logic_predicate_less_than_or_equal_to_spec.rb
|
252
|
-
- spec/unit/veritas/sql/generator/logic/visit_veritas_logic_predicate_less_than_spec.rb
|
253
|
-
- spec/unit/veritas/sql/generator/logic/visit_veritas_logic_proposition_contradiction_spec.rb
|
254
|
-
- spec/unit/veritas/sql/generator/logic/visit_veritas_logic_proposition_tautology_spec.rb
|
255
|
-
- spec/unit/veritas/sql/generator/relation/binary/base/to_subquery_spec.rb
|
256
|
-
- spec/unit/veritas/sql/generator/relation/binary/base/visit_veritas_base_relation_spec.rb
|
257
|
-
- spec/unit/veritas/sql/generator/relation/binary/class_methods/subquery_spec.rb
|
258
|
-
- spec/unit/veritas/sql/generator/relation/binary/to_s_spec.rb
|
259
|
-
- spec/unit/veritas/sql/generator/relation/binary/to_subquery_spec.rb
|
260
|
-
- spec/unit/veritas/sql/generator/relation/binary/visit_veritas_algebra_join_spec.rb
|
261
|
-
- spec/unit/veritas/sql/generator/relation/binary/visit_veritas_algebra_product_spec.rb
|
262
|
-
- spec/unit/veritas/sql/generator/relation/class_methods/subquery_spec.rb
|
263
|
-
- spec/unit/veritas/sql/generator/relation/class_methods/visit_spec.rb
|
264
|
-
- spec/unit/veritas/sql/generator/relation/name_spec.rb
|
265
|
-
- spec/unit/veritas/sql/generator/relation/set/to_s_spec.rb
|
266
|
-
- spec/unit/veritas/sql/generator/relation/set/to_subquery_spec.rb
|
267
|
-
- spec/unit/veritas/sql/generator/relation/set/visit_veritas_algebra_difference_spec.rb
|
268
|
-
- spec/unit/veritas/sql/generator/relation/set/visit_veritas_algebra_intersection_spec.rb
|
269
|
-
- spec/unit/veritas/sql/generator/relation/set/visit_veritas_algebra_union_spec.rb
|
270
|
-
- spec/unit/veritas/sql/generator/relation/to_sql_spec.rb
|
271
|
-
- spec/unit/veritas/sql/generator/relation/unary/to_s_spec.rb
|
272
|
-
- spec/unit/veritas/sql/generator/relation/unary/to_subquery_spec.rb
|
273
|
-
- spec/unit/veritas/sql/generator/relation/unary/visit_veritas_algebra_projection_spec.rb
|
274
|
-
- spec/unit/veritas/sql/generator/relation/unary/visit_veritas_algebra_rename_spec.rb
|
275
|
-
- spec/unit/veritas/sql/generator/relation/unary/visit_veritas_algebra_restriction_spec.rb
|
276
|
-
- spec/unit/veritas/sql/generator/relation/unary/visit_veritas_base_relation_spec.rb
|
277
|
-
- spec/unit/veritas/sql/generator/relation/unary/visit_veritas_relation_operation_limit_spec.rb
|
278
|
-
- spec/unit/veritas/sql/generator/relation/unary/visit_veritas_relation_operation_offset_spec.rb
|
279
|
-
- spec/unit/veritas/sql/generator/relation/unary/visit_veritas_relation_operation_order_spec.rb
|
280
|
-
- spec/unit/veritas/sql/generator/relation/unary/visit_veritas_relation_operation_reverse_spec.rb
|
281
|
-
- spec/unit/veritas/sql/generator/relation/visit_spec.rb
|
282
|
-
- spec/unit/veritas/sql/generator/relation/visited_spec.rb
|
283
|
-
- spec/unit/veritas/sql/generator/visitor/class_methods/handler_for_spec.rb
|
284
|
-
- spec/unit/veritas/sql/generator/visitor/visit_spec.rb
|
285
|
-
- spec/unit/veritas/sql/generator/visitor/visited_spec.rb
|
296
|
+
test_files: []
|
297
|
+
|
@@ -1,36 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
module Veritas
|
4
|
-
|
5
|
-
# A class that represents a base relation in an RDBMS
|
6
|
-
class BaseRelation < Relation
|
7
|
-
|
8
|
-
# The base relation name
|
9
|
-
#
|
10
|
-
# @example
|
11
|
-
# name = base_relation.name
|
12
|
-
#
|
13
|
-
# @return [#to_s]
|
14
|
-
#
|
15
|
-
# @api public
|
16
|
-
attr_reader :name
|
17
|
-
|
18
|
-
# Initialize a base relation
|
19
|
-
#
|
20
|
-
# @param [#to_s] name
|
21
|
-
# the relation name
|
22
|
-
# @param [Header, #to_ary] header
|
23
|
-
# the relation header
|
24
|
-
# @param [Enumerable] tuples
|
25
|
-
# the relation tuples
|
26
|
-
#
|
27
|
-
# @return [undefined]
|
28
|
-
#
|
29
|
-
# @api private
|
30
|
-
def initialize(name, *args)
|
31
|
-
super(*args)
|
32
|
-
@name = Immutable.freeze_object(name.to_s)
|
33
|
-
end
|
34
|
-
|
35
|
-
end # class BaseRelation
|
36
|
-
end # module Veritas
|
@@ -1,349 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
module Veritas
|
4
|
-
module SQL
|
5
|
-
module Generator
|
6
|
-
|
7
|
-
# Generates an SQL statement for a logic expression
|
8
|
-
module Logic
|
9
|
-
include Attribute, Literal
|
10
|
-
|
11
|
-
EQUAL_TO = ' = '.freeze
|
12
|
-
EQUAL_TO_NULL = ' IS '.freeze
|
13
|
-
NOT_EQUAL_TO = ' <> '.freeze
|
14
|
-
NOT_EQUAL_TO_NULL = ' IS NOT '.freeze
|
15
|
-
GREATER_THAN = ' > '.freeze
|
16
|
-
GREATER_THAN_OR_EQUAL_TO = ' >= '.freeze
|
17
|
-
LESS_THAN = ' < '.freeze
|
18
|
-
LESS_THAN_OR_EQUAL_TO = ' <= '.freeze
|
19
|
-
IN = ' IN '.freeze
|
20
|
-
NOT_IN = ' NOT IN '.freeze
|
21
|
-
BETWEEN = ' BETWEEN '.freeze
|
22
|
-
NOT_BETWEEN = ' NOT BETWEEN '.freeze
|
23
|
-
AND = ' AND '.freeze
|
24
|
-
OR = ' OR '.freeze
|
25
|
-
MATCH_ALL = '1 = 1'.freeze
|
26
|
-
MATCH_NONE = '1 = 0'.freeze
|
27
|
-
EMPTY_ARRAY = [].freeze
|
28
|
-
|
29
|
-
# Visit an Equality predicate
|
30
|
-
#
|
31
|
-
# @param [Logic::Predicate::Equality] equality
|
32
|
-
#
|
33
|
-
# @return [#to_s]
|
34
|
-
#
|
35
|
-
# @api private
|
36
|
-
def visit_veritas_logic_predicate_equality(equality)
|
37
|
-
binary_operation_sql(equality.right.nil? ? EQUAL_TO_NULL : EQUAL_TO, equality)
|
38
|
-
end
|
39
|
-
|
40
|
-
# Visit an Inequality predicate
|
41
|
-
#
|
42
|
-
# @param [Logic::Predicate::Inequality] inequality
|
43
|
-
#
|
44
|
-
# @return [#to_s]
|
45
|
-
#
|
46
|
-
# @api private
|
47
|
-
def visit_veritas_logic_predicate_inequality(inequality)
|
48
|
-
expressions = inequality_expressions(inequality)
|
49
|
-
expressions.one? ? expressions.first : "(#{expressions.join(OR)})"
|
50
|
-
end
|
51
|
-
|
52
|
-
# Visit an GreaterThan predicate
|
53
|
-
#
|
54
|
-
# @param [Logic::Predicate::GreaterThan] greater_than
|
55
|
-
#
|
56
|
-
# @return [#to_s]
|
57
|
-
#
|
58
|
-
# @api private
|
59
|
-
def visit_veritas_logic_predicate_greater_than(greater_than)
|
60
|
-
binary_operation_sql(GREATER_THAN, greater_than)
|
61
|
-
end
|
62
|
-
|
63
|
-
# Visit an GreaterThanOrEqualTo predicate
|
64
|
-
#
|
65
|
-
# @param [Logic::Predicate::GreaterThanOrEqualTo] greater_than_or_equal_to
|
66
|
-
#
|
67
|
-
# @return [#to_s]
|
68
|
-
#
|
69
|
-
# @api private
|
70
|
-
def visit_veritas_logic_predicate_greater_than_or_equal_to(greater_than_or_equal_to)
|
71
|
-
binary_operation_sql(GREATER_THAN_OR_EQUAL_TO, greater_than_or_equal_to)
|
72
|
-
end
|
73
|
-
|
74
|
-
# Visit an LessThan predicate
|
75
|
-
#
|
76
|
-
# @param [Logic::Predicate::LessThan] less_than
|
77
|
-
#
|
78
|
-
# @return [#to_s]
|
79
|
-
#
|
80
|
-
# @api private
|
81
|
-
def visit_veritas_logic_predicate_less_than(less_than)
|
82
|
-
binary_operation_sql(LESS_THAN, less_than)
|
83
|
-
end
|
84
|
-
|
85
|
-
# Visit an LessThanOrEqualTo predicate
|
86
|
-
#
|
87
|
-
# @param [Logic::Predicate::LessThanOrEqualTo] less_than_or_equal_to
|
88
|
-
#
|
89
|
-
# @return [#to_s]
|
90
|
-
#
|
91
|
-
# @api private
|
92
|
-
def visit_veritas_logic_predicate_less_than_or_equal_to(less_than_or_equal_to)
|
93
|
-
binary_operation_sql(LESS_THAN_OR_EQUAL_TO, less_than_or_equal_to)
|
94
|
-
end
|
95
|
-
|
96
|
-
# Visit an Inclusion predicate
|
97
|
-
#
|
98
|
-
# @param [Logic::Predicate::Inclusion] inclusion
|
99
|
-
#
|
100
|
-
# @return [#to_s]
|
101
|
-
#
|
102
|
-
# @api private
|
103
|
-
def visit_veritas_logic_predicate_inclusion(inclusion)
|
104
|
-
case inclusion.right
|
105
|
-
when Range then range_inclusion_sql(inclusion)
|
106
|
-
when EMPTY_ARRAY then MATCH_NONE
|
107
|
-
else
|
108
|
-
binary_operation_sql(IN, inclusion)
|
109
|
-
end
|
110
|
-
end
|
111
|
-
|
112
|
-
# Visit an Exclusion predicate
|
113
|
-
#
|
114
|
-
# @param [Logic::Predicate::Exclusion] exclusion
|
115
|
-
#
|
116
|
-
# @return [#to_s]
|
117
|
-
#
|
118
|
-
# @api private
|
119
|
-
def visit_veritas_logic_predicate_exclusion(exclusion)
|
120
|
-
case exclusion.right
|
121
|
-
when Range then range_exclusion_sql(exclusion)
|
122
|
-
when EMPTY_ARRAY then MATCH_ALL
|
123
|
-
else
|
124
|
-
binary_operation_sql(NOT_IN, exclusion)
|
125
|
-
end
|
126
|
-
end
|
127
|
-
|
128
|
-
# Visit an Conjunction connective
|
129
|
-
#
|
130
|
-
# @param [Logic::Connective::Conjunction] conjunction
|
131
|
-
#
|
132
|
-
# @return [#to_s]
|
133
|
-
#
|
134
|
-
# @api private
|
135
|
-
def visit_veritas_logic_connective_conjunction(conjunction)
|
136
|
-
binary_connective_sql(AND, conjunction)
|
137
|
-
end
|
138
|
-
|
139
|
-
# Visit an Disjunction connective
|
140
|
-
#
|
141
|
-
# @param [Logic::Connective::Disjunction] disjunction
|
142
|
-
#
|
143
|
-
# @return [#to_s]
|
144
|
-
#
|
145
|
-
# @api private
|
146
|
-
def visit_veritas_logic_connective_disjunction(disjunction)
|
147
|
-
binary_connective_sql(OR, disjunction)
|
148
|
-
end
|
149
|
-
|
150
|
-
# Visit an Negation connective
|
151
|
-
#
|
152
|
-
# @param [Logic::Connective::Negation] negation
|
153
|
-
#
|
154
|
-
# @return [#to_s]
|
155
|
-
#
|
156
|
-
# @api private
|
157
|
-
def visit_veritas_logic_connective_negation(negation)
|
158
|
-
"NOT #{dispatch negation.operand}"
|
159
|
-
end
|
160
|
-
|
161
|
-
# Visit a Tautology
|
162
|
-
#
|
163
|
-
# @param [Logic::Proposition::Tautology] _tautology
|
164
|
-
#
|
165
|
-
# @return [#to_s]
|
166
|
-
#
|
167
|
-
# @api private
|
168
|
-
def visit_veritas_logic_proposition_tautology(_tautology)
|
169
|
-
MATCH_ALL
|
170
|
-
end
|
171
|
-
|
172
|
-
# Visit a Contradiction
|
173
|
-
#
|
174
|
-
# @param [Logic::Proposition::Contradiction] _contradiction
|
175
|
-
#
|
176
|
-
# @return [#to_s]
|
177
|
-
#
|
178
|
-
# @api private
|
179
|
-
def visit_veritas_logic_proposition_contradiction(_contradiction)
|
180
|
-
MATCH_NONE
|
181
|
-
end
|
182
|
-
|
183
|
-
private
|
184
|
-
|
185
|
-
# Return the SQL for an Inclusion using a Range
|
186
|
-
#
|
187
|
-
# @param [Logic::Predicate::Inclusion] predicate
|
188
|
-
#
|
189
|
-
# @return [#to_s]
|
190
|
-
#
|
191
|
-
# @api private
|
192
|
-
def range_inclusion_sql(inclusion)
|
193
|
-
if inclusion.right.exclude_end?
|
194
|
-
exclusive_range_inclusion_sql(inclusion)
|
195
|
-
else
|
196
|
-
inclusive_range_sql(BETWEEN, inclusion)
|
197
|
-
end
|
198
|
-
end
|
199
|
-
|
200
|
-
# Return the SQL for an Exclusion using a Range
|
201
|
-
#
|
202
|
-
# @param [Logic::Predicate::Exclusion] exclusion
|
203
|
-
#
|
204
|
-
# @return [#to_s]
|
205
|
-
#
|
206
|
-
# @api private
|
207
|
-
def range_exclusion_sql(exclusion)
|
208
|
-
if exclusion.right.exclude_end?
|
209
|
-
exclusive_range_exclusion_sql(exclusion)
|
210
|
-
else
|
211
|
-
inclusive_range_sql(NOT_BETWEEN, exclusion)
|
212
|
-
end
|
213
|
-
end
|
214
|
-
|
215
|
-
# Return the SQL for an Inclusion using an exclusive Range
|
216
|
-
#
|
217
|
-
# @param [Logic::Predicate::Inclusion] inclusion
|
218
|
-
#
|
219
|
-
# @return [#to_s]
|
220
|
-
#
|
221
|
-
# @api private
|
222
|
-
def exclusive_range_inclusion_sql(inclusion)
|
223
|
-
left = new_from_enumerable_predicate(Veritas::Logic::Predicate::GreaterThanOrEqualTo, inclusion, :first)
|
224
|
-
right = new_from_enumerable_predicate(Veritas::Logic::Predicate::LessThan, inclusion, :last)
|
225
|
-
dispatch left.and(right)
|
226
|
-
end
|
227
|
-
|
228
|
-
# Return the SQL for an Exclusion using an exclusive Range
|
229
|
-
#
|
230
|
-
# @param [Logic::Predicate::Exclusion] exclusion
|
231
|
-
#
|
232
|
-
# @return [#to_s]
|
233
|
-
#
|
234
|
-
# @api private
|
235
|
-
def exclusive_range_exclusion_sql(exclusion)
|
236
|
-
left = new_from_enumerable_predicate(Veritas::Logic::Predicate::LessThan, exclusion, :first)
|
237
|
-
right = new_from_enumerable_predicate(Veritas::Logic::Predicate::GreaterThanOrEqualTo, exclusion, :last)
|
238
|
-
dispatch left.or(right)
|
239
|
-
end
|
240
|
-
|
241
|
-
# Instantiate a new Predicate object from an Enumerable Predicate
|
242
|
-
#
|
243
|
-
# @param [Class<Logic::Predicate>] klass
|
244
|
-
# the type of predicate to create
|
245
|
-
# @param [Logic::Predicate::Enumerable] predicate
|
246
|
-
# the enumerable predicate
|
247
|
-
# @param [Symbol] method
|
248
|
-
# the method to call on the right operand of the predicate
|
249
|
-
# @return [Logic::Predicate]
|
250
|
-
#
|
251
|
-
# @api private
|
252
|
-
def new_from_enumerable_predicate(klass, predicate, method)
|
253
|
-
klass.new(predicate.left, predicate.right.send(method))
|
254
|
-
end
|
255
|
-
|
256
|
-
# Return the expressions for an inequality
|
257
|
-
#
|
258
|
-
# @param [Logic::Predicate::Inequality] inequality
|
259
|
-
#
|
260
|
-
# @return [Array<#to_s>]
|
261
|
-
#
|
262
|
-
# @api private
|
263
|
-
def inequality_expressions(inequality)
|
264
|
-
expressions = [
|
265
|
-
inequality_sql(inequality),
|
266
|
-
optional_is_null_sql(inequality.left),
|
267
|
-
optional_is_null_sql(inequality.right),
|
268
|
-
]
|
269
|
-
expressions.compact!
|
270
|
-
expressions
|
271
|
-
end
|
272
|
-
|
273
|
-
# Return the SQL for an inequality predicate
|
274
|
-
#
|
275
|
-
# @param [Logic::Predicate::Inequality] inequality
|
276
|
-
#
|
277
|
-
# @return [#to_s]
|
278
|
-
#
|
279
|
-
# @api private
|
280
|
-
def inequality_sql(inequality)
|
281
|
-
binary_operation_sql(inequality.right.nil? ? NOT_EQUAL_TO_NULL : NOT_EQUAL_TO, inequality)
|
282
|
-
end
|
283
|
-
|
284
|
-
# Return the SQL for a Binary Connective
|
285
|
-
#
|
286
|
-
# @param [#to_s] operator
|
287
|
-
#
|
288
|
-
# @param [Logic::Connective::Binary] binary_connective
|
289
|
-
#
|
290
|
-
# @return [#to_s]
|
291
|
-
#
|
292
|
-
# @api private
|
293
|
-
def binary_connective_sql(operator, binary_connective)
|
294
|
-
"(#{binary_operation_sql(operator, binary_connective)})"
|
295
|
-
end
|
296
|
-
|
297
|
-
# Return the SQL for a predicate
|
298
|
-
#
|
299
|
-
# @param [#to_s] operator
|
300
|
-
#
|
301
|
-
# @param [Logic::Predicate] predicate
|
302
|
-
#
|
303
|
-
# @return [#to_s]
|
304
|
-
#
|
305
|
-
# @api private
|
306
|
-
def binary_operation_sql(operator, predicate)
|
307
|
-
"#{dispatch(predicate.left)}#{operator}#{dispatch(predicate.right)}"
|
308
|
-
end
|
309
|
-
|
310
|
-
# Return the SQL for an operation using an inclusive Range
|
311
|
-
#
|
312
|
-
# @param [#to_s] operator
|
313
|
-
#
|
314
|
-
# @param [Logic::Predicate::Enumerable] predicate
|
315
|
-
#
|
316
|
-
# @return [#to_s]
|
317
|
-
#
|
318
|
-
# @api private
|
319
|
-
def inclusive_range_sql(operator, predicate)
|
320
|
-
right = predicate.right
|
321
|
-
"#{dispatch(predicate.left)}#{operator}#{dispatch(right.first)}#{AND}#{dispatch(right.last)}"
|
322
|
-
end
|
323
|
-
|
324
|
-
# Return SQL for an Equality with a nil value for optional attributes
|
325
|
-
#
|
326
|
-
# @param [Attribute] attribute
|
327
|
-
#
|
328
|
-
# @return [#to_sql, nil]
|
329
|
-
#
|
330
|
-
# @api private
|
331
|
-
def optional_is_null_sql(attribute)
|
332
|
-
dispatch(attribute.eq(nil)) if optional?(attribute)
|
333
|
-
end
|
334
|
-
|
335
|
-
# Test if the object is not required
|
336
|
-
#
|
337
|
-
# @param [Object] operand
|
338
|
-
#
|
339
|
-
# @return [Boolean]
|
340
|
-
#
|
341
|
-
# @api private
|
342
|
-
def optional?(operand)
|
343
|
-
operand.respond_to?(:required?) && !operand.required?
|
344
|
-
end
|
345
|
-
|
346
|
-
end # module Logic
|
347
|
-
end # module Generator
|
348
|
-
end # module SQL
|
349
|
-
end # module Veritas
|