axiom-sql-generator 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gemtest +0 -0
- data/.gitignore +37 -0
- data/.rspec +4 -0
- data/.rvmrc +1 -0
- data/.travis.yml +35 -0
- data/CONTRIBUTING.md +11 -0
- data/Gemfile +8 -0
- data/Gemfile.devtools +57 -0
- data/Guardfile +23 -0
- data/LICENSE +20 -0
- data/README.md +70 -0
- data/Rakefile +5 -0
- data/TODO +34 -0
- data/axiom-sql-generator.gemspec +25 -0
- data/config/flay.yml +3 -0
- data/config/flog.yml +2 -0
- data/config/mutant.yml +3 -0
- data/config/reek.yml +165 -0
- data/config/yardstick.yml +2 -0
- data/lib/axiom-sql-generator.rb +3 -0
- data/lib/axiom/sql/generator.rb +61 -0
- data/lib/axiom/sql/generator/attribute.rb +25 -0
- data/lib/axiom/sql/generator/core_ext/date.rb +20 -0
- data/lib/axiom/sql/generator/core_ext/date_time.rb +46 -0
- data/lib/axiom/sql/generator/direction.rb +38 -0
- data/lib/axiom/sql/generator/function.rb +55 -0
- data/lib/axiom/sql/generator/function/aggregate.rb +134 -0
- data/lib/axiom/sql/generator/function/connective.rb +53 -0
- data/lib/axiom/sql/generator/function/numeric.rb +135 -0
- data/lib/axiom/sql/generator/function/predicate.rb +266 -0
- data/lib/axiom/sql/generator/function/proposition.rb +38 -0
- data/lib/axiom/sql/generator/function/string.rb +29 -0
- data/lib/axiom/sql/generator/identifier.rb +28 -0
- data/lib/axiom/sql/generator/literal.rb +157 -0
- data/lib/axiom/sql/generator/relation.rb +240 -0
- data/lib/axiom/sql/generator/relation/base.rb +14 -0
- data/lib/axiom/sql/generator/relation/binary.rb +136 -0
- data/lib/axiom/sql/generator/relation/insertion.rb +62 -0
- data/lib/axiom/sql/generator/relation/materialized.rb +60 -0
- data/lib/axiom/sql/generator/relation/set.rb +107 -0
- data/lib/axiom/sql/generator/relation/unary.rb +379 -0
- data/lib/axiom/sql/generator/version.rb +12 -0
- data/lib/axiom/sql/generator/visitor.rb +121 -0
- data/spec/rcov.opts +7 -0
- data/spec/shared/generated_sql_behavior.rb +15 -0
- data/spec/spec_helper.rb +33 -0
- data/spec/support/config_alias.rb +3 -0
- data/spec/unit/axiom/sql/generator/attribute/visit_axiom_attribute_spec.rb +15 -0
- data/spec/unit/axiom/sql/generator/class_methods/parenthesize_spec.rb +18 -0
- data/spec/unit/axiom/sql/generator/direction/visit_axiom_relation_operation_order_ascending_spec.rb +15 -0
- data/spec/unit/axiom/sql/generator/direction/visit_axiom_relation_operation_order_descending_spec.rb +15 -0
- data/spec/unit/axiom/sql/generator/function/aggregate/visit_axiom_aggregate_count_spec.rb +16 -0
- data/spec/unit/axiom/sql/generator/function/aggregate/visit_axiom_aggregate_maximum_spec.rb +16 -0
- data/spec/unit/axiom/sql/generator/function/aggregate/visit_axiom_aggregate_mean_spec.rb +16 -0
- data/spec/unit/axiom/sql/generator/function/aggregate/visit_axiom_aggregate_minimum_spec.rb +16 -0
- data/spec/unit/axiom/sql/generator/function/aggregate/visit_axiom_aggregate_standard_deviation_spec.rb +16 -0
- data/spec/unit/axiom/sql/generator/function/aggregate/visit_axiom_aggregate_sum_spec.rb +16 -0
- data/spec/unit/axiom/sql/generator/function/aggregate/visit_axiom_aggregate_variance_spec.rb +16 -0
- data/spec/unit/axiom/sql/generator/function/connective/visit_axiom_function_connective_conjunction_spec.rb +20 -0
- data/spec/unit/axiom/sql/generator/function/connective/visit_axiom_function_connective_disjunction_spec.rb +20 -0
- data/spec/unit/axiom/sql/generator/function/connective/visit_axiom_function_connective_negation_spec.rb +20 -0
- data/spec/unit/axiom/sql/generator/function/numeric/visit_axiom_function_numeric_absolute_spec.rb +15 -0
- data/spec/unit/axiom/sql/generator/function/numeric/visit_axiom_function_numeric_addition_spec.rb +15 -0
- data/spec/unit/axiom/sql/generator/function/numeric/visit_axiom_function_numeric_division_spec.rb +15 -0
- data/spec/unit/axiom/sql/generator/function/numeric/visit_axiom_function_numeric_exponentiation_spec.rb +15 -0
- data/spec/unit/axiom/sql/generator/function/numeric/visit_axiom_function_numeric_modulo_spec.rb +15 -0
- data/spec/unit/axiom/sql/generator/function/numeric/visit_axiom_function_numeric_multiplication_spec.rb +15 -0
- data/spec/unit/axiom/sql/generator/function/numeric/visit_axiom_function_numeric_square_root_spec.rb +15 -0
- data/spec/unit/axiom/sql/generator/function/numeric/visit_axiom_function_numeric_subtraction_spec.rb +15 -0
- data/spec/unit/axiom/sql/generator/function/numeric/visit_axiom_function_numeric_unary_minus_spec.rb +15 -0
- data/spec/unit/axiom/sql/generator/function/numeric/visit_axiom_function_numeric_unary_plus_spec.rb +15 -0
- data/spec/unit/axiom/sql/generator/function/predicate/visit_axiom_function_predicate_equality_spec.rb +27 -0
- data/spec/unit/axiom/sql/generator/function/predicate/visit_axiom_function_predicate_exclusion_spec.rb +47 -0
- data/spec/unit/axiom/sql/generator/function/predicate/visit_axiom_function_predicate_greater_than_or_equal_to_spec.rb +15 -0
- data/spec/unit/axiom/sql/generator/function/predicate/visit_axiom_function_predicate_greater_than_spec.rb +15 -0
- data/spec/unit/axiom/sql/generator/function/predicate/visit_axiom_function_predicate_inclusion_spec.rb +47 -0
- data/spec/unit/axiom/sql/generator/function/predicate/visit_axiom_function_predicate_inequality_spec.rb +55 -0
- data/spec/unit/axiom/sql/generator/function/predicate/visit_axiom_function_predicate_less_than_or_equal_to_spec.rb +15 -0
- data/spec/unit/axiom/sql/generator/function/predicate/visit_axiom_function_predicate_less_than_spec.rb +15 -0
- data/spec/unit/axiom/sql/generator/function/proposition/visit_axiom_function_proposition_contradiction_spec.rb +15 -0
- data/spec/unit/axiom/sql/generator/function/proposition/visit_axiom_function_proposition_tautology_spec.rb +15 -0
- data/spec/unit/axiom/sql/generator/function/string/visit_axiom_function_string_length_spec.rb +15 -0
- data/spec/unit/axiom/sql/generator/identifier/visit_identifier_spec.rb +26 -0
- data/spec/unit/axiom/sql/generator/literal/class_methods/dup_frozen_spec.rb +23 -0
- data/spec/unit/axiom/sql/generator/literal/visit_class_spec.rb +31 -0
- data/spec/unit/axiom/sql/generator/literal/visit_date_spec.rb +15 -0
- data/spec/unit/axiom/sql/generator/literal/visit_date_time_spec.rb +55 -0
- data/spec/unit/axiom/sql/generator/literal/visit_enumerable_spec.rb +15 -0
- data/spec/unit/axiom/sql/generator/literal/visit_false_class_spec.rb +14 -0
- data/spec/unit/axiom/sql/generator/literal/visit_nil_class_spec.rb +14 -0
- data/spec/unit/axiom/sql/generator/literal/visit_numeric_spec.rb +34 -0
- data/spec/unit/axiom/sql/generator/literal/visit_string_spec.rb +26 -0
- data/spec/unit/axiom/sql/generator/literal/visit_time_spec.rb +97 -0
- data/spec/unit/axiom/sql/generator/literal/visit_true_class_spec.rb +14 -0
- data/spec/unit/axiom/sql/generator/relation/binary/base/to_subquery_spec.rb +35 -0
- data/spec/unit/axiom/sql/generator/relation/binary/base/visit_axiom_relation_base_spec.rb +22 -0
- data/spec/unit/axiom/sql/generator/relation/binary/to_s_spec.rb +35 -0
- data/spec/unit/axiom/sql/generator/relation/binary/to_subquery_spec.rb +35 -0
- data/spec/unit/axiom/sql/generator/relation/binary/visit_axiom_algebra_join_spec.rb +179 -0
- data/spec/unit/axiom/sql/generator/relation/binary/visit_axiom_algebra_product_spec.rb +183 -0
- data/spec/unit/axiom/sql/generator/relation/class_methods/visit_spec.rb +71 -0
- data/spec/unit/axiom/sql/generator/relation/insertion/to_subquery_spec.rb +15 -0
- data/spec/unit/axiom/sql/generator/relation/insertion/visit_axiom_relation_operation_insertion_spec.rb +187 -0
- data/spec/unit/axiom/sql/generator/relation/materialized/visit_axiom_relation_materialized_spec.rb +28 -0
- data/spec/unit/axiom/sql/generator/relation/materialized/visited_spec.rb +26 -0
- data/spec/unit/axiom/sql/generator/relation/name_spec.rb +30 -0
- data/spec/unit/axiom/sql/generator/relation/set/class_methods/normalize_operand_headers_spec.rb +35 -0
- data/spec/unit/axiom/sql/generator/relation/set/to_s_spec.rb +55 -0
- data/spec/unit/axiom/sql/generator/relation/set/to_subquery_spec.rb +55 -0
- data/spec/unit/axiom/sql/generator/relation/set/visit_axiom_algebra_difference_spec.rb +191 -0
- data/spec/unit/axiom/sql/generator/relation/set/visit_axiom_algebra_intersection_spec.rb +188 -0
- data/spec/unit/axiom/sql/generator/relation/set/visit_axiom_algebra_union_spec.rb +188 -0
- data/spec/unit/axiom/sql/generator/relation/to_s_spec.rb +50 -0
- data/spec/unit/axiom/sql/generator/relation/to_sql_spec.rb +52 -0
- data/spec/unit/axiom/sql/generator/relation/to_subquery_spec.rb +49 -0
- data/spec/unit/axiom/sql/generator/relation/unary/to_s_spec.rb +55 -0
- data/spec/unit/axiom/sql/generator/relation/unary/to_subquery_spec.rb +75 -0
- data/spec/unit/axiom/sql/generator/relation/unary/visit_axiom_algebra_extension_spec.rb +165 -0
- data/spec/unit/axiom/sql/generator/relation/unary/visit_axiom_algebra_projection_spec.rb +193 -0
- data/spec/unit/axiom/sql/generator/relation/unary/visit_axiom_algebra_rename_spec.rb +178 -0
- data/spec/unit/axiom/sql/generator/relation/unary/visit_axiom_algebra_restriction_spec.rb +199 -0
- data/spec/unit/axiom/sql/generator/relation/unary/visit_axiom_algebra_summarization_spec.rb +652 -0
- data/spec/unit/axiom/sql/generator/relation/unary/visit_axiom_relation_base_spec.rb +21 -0
- data/spec/unit/axiom/sql/generator/relation/unary/visit_axiom_relation_operation_limit_spec.rb +165 -0
- data/spec/unit/axiom/sql/generator/relation/unary/visit_axiom_relation_operation_offset_spec.rb +165 -0
- data/spec/unit/axiom/sql/generator/relation/unary/visit_axiom_relation_operation_order_spec.rb +183 -0
- data/spec/unit/axiom/sql/generator/relation/unary/visit_axiom_relation_operation_reverse_spec.rb +165 -0
- data/spec/unit/axiom/sql/generator/relation/visit_spec.rb +54 -0
- data/spec/unit/axiom/sql/generator/relation/visited_spec.rb +35 -0
- data/spec/unit/axiom/sql/generator/visitor/class_methods/handler_for_spec.rb +71 -0
- data/spec/unit/axiom/sql/generator/visitor/visit_spec.rb +12 -0
- data/spec/unit/axiom/sql/generator/visitor/visited_spec.rb +11 -0
- data/spec/unit/date/iso8601_spec.rb +23 -0
- data/spec/unit/date_time/iso8601_spec.rb +112 -0
- metadata +325 -0
data/spec/unit/axiom/sql/generator/function/numeric/visit_axiom_function_numeric_absolute_spec.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe SQL::Generator::Function::Numeric, '#visit_axiom_function_numeric_absolute' do
|
6
|
+
subject { object.visit_axiom_function_numeric_absolute(absolute) }
|
7
|
+
|
8
|
+
let(:described_class) { Class.new(SQL::Generator::Visitor) { include SQL::Generator::Function::Numeric } }
|
9
|
+
let(:absolute) { Attribute::Integer.new(:number).abs }
|
10
|
+
let(:object) { described_class.new }
|
11
|
+
|
12
|
+
it_should_behave_like 'a generated SQL expression'
|
13
|
+
|
14
|
+
its(:to_s) { should eql('ABS ("number")') }
|
15
|
+
end
|
data/spec/unit/axiom/sql/generator/function/numeric/visit_axiom_function_numeric_addition_spec.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe SQL::Generator::Function::Numeric, '#visit_axiom_function_numeric_addition' do
|
6
|
+
subject { object.visit_axiom_function_numeric_addition(addition) }
|
7
|
+
|
8
|
+
let(:described_class) { Class.new(SQL::Generator::Visitor) { include SQL::Generator::Function::Numeric } }
|
9
|
+
let(:addition) { Attribute::Integer.new(:number).add(1) }
|
10
|
+
let(:object) { described_class.new }
|
11
|
+
|
12
|
+
it_should_behave_like 'a generated SQL expression'
|
13
|
+
|
14
|
+
its(:to_s) { should eql('("number" + 1)') }
|
15
|
+
end
|
data/spec/unit/axiom/sql/generator/function/numeric/visit_axiom_function_numeric_division_spec.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe SQL::Generator::Function::Numeric, '#visit_axiom_function_numeric_division' do
|
6
|
+
subject { object.visit_axiom_function_numeric_division(division) }
|
7
|
+
|
8
|
+
let(:described_class) { Class.new(SQL::Generator::Visitor) { include SQL::Generator::Function::Numeric } }
|
9
|
+
let(:division) { Attribute::Integer.new(:number).divide(1) }
|
10
|
+
let(:object) { described_class.new }
|
11
|
+
|
12
|
+
it_should_behave_like 'a generated SQL expression'
|
13
|
+
|
14
|
+
its(:to_s) { should eql('("number" / 1)') }
|
15
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe SQL::Generator::Function::Numeric, '#visit_axiom_function_numeric_exponentiation' do
|
6
|
+
subject { object.visit_axiom_function_numeric_exponentiation(exponentiation) }
|
7
|
+
|
8
|
+
let(:described_class) { Class.new(SQL::Generator::Visitor) { include SQL::Generator::Function::Numeric } }
|
9
|
+
let(:exponentiation) { Attribute::Integer.new(:number).exponent(1) }
|
10
|
+
let(:object) { described_class.new }
|
11
|
+
|
12
|
+
it_should_behave_like 'a generated SQL expression'
|
13
|
+
|
14
|
+
its(:to_s) { should eql('POWER ("number", 1)') }
|
15
|
+
end
|
data/spec/unit/axiom/sql/generator/function/numeric/visit_axiom_function_numeric_modulo_spec.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe SQL::Generator::Function::Numeric, '#visit_axiom_function_numeric_modulo' do
|
6
|
+
subject { object.visit_axiom_function_numeric_modulo(modulo) }
|
7
|
+
|
8
|
+
let(:described_class) { Class.new(SQL::Generator::Visitor) { include SQL::Generator::Function::Numeric } }
|
9
|
+
let(:modulo) { Attribute::Integer.new(:number).modulo(1) }
|
10
|
+
let(:object) { described_class.new }
|
11
|
+
|
12
|
+
it_should_behave_like 'a generated SQL expression'
|
13
|
+
|
14
|
+
its(:to_s) { should eql('MOD ("number", 1)') }
|
15
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe SQL::Generator::Function::Numeric, '#visit_axiom_function_numeric_multiplication' do
|
6
|
+
subject { object.visit_axiom_function_numeric_multiplication(multiplication) }
|
7
|
+
|
8
|
+
let(:described_class) { Class.new(SQL::Generator::Visitor) { include SQL::Generator::Function::Numeric } }
|
9
|
+
let(:multiplication) { Attribute::Integer.new(:number).multiply(1) }
|
10
|
+
let(:object) { described_class.new }
|
11
|
+
|
12
|
+
it_should_behave_like 'a generated SQL expression'
|
13
|
+
|
14
|
+
its(:to_s) { should eql('("number" * 1)') }
|
15
|
+
end
|
data/spec/unit/axiom/sql/generator/function/numeric/visit_axiom_function_numeric_square_root_spec.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe SQL::Generator::Function::Numeric, '#visit_axiom_function_numeric_square_root' do
|
6
|
+
subject { object.visit_axiom_function_numeric_square_root(square_root) }
|
7
|
+
|
8
|
+
let(:described_class) { Class.new(SQL::Generator::Visitor) { include SQL::Generator::Function::Numeric } }
|
9
|
+
let(:square_root) { Attribute::Integer.new(:number).square_root }
|
10
|
+
let(:object) { described_class.new }
|
11
|
+
|
12
|
+
it_should_behave_like 'a generated SQL expression'
|
13
|
+
|
14
|
+
its(:to_s) { should eql('SQRT ("number")') }
|
15
|
+
end
|
data/spec/unit/axiom/sql/generator/function/numeric/visit_axiom_function_numeric_subtraction_spec.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe SQL::Generator::Function::Numeric, '#visit_axiom_function_numeric_subtraction' do
|
6
|
+
subject { object.visit_axiom_function_numeric_subtraction(subtraction) }
|
7
|
+
|
8
|
+
let(:described_class) { Class.new(SQL::Generator::Visitor) { include SQL::Generator::Function::Numeric } }
|
9
|
+
let(:subtraction) { Attribute::Integer.new(:number).subtract(1) }
|
10
|
+
let(:object) { described_class.new }
|
11
|
+
|
12
|
+
it_should_behave_like 'a generated SQL expression'
|
13
|
+
|
14
|
+
its(:to_s) { should eql('("number" - 1)') }
|
15
|
+
end
|
data/spec/unit/axiom/sql/generator/function/numeric/visit_axiom_function_numeric_unary_minus_spec.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe SQL::Generator::Function::Numeric, '#visit_axiom_function_numeric_unary_minus' do
|
6
|
+
subject { object.visit_axiom_function_numeric_unary_minus(unary_minus) }
|
7
|
+
|
8
|
+
let(:described_class) { Class.new(SQL::Generator::Visitor) { include SQL::Generator::Function::Numeric } }
|
9
|
+
let(:unary_minus) { Attribute::Integer.new(:number).unary_minus }
|
10
|
+
let(:object) { described_class.new }
|
11
|
+
|
12
|
+
it_should_behave_like 'a generated SQL expression'
|
13
|
+
|
14
|
+
its(:to_s) { should eql('- ("number")') }
|
15
|
+
end
|
data/spec/unit/axiom/sql/generator/function/numeric/visit_axiom_function_numeric_unary_plus_spec.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe SQL::Generator::Function::Numeric, '#visit_axiom_function_numeric_unary_plus' do
|
6
|
+
subject { object.visit_axiom_function_numeric_unary_plus(unary_plus) }
|
7
|
+
|
8
|
+
let(:described_class) { Class.new(SQL::Generator::Visitor) { include SQL::Generator::Function::Numeric } }
|
9
|
+
let(:unary_plus) { Attribute::Integer.new(:number).unary_plus }
|
10
|
+
let(:object) { described_class.new }
|
11
|
+
|
12
|
+
it_should_behave_like 'a generated SQL expression'
|
13
|
+
|
14
|
+
its(:to_s) { should eql('+ ("number")') }
|
15
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe SQL::Generator::Function::Predicate, '#visit_axiom_function_predicate_equality' do
|
6
|
+
subject { object.visit_axiom_function_predicate_equality(equality) }
|
7
|
+
|
8
|
+
let(:described_class) { Class.new(SQL::Generator::Visitor) { include SQL::Generator::Function::Predicate } }
|
9
|
+
let(:attribute) { Attribute::Integer.new(:id) }
|
10
|
+
let(:object) { described_class.new }
|
11
|
+
|
12
|
+
context 'when the right operand is not nil' do
|
13
|
+
let(:equality) { attribute.eq(1) }
|
14
|
+
|
15
|
+
it_should_behave_like 'a generated SQL expression'
|
16
|
+
|
17
|
+
its(:to_s) { should eql('"id" = 1') }
|
18
|
+
end
|
19
|
+
|
20
|
+
context 'when the right operand is nil' do
|
21
|
+
let(:equality) { attribute.eq(nil) }
|
22
|
+
|
23
|
+
it_should_behave_like 'a generated SQL expression'
|
24
|
+
|
25
|
+
its(:to_s) { should eql('"id" IS NULL') }
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe SQL::Generator::Function::Predicate, '#visit_axiom_function_predicate_exclusion' do
|
6
|
+
subject { object.visit_axiom_function_predicate_exclusion(exclusion) }
|
7
|
+
|
8
|
+
let(:described_class) { Class.new(SQL::Generator::Visitor) { include SQL::Generator::Function::Predicate } }
|
9
|
+
let(:attribute) { Attribute::Integer.new(:id) }
|
10
|
+
let(:object) { described_class.new }
|
11
|
+
|
12
|
+
before do
|
13
|
+
described_class.class_eval { include SQL::Generator::Function::Connective }
|
14
|
+
end
|
15
|
+
|
16
|
+
context 'when right operand is an inclusive Range' do
|
17
|
+
let(:exclusion) { attribute.exclude(1..10) }
|
18
|
+
|
19
|
+
it_should_behave_like 'a generated SQL expression'
|
20
|
+
|
21
|
+
its(:to_s) { should eql('"id" NOT BETWEEN 1 AND 10') }
|
22
|
+
end
|
23
|
+
|
24
|
+
context 'when right operand is an exclusive Range' do
|
25
|
+
let(:exclusion) { attribute.exclude(1...10) }
|
26
|
+
|
27
|
+
it_should_behave_like 'a generated SQL expression'
|
28
|
+
|
29
|
+
its(:to_s) { should eql('("id" < 1 OR "id" >= 10)') }
|
30
|
+
end
|
31
|
+
|
32
|
+
context 'when right operand is an Array' do
|
33
|
+
let(:exclusion) { attribute.exclude([ 1, 2 ]) }
|
34
|
+
|
35
|
+
it_should_behave_like 'a generated SQL expression'
|
36
|
+
|
37
|
+
its(:to_s) { should eql('"id" NOT IN (1, 2)') }
|
38
|
+
end
|
39
|
+
|
40
|
+
context 'when right operand is an empty Array' do
|
41
|
+
let(:exclusion) { attribute.exclude([]) }
|
42
|
+
|
43
|
+
it_should_behave_like 'a generated SQL expression'
|
44
|
+
|
45
|
+
its(:to_s) { should eql('TRUE') }
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe SQL::Generator::Function::Predicate, '#visit_axiom_function_predicate_greater_than_or_equal_to' do
|
6
|
+
subject { object.visit_axiom_function_predicate_greater_than_or_equal_to(greater_than_or_equal_to) }
|
7
|
+
|
8
|
+
let(:described_class) { Class.new(SQL::Generator::Visitor) { include SQL::Generator::Function::Predicate } }
|
9
|
+
let(:greater_than_or_equal_to) { Attribute::Integer.new(:id).gte(1) }
|
10
|
+
let(:object) { described_class.new }
|
11
|
+
|
12
|
+
it_should_behave_like 'a generated SQL expression'
|
13
|
+
|
14
|
+
its(:to_s) { should eql('"id" >= 1') }
|
15
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe SQL::Generator::Function::Predicate, '#visit_axiom_function_predicate_greater_than' do
|
6
|
+
subject { object.visit_axiom_function_predicate_greater_than(greater_than) }
|
7
|
+
|
8
|
+
let(:described_class) { Class.new(SQL::Generator::Visitor) { include SQL::Generator::Function::Predicate } }
|
9
|
+
let(:greater_than) { Attribute::Integer.new(:id).gt(1) }
|
10
|
+
let(:object) { described_class.new }
|
11
|
+
|
12
|
+
it_should_behave_like 'a generated SQL expression'
|
13
|
+
|
14
|
+
its(:to_s) { should eql('"id" > 1') }
|
15
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe SQL::Generator::Function::Predicate, '#visit_axiom_function_predicate_inclusion' do
|
6
|
+
subject { object.visit_axiom_function_predicate_inclusion(inclusion) }
|
7
|
+
|
8
|
+
let(:described_class) { Class.new(SQL::Generator::Visitor) { include SQL::Generator::Function::Predicate } }
|
9
|
+
let(:attribute) { Attribute::Integer.new(:id) }
|
10
|
+
let(:object) { described_class.new }
|
11
|
+
|
12
|
+
before do
|
13
|
+
described_class.class_eval { include SQL::Generator::Function::Connective }
|
14
|
+
end
|
15
|
+
|
16
|
+
context 'when right operand is an inclusive Range' do
|
17
|
+
let(:inclusion) { attribute.include(1..10) }
|
18
|
+
|
19
|
+
it_should_behave_like 'a generated SQL expression'
|
20
|
+
|
21
|
+
its(:to_s) { should eql('"id" BETWEEN 1 AND 10') }
|
22
|
+
end
|
23
|
+
|
24
|
+
context 'when right operand is an exclusive Range' do
|
25
|
+
let(:inclusion) { attribute.include(1...10) }
|
26
|
+
|
27
|
+
it_should_behave_like 'a generated SQL expression'
|
28
|
+
|
29
|
+
its(:to_s) { should eql('("id" >= 1 AND "id" < 10)') }
|
30
|
+
end
|
31
|
+
|
32
|
+
context 'when right operand is an Array' do
|
33
|
+
let(:inclusion) { attribute.include([ 1, 2 ]) }
|
34
|
+
|
35
|
+
it_should_behave_like 'a generated SQL expression'
|
36
|
+
|
37
|
+
its(:to_s) { should eql('"id" IN (1, 2)') }
|
38
|
+
end
|
39
|
+
|
40
|
+
context 'when right operand is an empty Array' do
|
41
|
+
let(:inclusion) { attribute.include([]) }
|
42
|
+
|
43
|
+
it_should_behave_like 'a generated SQL expression'
|
44
|
+
|
45
|
+
its(:to_s) { should eql('FALSE') }
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe SQL::Generator::Function::Predicate, '#visit_axiom_function_predicate_inequality' do
|
6
|
+
subject { object.visit_axiom_function_predicate_inequality(inequality) }
|
7
|
+
|
8
|
+
let(:described_class) { Class.new(SQL::Generator::Visitor) { include SQL::Generator::Function::Predicate } }
|
9
|
+
let(:object) { described_class.new }
|
10
|
+
|
11
|
+
context 'and the left attribute is optional' do
|
12
|
+
let(:attribute) { Attribute::Integer.new(:age, :required => false) }
|
13
|
+
let(:inequality) { attribute.ne(1) }
|
14
|
+
|
15
|
+
it_should_behave_like 'a generated SQL expression'
|
16
|
+
|
17
|
+
its(:to_s) { should eql('("age" <> 1 OR "age" IS NULL)') }
|
18
|
+
end
|
19
|
+
|
20
|
+
context 'and the right attribute is optional' do
|
21
|
+
let(:attribute) { Attribute::Integer.new(:age, :required => false) }
|
22
|
+
let(:inequality) { Function::Predicate::Inequality.new(1, attribute) }
|
23
|
+
|
24
|
+
it_should_behave_like 'a generated SQL expression'
|
25
|
+
|
26
|
+
its(:to_s) { should eql('(1 <> "age" OR "age" IS NULL)') }
|
27
|
+
end
|
28
|
+
|
29
|
+
context 'and the left is a value' do
|
30
|
+
let(:attribute) { Attribute::Integer.new(:id) }
|
31
|
+
let(:inequality) { Function::Predicate::Inequality.new(1, attribute) }
|
32
|
+
|
33
|
+
it_should_behave_like 'a generated SQL expression'
|
34
|
+
|
35
|
+
its(:to_s) { should eql('1 <> "id"') }
|
36
|
+
end
|
37
|
+
|
38
|
+
context 'and the right is a value' do
|
39
|
+
let(:attribute) { Attribute::Integer.new(:id) }
|
40
|
+
let(:inequality) { attribute.ne(1) }
|
41
|
+
|
42
|
+
it_should_behave_like 'a generated SQL expression'
|
43
|
+
|
44
|
+
its(:to_s) { should eql('"id" <> 1') }
|
45
|
+
end
|
46
|
+
|
47
|
+
context 'and the right is a nil value' do
|
48
|
+
let(:attribute) { Attribute::Integer.new(:id) }
|
49
|
+
let(:inequality) { attribute.ne(nil) }
|
50
|
+
|
51
|
+
it_should_behave_like 'a generated SQL expression'
|
52
|
+
|
53
|
+
its(:to_s) { should eql('"id" IS NOT NULL') }
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe SQL::Generator::Function::Predicate, '#visit_axiom_function_predicate_less_than_or_equal_to' do
|
6
|
+
subject { object.visit_axiom_function_predicate_less_than_or_equal_to(less_than_or_equal_to) }
|
7
|
+
|
8
|
+
let(:described_class) { Class.new(SQL::Generator::Visitor) { include SQL::Generator::Function::Predicate } }
|
9
|
+
let(:less_than_or_equal_to) { Attribute::Integer.new(:id).lte(1) }
|
10
|
+
let(:object) { described_class.new }
|
11
|
+
|
12
|
+
it_should_behave_like 'a generated SQL expression'
|
13
|
+
|
14
|
+
its(:to_s) { should eql('"id" <= 1') }
|
15
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe SQL::Generator::Function::Predicate, '#visit_axiom_function_predicate_less_than' do
|
6
|
+
subject { object.visit_axiom_function_predicate_less_than(less_than) }
|
7
|
+
|
8
|
+
let(:described_class) { Class.new(SQL::Generator::Visitor) { include SQL::Generator::Function::Predicate } }
|
9
|
+
let(:less_than) { Attribute::Integer.new(:id).lt(1) }
|
10
|
+
let(:object) { described_class.new }
|
11
|
+
|
12
|
+
it_should_behave_like 'a generated SQL expression'
|
13
|
+
|
14
|
+
its(:to_s) { should eql('"id" < 1') }
|
15
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe SQL::Generator::Function::Proposition, '#visit_axiom_function_proposition_contradiction' do
|
6
|
+
subject { object.visit_axiom_function_proposition_contradiction(contradiction) }
|
7
|
+
|
8
|
+
let(:described_class) { Class.new(SQL::Generator::Visitor) { include SQL::Generator::Function::Proposition } }
|
9
|
+
let(:contradiction) { Function::Proposition::Contradiction.instance }
|
10
|
+
let(:object) { described_class.new }
|
11
|
+
|
12
|
+
it_should_behave_like 'a generated SQL expression'
|
13
|
+
|
14
|
+
its(:to_s) { should eql('FALSE') }
|
15
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe SQL::Generator::Function::Proposition, '#visit_axiom_function_proposition_tautology' do
|
6
|
+
subject { object.visit_axiom_function_proposition_tautology(tautology) }
|
7
|
+
|
8
|
+
let(:described_class) { Class.new(SQL::Generator::Visitor) { include SQL::Generator::Function::Proposition } }
|
9
|
+
let(:tautology) { Function::Proposition::Tautology.instance }
|
10
|
+
let(:object) { described_class.new }
|
11
|
+
|
12
|
+
it_should_behave_like 'a generated SQL expression'
|
13
|
+
|
14
|
+
its(:to_s) { should eql('TRUE') }
|
15
|
+
end
|