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.
Files changed (117) hide show
  1. data/.gemtest +0 -0
  2. data/.rvmrc +1 -0
  3. data/.travis.yml +8 -0
  4. data/Gemfile +20 -10
  5. data/Guardfile +22 -0
  6. data/README.rdoc +2 -0
  7. data/Rakefile +4 -2
  8. data/TODO +16 -2
  9. data/config/flay.yml +2 -2
  10. data/config/flog.yml +1 -1
  11. data/config/roodi.yml +5 -5
  12. data/config/site.reek +21 -19
  13. data/lib/veritas/sql/generator.rb +25 -2
  14. data/lib/veritas/sql/generator/core_ext/date.rb +20 -0
  15. data/lib/veritas/sql/generator/core_ext/date_time.rb +45 -0
  16. data/lib/veritas/sql/generator/direction.rb +3 -1
  17. data/lib/veritas/sql/generator/function.rb +54 -0
  18. data/lib/veritas/sql/generator/function/aggregate.rb +134 -0
  19. data/lib/veritas/sql/generator/function/connective.rb +53 -0
  20. data/lib/veritas/sql/generator/function/numeric.rb +135 -0
  21. data/lib/veritas/sql/generator/function/predicate.rb +266 -0
  22. data/lib/veritas/sql/generator/function/proposition.rb +38 -0
  23. data/lib/veritas/sql/generator/function/string.rb +29 -0
  24. data/lib/veritas/sql/generator/identifier.rb +2 -1
  25. data/lib/veritas/sql/generator/literal.rb +15 -18
  26. data/lib/veritas/sql/generator/relation.rb +144 -17
  27. data/lib/veritas/sql/generator/relation/binary.rb +16 -64
  28. data/lib/veritas/sql/generator/relation/set.rb +30 -22
  29. data/lib/veritas/sql/generator/relation/unary.rb +131 -78
  30. data/lib/veritas/sql/generator/version.rb +1 -1
  31. data/spec/unit/date/iso8601_spec.rb +23 -0
  32. data/spec/unit/date_time/iso_8601_spec.rb +115 -0
  33. data/spec/unit/veritas/sql/generator/class_methods/parenthesize_spec.rb +18 -0
  34. data/spec/unit/veritas/sql/generator/function/aggregate/visit_veritas_aggregate_count_spec.rb +16 -0
  35. data/spec/unit/veritas/sql/generator/function/aggregate/visit_veritas_aggregate_maximum_spec.rb +16 -0
  36. data/spec/unit/veritas/sql/generator/function/aggregate/visit_veritas_aggregate_mean_spec.rb +16 -0
  37. data/spec/unit/veritas/sql/generator/function/aggregate/visit_veritas_aggregate_minimum_spec.rb +16 -0
  38. data/spec/unit/veritas/sql/generator/function/aggregate/visit_veritas_aggregate_standard_deviation_spec.rb +16 -0
  39. data/spec/unit/veritas/sql/generator/function/aggregate/visit_veritas_aggregate_sum_spec.rb +16 -0
  40. data/spec/unit/veritas/sql/generator/function/aggregate/visit_veritas_aggregate_variance_spec.rb +16 -0
  41. data/spec/unit/veritas/sql/generator/function/connective/visit_veritas_function_connective_conjunction_spec.rb +20 -0
  42. data/spec/unit/veritas/sql/generator/function/connective/visit_veritas_function_connective_disjunction_spec.rb +20 -0
  43. data/spec/unit/veritas/sql/generator/function/connective/visit_veritas_function_connective_negation_spec.rb +20 -0
  44. data/spec/unit/veritas/sql/generator/function/numeric/visit_veritas_function_numeric_absolute_spec.rb +15 -0
  45. data/spec/unit/veritas/sql/generator/function/numeric/visit_veritas_function_numeric_addition_spec.rb +15 -0
  46. data/spec/unit/veritas/sql/generator/function/numeric/visit_veritas_function_numeric_division_spec.rb +15 -0
  47. data/spec/unit/veritas/sql/generator/function/numeric/visit_veritas_function_numeric_exponentiation_spec.rb +15 -0
  48. data/spec/unit/veritas/sql/generator/function/numeric/visit_veritas_function_numeric_modulo_spec.rb +15 -0
  49. data/spec/unit/veritas/sql/generator/function/numeric/visit_veritas_function_numeric_multiplication_spec.rb +15 -0
  50. data/spec/unit/veritas/sql/generator/function/numeric/visit_veritas_function_numeric_square_root_spec.rb +15 -0
  51. data/spec/unit/veritas/sql/generator/function/numeric/visit_veritas_function_numeric_subtraction_spec.rb +15 -0
  52. data/spec/unit/veritas/sql/generator/function/numeric/visit_veritas_function_numeric_unary_minus_spec.rb +15 -0
  53. data/spec/unit/veritas/sql/generator/function/numeric/visit_veritas_function_numeric_unary_plus_spec.rb +15 -0
  54. 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
  55. 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
  56. data/spec/unit/veritas/sql/generator/function/predicate/visit_veritas_function_predicate_greater_than_or_equal_to_spec.rb +15 -0
  57. 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
  58. 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
  59. 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
  60. data/spec/unit/veritas/sql/generator/function/predicate/visit_veritas_function_predicate_less_than_or_equal_to_spec.rb +15 -0
  61. 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
  62. data/spec/unit/veritas/sql/generator/function/proposition/visit_veritas_function_proposition_contradiction_spec.rb +15 -0
  63. data/spec/unit/veritas/sql/generator/function/proposition/visit_veritas_function_proposition_tautology_spec.rb +15 -0
  64. data/spec/unit/veritas/sql/generator/function/string/visit_veritas_function_string_length_spec.rb +15 -0
  65. data/spec/unit/veritas/sql/generator/literal/class_methods/dup_frozen_spec.rb +2 -2
  66. data/spec/unit/veritas/sql/generator/relation/binary/base/to_subquery_spec.rb +1 -1
  67. data/spec/unit/veritas/sql/generator/relation/binary/base/{visit_veritas_base_relation_spec.rb → visit_veritas_relation_base_spec.rb} +3 -3
  68. data/spec/unit/veritas/sql/generator/relation/binary/to_s_spec.rb +2 -2
  69. data/spec/unit/veritas/sql/generator/relation/binary/to_subquery_spec.rb +2 -2
  70. data/spec/unit/veritas/sql/generator/relation/binary/visit_veritas_algebra_join_spec.rb +74 -33
  71. data/spec/unit/veritas/sql/generator/relation/binary/visit_veritas_algebra_product_spec.rb +63 -19
  72. data/spec/unit/veritas/sql/generator/relation/class_methods/visit_spec.rb +1 -1
  73. data/spec/unit/veritas/sql/generator/relation/set/class_methods/normalize_operand_headers_spec.rb +35 -0
  74. data/spec/unit/veritas/sql/generator/relation/set/to_s_spec.rb +1 -1
  75. data/spec/unit/veritas/sql/generator/relation/set/to_subquery_spec.rb +4 -4
  76. data/spec/unit/veritas/sql/generator/relation/set/visit_veritas_algebra_difference_spec.rb +83 -30
  77. data/spec/unit/veritas/sql/generator/relation/set/visit_veritas_algebra_intersection_spec.rb +80 -30
  78. data/spec/unit/veritas/sql/generator/relation/set/visit_veritas_algebra_union_spec.rb +80 -30
  79. data/spec/unit/veritas/sql/generator/relation/to_s_spec.rb +50 -0
  80. data/spec/unit/veritas/sql/generator/relation/to_subquery_spec.rb +49 -0
  81. data/spec/unit/veritas/sql/generator/relation/unary/to_s_spec.rb +1 -1
  82. data/spec/unit/veritas/sql/generator/relation/unary/to_subquery_spec.rb +6 -6
  83. data/spec/unit/veritas/sql/generator/relation/unary/visit_veritas_algebra_extension_spec.rb +165 -0
  84. data/spec/unit/veritas/sql/generator/relation/unary/visit_veritas_algebra_projection_spec.rb +84 -29
  85. data/spec/unit/veritas/sql/generator/relation/unary/visit_veritas_algebra_rename_spec.rb +69 -27
  86. data/spec/unit/veritas/sql/generator/relation/unary/visit_veritas_algebra_restriction_spec.rb +64 -22
  87. data/spec/unit/veritas/sql/generator/relation/unary/visit_veritas_algebra_summarization_spec.rb +652 -0
  88. data/spec/unit/veritas/sql/generator/relation/unary/{visit_veritas_base_relation_spec.rb → visit_veritas_relation_base_spec.rb} +4 -4
  89. data/spec/unit/veritas/sql/generator/relation/unary/visit_veritas_relation_operation_limit_spec.rb +60 -20
  90. data/spec/unit/veritas/sql/generator/relation/unary/visit_veritas_relation_operation_offset_spec.rb +60 -20
  91. data/spec/unit/veritas/sql/generator/relation/unary/visit_veritas_relation_operation_order_spec.rb +63 -23
  92. data/spec/unit/veritas/sql/generator/relation/unary/visit_veritas_relation_operation_reverse_spec.rb +60 -20
  93. data/spec/unit/veritas/sql/generator/relation/visited_spec.rb +1 -1
  94. data/tasks/metrics/ci.rake +7 -0
  95. data/tasks/{quality → metrics}/flay.rake +0 -0
  96. data/tasks/{quality → metrics}/flog.rake +0 -0
  97. data/tasks/{quality → metrics}/heckle.rake +1 -0
  98. data/tasks/{quality → metrics}/metric_fu.rake +3 -0
  99. data/tasks/{quality → metrics}/reek.rake +0 -0
  100. data/tasks/{quality → metrics}/roodi.rake +0 -0
  101. data/tasks/{quality → metrics}/yardstick.rake +0 -0
  102. data/tasks/spec.rake +1 -0
  103. data/veritas-sql-generator.gemspec +82 -114
  104. metadata +137 -125
  105. data/lib/veritas/base_relation.rb +0 -36
  106. data/lib/veritas/sql/generator/logic.rb +0 -349
  107. data/spec/unit/veritas/base_relation/name_spec.rb +0 -45
  108. data/spec/unit/veritas/sql/generator/logic/visit_veritas_logic_connective_conjunction_spec.rb +0 -16
  109. data/spec/unit/veritas/sql/generator/logic/visit_veritas_logic_connective_disjunction_spec.rb +0 -16
  110. data/spec/unit/veritas/sql/generator/logic/visit_veritas_logic_connective_negation_spec.rb +0 -16
  111. data/spec/unit/veritas/sql/generator/logic/visit_veritas_logic_predicate_greater_than_or_equal_to_spec.rb +0 -15
  112. data/spec/unit/veritas/sql/generator/logic/visit_veritas_logic_predicate_less_than_or_equal_to_spec.rb +0 -15
  113. data/spec/unit/veritas/sql/generator/logic/visit_veritas_logic_proposition_contradiction_spec.rb +0 -15
  114. data/spec/unit/veritas/sql/generator/logic/visit_veritas_logic_proposition_tautology_spec.rb +0 -15
  115. data/spec/unit/veritas/sql/generator/relation/binary/class_methods/subquery_spec.rb +0 -42
  116. data/spec/unit/veritas/sql/generator/relation/class_methods/subquery_spec.rb +0 -33
  117. data/tasks/quality/ci.rake +0 -2
@@ -0,0 +1,115 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe DateTime, '#iso8601' do
6
+
7
+ # ruby 1.9.3 has problems with fractional nanoseconds
8
+ def self.it_supports_nanoseconds(message = 'returns the expected date-time', &block)
9
+ if RUBY_VERSION >= '1.9.3'
10
+ it(message) { pending('Fix rounding error in 1.9.3', &block) }
11
+ else
12
+ it(message, &block)
13
+ end
14
+ end
15
+
16
+ let(:object) { described_class.new(2010, 12, 31, 23, 59, 59 + nsec_in_seconds) }
17
+ let(:nsec_in_seconds) { 1 - Rational(1, 10**9) }
18
+
19
+ # rubinius 1.2.3 has problems with fractional seconds above 59
20
+ unless defined?(RUBY_ENGINE) && RUBY_ENGINE == 'rbx' && Rubinius::VERSION <= '1.2.3'
21
+ context 'with no arguments' do
22
+ subject { object.iso8601 }
23
+
24
+ context 'when the datetime is frozen' do
25
+ before do
26
+ object.freeze
27
+ end
28
+
29
+ it { should respond_to(:to_s) }
30
+
31
+ it_supports_nanoseconds do
32
+ should == '2010-12-31T23:59:59+00:00'
33
+ end
34
+ end
35
+
36
+ context 'when the datetime is not frozen' do
37
+ it { should respond_to(:to_s) }
38
+
39
+ it { should == '2010-12-31T23:59:59+00:00' }
40
+ end
41
+ end
42
+
43
+ context 'with a time scale of 0' do
44
+ subject { object.iso8601(time_scale) }
45
+
46
+ let(:time_scale) { 0 }
47
+
48
+ context 'when the datetime is frozen' do
49
+ before do
50
+ object.freeze
51
+ end
52
+
53
+ it { should respond_to(:to_s) }
54
+
55
+ it_supports_nanoseconds do
56
+ should == '2010-12-31T23:59:59+00:00'
57
+ end
58
+ end
59
+
60
+ context 'when the datetime is not frozen' do
61
+ it { should respond_to(:to_s) }
62
+
63
+ it { should == '2010-12-31T23:59:59+00:00' }
64
+ end
65
+ end
66
+
67
+ context 'with a time scale of 1' do
68
+ subject { object.iso8601(time_scale) }
69
+
70
+ let(:time_scale) { 1 }
71
+
72
+ context 'when the datetime is frozen' do
73
+ before do
74
+ object.freeze
75
+ end
76
+
77
+ it { should respond_to(:to_s) }
78
+
79
+ it_supports_nanoseconds do
80
+ should == '2010-12-31T23:59:59.9+00:00'
81
+ end
82
+ end
83
+
84
+ context 'when the datetime is not frozen' do
85
+ it { should respond_to(:to_s) }
86
+
87
+ it { should == '2010-12-31T23:59:59.9+00:00' }
88
+ end
89
+ end
90
+
91
+ context 'with a time scale of 9' do
92
+ subject { object.iso8601(time_scale) }
93
+
94
+ let(:time_scale) { 9 }
95
+
96
+ context 'when the datetime is frozen' do
97
+ before do
98
+ object.freeze
99
+ end
100
+
101
+ it { should respond_to(:to_s) }
102
+
103
+ it_supports_nanoseconds do
104
+ should == '2010-12-31T23:59:59.999999999+00:00'
105
+ end
106
+ end
107
+
108
+ context 'when the datetime is not frozen' do
109
+ it { should respond_to(:to_s) }
110
+
111
+ it { should == '2010-12-31T23:59:59.999999999+00:00' }
112
+ end
113
+ end
114
+ end
115
+ end
@@ -0,0 +1,18 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe SQL::Generator, '.parenthesize!' do
6
+ subject { object.parenthesize!(string) }
7
+
8
+ let(:string) { '1 + 1' }
9
+ let(:object) { self.class.described_type }
10
+
11
+ it_should_behave_like 'a generated SQL expression'
12
+
13
+ it 'modifies the string inline' do
14
+ should equal(string)
15
+ end
16
+
17
+ its(:to_s) { should == '(1 + 1)' }
18
+ end
@@ -0,0 +1,16 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe SQL::Generator::Function::Aggregate, '#visit_veritas_aggregate_count' do
6
+ subject { object.visit_veritas_aggregate_count(count) }
7
+
8
+ let(:described_class) { Class.new(SQL::Generator::Visitor) { include SQL::Generator::Function::Aggregate } }
9
+ let(:attribute) { Attribute::Integer.new(:id) }
10
+ let(:count) { attribute.count }
11
+ let(:object) { described_class.new }
12
+
13
+ it_should_behave_like 'a generated SQL expression'
14
+
15
+ its(:to_s) { should eql('COUNT ("id")') }
16
+ end
@@ -0,0 +1,16 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe SQL::Generator::Function::Aggregate, '#visit_veritas_aggregate_maximum' do
6
+ subject { object.visit_veritas_aggregate_maximum(maximum) }
7
+
8
+ let(:described_class) { Class.new(SQL::Generator::Visitor) { include SQL::Generator::Function::Aggregate } }
9
+ let(:attribute) { Attribute::Integer.new(:id) }
10
+ let(:maximum) { attribute.maximum }
11
+ let(:object) { described_class.new }
12
+
13
+ it_should_behave_like 'a generated SQL expression'
14
+
15
+ its(:to_s) { should eql('MAX ("id")') }
16
+ end
@@ -0,0 +1,16 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe SQL::Generator::Function::Aggregate, '#visit_veritas_aggregate_mean' do
6
+ subject { object.visit_veritas_aggregate_mean(mean) }
7
+
8
+ let(:described_class) { Class.new(SQL::Generator::Visitor) { include SQL::Generator::Function::Aggregate } }
9
+ let(:attribute) { Attribute::Integer.new(:id) }
10
+ let(:mean) { attribute.mean }
11
+ let(:object) { described_class.new }
12
+
13
+ it_should_behave_like 'a generated SQL expression'
14
+
15
+ its(:to_s) { should eql('AVG ("id")') }
16
+ end
@@ -0,0 +1,16 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe SQL::Generator::Function::Aggregate, '#visit_veritas_aggregate_minimum' do
6
+ subject { object.visit_veritas_aggregate_minimum(minimum) }
7
+
8
+ let(:described_class) { Class.new(SQL::Generator::Visitor) { include SQL::Generator::Function::Aggregate } }
9
+ let(:attribute) { Attribute::Integer.new(:id) }
10
+ let(:minimum) { attribute.minimum }
11
+ let(:object) { described_class.new }
12
+
13
+ it_should_behave_like 'a generated SQL expression'
14
+
15
+ its(:to_s) { should eql('MIN ("id")') }
16
+ end
@@ -0,0 +1,16 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe SQL::Generator::Function::Aggregate, '#visit_veritas_aggregate_standard_deviation' do
6
+ subject { object.visit_veritas_aggregate_standard_deviation(standard_deviation) }
7
+
8
+ let(:described_class) { Class.new(SQL::Generator::Visitor) { include SQL::Generator::Function::Aggregate } }
9
+ let(:attribute) { Attribute::Integer.new(:id) }
10
+ let(:standard_deviation) { attribute.standard_deviation }
11
+ let(:object) { described_class.new }
12
+
13
+ it_should_behave_like 'a generated SQL expression'
14
+
15
+ its(:to_s) { should eql('STDDEV_POP ("id")') }
16
+ end
@@ -0,0 +1,16 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe SQL::Generator::Function::Aggregate, '#visit_veritas_aggregate_sum' do
6
+ subject { object.visit_veritas_aggregate_sum(sum) }
7
+
8
+ let(:described_class) { Class.new(SQL::Generator::Visitor) { include SQL::Generator::Function::Aggregate } }
9
+ let(:attribute) { Attribute::Integer.new(:id) }
10
+ let(:sum) { attribute.sum }
11
+ let(:object) { described_class.new }
12
+
13
+ it_should_behave_like 'a generated SQL expression'
14
+
15
+ its(:to_s) { should eql('COALESCE (SUM ("id"), 0)') }
16
+ end
@@ -0,0 +1,16 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe SQL::Generator::Function::Aggregate, '#visit_veritas_aggregate_variance' do
6
+ subject { object.visit_veritas_aggregate_variance(variance) }
7
+
8
+ let(:described_class) { Class.new(SQL::Generator::Visitor) { include SQL::Generator::Function::Aggregate } }
9
+ let(:attribute) { Attribute::Integer.new(:id) }
10
+ let(:variance) { attribute.variance }
11
+ let(:object) { described_class.new }
12
+
13
+ it_should_behave_like 'a generated SQL expression'
14
+
15
+ its(:to_s) { should eql('VAR_POP ("id")') }
16
+ end
@@ -0,0 +1,20 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe SQL::Generator::Function::Connective, '#visit_veritas_function_connective_conjunction' do
6
+ subject { object.visit_veritas_function_connective_conjunction(conjunction) }
7
+
8
+ let(:described_class) { Class.new(SQL::Generator::Visitor) { include SQL::Generator::Function::Connective } }
9
+ let(:attribute) { Attribute::Integer.new(:id) }
10
+ let(:conjunction) { attribute.eq(1).and(attribute.ne(2)) }
11
+ let(:object) { described_class.new }
12
+
13
+ before do
14
+ described_class.class_eval { include SQL::Generator::Function::Predicate }
15
+ end
16
+
17
+ it_should_behave_like 'a generated SQL expression'
18
+
19
+ its(:to_s) { should eql('("id" = 1 AND "id" <> 2)') }
20
+ end
@@ -0,0 +1,20 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe SQL::Generator::Function::Connective, '#visit_veritas_function_connective_disjunction' do
6
+ subject { object.visit_veritas_function_connective_disjunction(disjunction) }
7
+
8
+ let(:described_class) { Class.new(SQL::Generator::Visitor) { include SQL::Generator::Function::Connective } }
9
+ let(:attribute) { Attribute::Integer.new(:id) }
10
+ let(:disjunction) { attribute.eq(1).or(attribute.eq(2)) }
11
+ let(:object) { described_class.new }
12
+
13
+ before do
14
+ described_class.class_eval { include SQL::Generator::Function::Predicate }
15
+ end
16
+
17
+ it_should_behave_like 'a generated SQL expression'
18
+
19
+ its(:to_s) { should eql('("id" = 1 OR "id" = 2)') }
20
+ end
@@ -0,0 +1,20 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe SQL::Generator::Function::Connective, '#visit_veritas_function_connective_negation' do
6
+ subject { object.visit_veritas_function_connective_negation(negation) }
7
+
8
+ let(:described_class) { Class.new(SQL::Generator::Visitor) { include SQL::Generator::Function::Connective } }
9
+ let(:attribute) { Attribute::Integer.new(:id) }
10
+ let(:negation) { Function::Connective::Negation.new(attribute.eq(1)) }
11
+ let(:object) { described_class.new }
12
+
13
+ before do
14
+ described_class.class_eval { include SQL::Generator::Function::Predicate }
15
+ end
16
+
17
+ it_should_behave_like 'a generated SQL expression'
18
+
19
+ its(:to_s) { should eql('NOT ("id" = 1)') }
20
+ end
@@ -0,0 +1,15 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe SQL::Generator::Function::Numeric, '#visit_veritas_function_numeric_absolute' do
6
+ subject { object.visit_veritas_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
@@ -0,0 +1,15 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe SQL::Generator::Function::Numeric, '#visit_veritas_function_numeric_addition' do
6
+ subject { object.visit_veritas_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
@@ -0,0 +1,15 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe SQL::Generator::Function::Numeric, '#visit_veritas_function_numeric_division' do
6
+ subject { object.visit_veritas_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_veritas_function_numeric_exponentiation' do
6
+ subject { object.visit_veritas_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
@@ -0,0 +1,15 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe SQL::Generator::Function::Numeric, '#visit_veritas_function_numeric_modulo' do
6
+ subject { object.visit_veritas_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_veritas_function_numeric_multiplication' do
6
+ subject { object.visit_veritas_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
@@ -0,0 +1,15 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe SQL::Generator::Function::Numeric, '#visit_veritas_function_numeric_square_root' do
6
+ subject { object.visit_veritas_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
@@ -0,0 +1,15 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe SQL::Generator::Function::Numeric, '#visit_veritas_function_numeric_subtraction' do
6
+ subject { object.visit_veritas_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