query_builder 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (229) hide show
  1. checksums.yaml +7 -0
  2. data/.coveralls.yml +2 -0
  3. data/.gitignore +9 -0
  4. data/.metrics +9 -0
  5. data/.rspec +2 -0
  6. data/.rubocop.yml +2 -0
  7. data/.travis.yml +25 -0
  8. data/.yardopts +3 -0
  9. data/CHANGELOG.md +5 -0
  10. data/Gemfile +7 -0
  11. data/Guardfile +14 -0
  12. data/LICENSE +21 -0
  13. data/README.md +95 -0
  14. data/Rakefile +34 -0
  15. data/config/metrics/STYLEGUIDE +230 -0
  16. data/config/metrics/cane.yml +5 -0
  17. data/config/metrics/churn.yml +6 -0
  18. data/config/metrics/flay.yml +2 -0
  19. data/config/metrics/metric_fu.yml +14 -0
  20. data/config/metrics/reek.yml +1 -0
  21. data/config/metrics/roodi.yml +24 -0
  22. data/config/metrics/rubocop.yml +80 -0
  23. data/config/metrics/saikuro.yml +3 -0
  24. data/config/metrics/simplecov.yml +6 -0
  25. data/config/metrics/yardstick.yml +37 -0
  26. data/lib/query_builder.rb +9 -0
  27. data/lib/query_builder/core.rb +19 -0
  28. data/lib/query_builder/core/attribute.rb +54 -0
  29. data/lib/query_builder/core/attribute_error.rb +25 -0
  30. data/lib/query_builder/core/base.rb +102 -0
  31. data/lib/query_builder/core/clause.rb +46 -0
  32. data/lib/query_builder/core/statement.rb +55 -0
  33. data/lib/query_builder/cql.rb +80 -0
  34. data/lib/query_builder/cql/contexts.rb +21 -0
  35. data/lib/query_builder/cql/contexts/aggregate.rb +42 -0
  36. data/lib/query_builder/cql/contexts/column.rb +59 -0
  37. data/lib/query_builder/cql/contexts/field.rb +48 -0
  38. data/lib/query_builder/cql/contexts/function.rb +46 -0
  39. data/lib/query_builder/cql/contexts/index.rb +44 -0
  40. data/lib/query_builder/cql/contexts/keyspace.rb +107 -0
  41. data/lib/query_builder/cql/contexts/permission.rb +59 -0
  42. data/lib/query_builder/cql/contexts/role.rb +51 -0
  43. data/lib/query_builder/cql/contexts/table.rb +140 -0
  44. data/lib/query_builder/cql/contexts/trigger.rb +42 -0
  45. data/lib/query_builder/cql/contexts/type.rb +52 -0
  46. data/lib/query_builder/cql/contexts/user.rb +53 -0
  47. data/lib/query_builder/cql/modifiers.rb +61 -0
  48. data/lib/query_builder/cql/modifiers/add_column.rb +50 -0
  49. data/lib/query_builder/cql/modifiers/add_field.rb +49 -0
  50. data/lib/query_builder/cql/modifiers/allow_filtering.rb +45 -0
  51. data/lib/query_builder/cql/modifiers/alter.rb +44 -0
  52. data/lib/query_builder/cql/modifiers/called_on_null.rb +47 -0
  53. data/lib/query_builder/cql/modifiers/clustering_order.rb +51 -0
  54. data/lib/query_builder/cql/modifiers/column.rb +59 -0
  55. data/lib/query_builder/cql/modifiers/compact_storage.rb +46 -0
  56. data/lib/query_builder/cql/modifiers/count.rb +47 -0
  57. data/lib/query_builder/cql/modifiers/counter.rb +45 -0
  58. data/lib/query_builder/cql/modifiers/delete.rb +48 -0
  59. data/lib/query_builder/cql/modifiers/distinct.rb +45 -0
  60. data/lib/query_builder/cql/modifiers/finalfunc.rb +47 -0
  61. data/lib/query_builder/cql/modifiers/if.rb +44 -0
  62. data/lib/query_builder/cql/modifiers/if_exists.rb +46 -0
  63. data/lib/query_builder/cql/modifiers/if_not_exists.rb +46 -0
  64. data/lib/query_builder/cql/modifiers/initcond.rb +49 -0
  65. data/lib/query_builder/cql/modifiers/insert.rb +68 -0
  66. data/lib/query_builder/cql/modifiers/limit.rb +49 -0
  67. data/lib/query_builder/cql/modifiers/norecursive.rb +45 -0
  68. data/lib/query_builder/cql/modifiers/or_replace.rb +44 -0
  69. data/lib/query_builder/cql/modifiers/order.rb +50 -0
  70. data/lib/query_builder/cql/modifiers/password.rb +49 -0
  71. data/lib/query_builder/cql/modifiers/primary_key.rb +51 -0
  72. data/lib/query_builder/cql/modifiers/returns.rb +49 -0
  73. data/lib/query_builder/cql/modifiers/selected.rb +54 -0
  74. data/lib/query_builder/cql/modifiers/sfunc.rb +47 -0
  75. data/lib/query_builder/cql/modifiers/statement.rb +47 -0
  76. data/lib/query_builder/cql/modifiers/stype.rb +47 -0
  77. data/lib/query_builder/cql/modifiers/superuser.rb +54 -0
  78. data/lib/query_builder/cql/modifiers/timestamp.rb +50 -0
  79. data/lib/query_builder/cql/modifiers/unlogged.rb +45 -0
  80. data/lib/query_builder/cql/modifiers/update.rb +44 -0
  81. data/lib/query_builder/cql/modifiers/using.rb +48 -0
  82. data/lib/query_builder/cql/modifiers/using_options.rb +51 -0
  83. data/lib/query_builder/cql/modifiers/where.rb +44 -0
  84. data/lib/query_builder/cql/modifiers/where_clustered.rb +51 -0
  85. data/lib/query_builder/cql/modifiers/with.rb +44 -0
  86. data/lib/query_builder/cql/modifiers/with_options.rb +42 -0
  87. data/lib/query_builder/cql/operators.rb +29 -0
  88. data/lib/query_builder/cql/operators/cql.rb +23 -0
  89. data/lib/query_builder/cql/operators/cql_composite.rb +20 -0
  90. data/lib/query_builder/cql/operators/cql_dec.rb +21 -0
  91. data/lib/query_builder/cql/operators/cql_element.rb +23 -0
  92. data/lib/query_builder/cql/operators/cql_entries.rb +20 -0
  93. data/lib/query_builder/cql/operators/cql_frozen.rb +20 -0
  94. data/lib/query_builder/cql/operators/cql_full.rb +20 -0
  95. data/lib/query_builder/cql/operators/cql_gt.rb +23 -0
  96. data/lib/query_builder/cql/operators/cql_gte.rb +23 -0
  97. data/lib/query_builder/cql/operators/cql_in.rb +23 -0
  98. data/lib/query_builder/cql/operators/cql_inc.rb +21 -0
  99. data/lib/query_builder/cql/operators/cql_keys.rb +20 -0
  100. data/lib/query_builder/cql/operators/cql_list.rb +21 -0
  101. data/lib/query_builder/cql/operators/cql_literal.rb +84 -0
  102. data/lib/query_builder/cql/operators/cql_lt.rb +23 -0
  103. data/lib/query_builder/cql/operators/cql_lte.rb +23 -0
  104. data/lib/query_builder/cql/operators/cql_map.rb +25 -0
  105. data/lib/query_builder/cql/operators/cql_set.rb +21 -0
  106. data/lib/query_builder/cql/operators/cql_token.rb +21 -0
  107. data/lib/query_builder/cql/operators/cql_token_value.rb +23 -0
  108. data/lib/query_builder/cql/operators/cql_ttl.rb +20 -0
  109. data/lib/query_builder/cql/operators/cql_tuple.rb +21 -0
  110. data/lib/query_builder/cql/operators/cql_tuple_value.rb +23 -0
  111. data/lib/query_builder/cql/operators/cql_writetime.rb +20 -0
  112. data/lib/query_builder/cql/statements.rb +25 -0
  113. data/lib/query_builder/cql/statements/alter_column.rb +27 -0
  114. data/lib/query_builder/cql/statements/alter_field.rb +27 -0
  115. data/lib/query_builder/cql/statements/alter_keyspace.rb +25 -0
  116. data/lib/query_builder/cql/statements/alter_role.rb +26 -0
  117. data/lib/query_builder/cql/statements/alter_table.rb +25 -0
  118. data/lib/query_builder/cql/statements/alter_user.rb +26 -0
  119. data/lib/query_builder/cql/statements/batch.rb +31 -0
  120. data/lib/query_builder/cql/statements/create_aggregate.rb +36 -0
  121. data/lib/query_builder/cql/statements/create_column.rb +35 -0
  122. data/lib/query_builder/cql/statements/create_field.rb +25 -0
  123. data/lib/query_builder/cql/statements/create_function.rb +38 -0
  124. data/lib/query_builder/cql/statements/create_index.rb +41 -0
  125. data/lib/query_builder/cql/statements/create_keyspace.rb +26 -0
  126. data/lib/query_builder/cql/statements/create_role.rb +26 -0
  127. data/lib/query_builder/cql/statements/create_table.rb +30 -0
  128. data/lib/query_builder/cql/statements/create_trigger.rb +29 -0
  129. data/lib/query_builder/cql/statements/create_type.rb +26 -0
  130. data/lib/query_builder/cql/statements/create_user.rb +27 -0
  131. data/lib/query_builder/cql/statements/delete.rb +32 -0
  132. data/lib/query_builder/cql/statements/drop_aggregate.rb +25 -0
  133. data/lib/query_builder/cql/statements/drop_column.rb +23 -0
  134. data/lib/query_builder/cql/statements/drop_function.rb +25 -0
  135. data/lib/query_builder/cql/statements/drop_index.rb +25 -0
  136. data/lib/query_builder/cql/statements/drop_keyspace.rb +25 -0
  137. data/lib/query_builder/cql/statements/drop_role.rb +25 -0
  138. data/lib/query_builder/cql/statements/drop_table.rb +25 -0
  139. data/lib/query_builder/cql/statements/drop_trigger.rb +25 -0
  140. data/lib/query_builder/cql/statements/drop_type.rb +25 -0
  141. data/lib/query_builder/cql/statements/drop_user.rb +25 -0
  142. data/lib/query_builder/cql/statements/grant.rb +31 -0
  143. data/lib/query_builder/cql/statements/insert.rb +27 -0
  144. data/lib/query_builder/cql/statements/list_permissions.rb +35 -0
  145. data/lib/query_builder/cql/statements/list_roles.rb +23 -0
  146. data/lib/query_builder/cql/statements/list_users.rb +23 -0
  147. data/lib/query_builder/cql/statements/rename_column.rb +27 -0
  148. data/lib/query_builder/cql/statements/rename_field.rb +25 -0
  149. data/lib/query_builder/cql/statements/revoke.rb +31 -0
  150. data/lib/query_builder/cql/statements/select.rb +35 -0
  151. data/lib/query_builder/cql/statements/truncate.rb +23 -0
  152. data/lib/query_builder/cql/statements/update.rb +31 -0
  153. data/lib/query_builder/cql/statements/use.rb +23 -0
  154. data/lib/query_builder/rspec.rb +25 -0
  155. data/lib/query_builder/version.rb +9 -0
  156. data/query_builder.gemspec +31 -0
  157. data/spec/integration/alter_keyspace_spec.rb +17 -0
  158. data/spec/integration/alter_role_spec.rb +28 -0
  159. data/spec/integration/alter_table_add_spec.rb +21 -0
  160. data/spec/integration/alter_table_alter_spec.rb +15 -0
  161. data/spec/integration/alter_table_drop_spec.rb +15 -0
  162. data/spec/integration/alter_table_rename_spec.rb +15 -0
  163. data/spec/integration/alter_table_with_spec.rb +17 -0
  164. data/spec/integration/alter_type_add_spec.rb +15 -0
  165. data/spec/integration/alter_type_alter_spec.rb +15 -0
  166. data/spec/integration/alter_type_rename_spec.rb +15 -0
  167. data/spec/integration/alter_user_spec.rb +28 -0
  168. data/spec/integration/batch_spec.rb +32 -0
  169. data/spec/integration/create_aggregate_spec.rb +31 -0
  170. data/spec/integration/create_function_spec.rb +29 -0
  171. data/spec/integration/create_index_spec.rb +35 -0
  172. data/spec/integration/create_keyspace_spec.rb +24 -0
  173. data/spec/integration/create_role_spec.rb +26 -0
  174. data/spec/integration/create_table_spec.rb +34 -0
  175. data/spec/integration/create_trigger_spec.rb +21 -0
  176. data/spec/integration/create_type_spec.rb +20 -0
  177. data/spec/integration/create_user_spec.rb +23 -0
  178. data/spec/integration/delete_spec.rb +28 -0
  179. data/spec/integration/drop_aggregate_spec.rb +21 -0
  180. data/spec/integration/drop_function_spec.rb +21 -0
  181. data/spec/integration/drop_index_spec.rb +21 -0
  182. data/spec/integration/drop_keyspace_spec.rb +18 -0
  183. data/spec/integration/drop_role_spec.rb +18 -0
  184. data/spec/integration/drop_table_spec.rb +18 -0
  185. data/spec/integration/drop_trigger_spec.rb +21 -0
  186. data/spec/integration/drop_type_spec.rb +18 -0
  187. data/spec/integration/drop_user_spec.rb +18 -0
  188. data/spec/integration/grant_spec.rb +29 -0
  189. data/spec/integration/insert_spec.rb +22 -0
  190. data/spec/integration/list_permissions_spec.rb +34 -0
  191. data/spec/integration/list_roles_spec.rb +12 -0
  192. data/spec/integration/list_users_spec.rb +12 -0
  193. data/spec/integration/revoke_spec.rb +29 -0
  194. data/spec/integration/select_spec.rb +46 -0
  195. data/spec/integration/truncate_spec.rb +12 -0
  196. data/spec/integration/update_spec.rb +23 -0
  197. data/spec/integration/use_spec.rb +12 -0
  198. data/spec/spec_helper.rb +16 -0
  199. data/spec/unit/core/attribute_error_spec.rb +38 -0
  200. data/spec/unit/core/attribute_spec.rb +70 -0
  201. data/spec/unit/core/base_spec.rb +110 -0
  202. data/spec/unit/core/clause_spec.rb +101 -0
  203. data/spec/unit/core/statement_spec.rb +88 -0
  204. data/spec/unit/cql/operators/cql_composite_spec.rb +12 -0
  205. data/spec/unit/cql/operators/cql_dec_spec.rb +12 -0
  206. data/spec/unit/cql/operators/cql_element_spec.rb +12 -0
  207. data/spec/unit/cql/operators/cql_entries_spec.rb +12 -0
  208. data/spec/unit/cql/operators/cql_frozen_spec.rb +12 -0
  209. data/spec/unit/cql/operators/cql_full_spec.rb +12 -0
  210. data/spec/unit/cql/operators/cql_gt_spec.rb +19 -0
  211. data/spec/unit/cql/operators/cql_gte_spec.rb +19 -0
  212. data/spec/unit/cql/operators/cql_in_spec.rb +12 -0
  213. data/spec/unit/cql/operators/cql_inc_spec.rb +12 -0
  214. data/spec/unit/cql/operators/cql_keys_spec.rb +12 -0
  215. data/spec/unit/cql/operators/cql_list_spec.rb +12 -0
  216. data/spec/unit/cql/operators/cql_literal_spec.rb +83 -0
  217. data/spec/unit/cql/operators/cql_lt_spec.rb +19 -0
  218. data/spec/unit/cql/operators/cql_lte_spec.rb +19 -0
  219. data/spec/unit/cql/operators/cql_map_spec.rb +12 -0
  220. data/spec/unit/cql/operators/cql_set_spec.rb +12 -0
  221. data/spec/unit/cql/operators/cql_spec.rb +12 -0
  222. data/spec/unit/cql/operators/cql_token_spec.rb +12 -0
  223. data/spec/unit/cql/operators/cql_token_value_spec.rb +12 -0
  224. data/spec/unit/cql/operators/cql_ttl_spec.rb +12 -0
  225. data/spec/unit/cql/operators/cql_tuple_spec.rb +12 -0
  226. data/spec/unit/cql/operators/cql_tuple_value_spec.rb +12 -0
  227. data/spec/unit/cql/operators/cql_writetime_spec.rb +12 -0
  228. data/spec/unit/cql/operators_spec.rb +66 -0
  229. metadata +405 -0
@@ -0,0 +1,101 @@
1
+ # encoding: utf-8
2
+
3
+ describe QueryBuilder::Core::Clause do
4
+
5
+ let(:klass) { Class.new(described_class) { attribute :foo, default: :BAR } }
6
+ let(:clause) { klass.new(options) }
7
+ let(:options) { { foo: :FOO } }
8
+
9
+ shared_examples :comparable_by_kind_and_attributes do
10
+
11
+ context "of the same type and attributes" do
12
+ let(:other) { klass.new(options) }
13
+ it { is_expected.to eql true }
14
+ end # context
15
+
16
+ context "with other attributes" do
17
+ let(:other) { klass.new }
18
+ it { is_expected.to eql false }
19
+ end # context
20
+
21
+ context "of another kind" do
22
+ let(:other) { Class.new(klass).new(options) }
23
+ it { is_expected.to eql false }
24
+ end # context
25
+
26
+ end # end
27
+
28
+ shared_examples :comparable_by_kind do
29
+
30
+ context "of the same type and attributes" do
31
+ let(:other) { klass.new(options) }
32
+ it { is_expected.to eql true }
33
+ end # context
34
+
35
+ context "with other attributes" do
36
+ let(:other) { klass.new }
37
+ it { is_expected.to eql true }
38
+ end # context
39
+
40
+ context "of another kind" do
41
+ let(:other) { Class.new(klass).new(options) }
42
+ it { is_expected.to eql false }
43
+ end # context
44
+
45
+ end # end
46
+
47
+ describe ".type" do
48
+ subject { klass.type :foo }
49
+
50
+ it "sets the class type" do
51
+ expect { subject }
52
+ .to change { klass.type }
53
+ .from(nil)
54
+ .to :foo
55
+ end
56
+
57
+ it "sets the instance's type" do
58
+ expect { subject }
59
+ .to change { klass.new.type }
60
+ .from(nil)
61
+ .to :foo
62
+ end
63
+ end # describe .type
64
+
65
+ describe ".new" do
66
+ subject { clause }
67
+
68
+ it "is immutable" do
69
+ expect(subject).to be_frozen
70
+ end
71
+
72
+ it "is comparable" do
73
+ expect(subject).to be_kind_of QueryBuilder::Core::Base
74
+ end
75
+ end # describe .new
76
+
77
+ describe "#==" do
78
+ subject { clause == other }
79
+
80
+ it_behaves_like :comparable_by_kind_and_attributes
81
+ end # describe #==
82
+
83
+ describe "#eql?" do
84
+ subject { clause.eql? other }
85
+
86
+ it_behaves_like :comparable_by_kind_and_attributes
87
+ end # describe #eql?
88
+
89
+ describe ".unique" do
90
+ before { klass.unique }
91
+
92
+ it_behaves_like :comparable_by_kind do
93
+ subject { clause == other }
94
+ end
95
+
96
+ it_behaves_like :comparable_by_kind do
97
+ subject { clause.eql? other }
98
+ end
99
+ end # describe .unique
100
+
101
+ end # describe QueryBuilder::Core::Clause
@@ -0,0 +1,88 @@
1
+ # encoding: utf-8
2
+
3
+ describe QueryBuilder::Core::Statement do
4
+
5
+ let(:klass) { Class.new(described_class) { attribute :foo } }
6
+ let(:statement) { klass.new(attributes) { [bar, baz] } }
7
+ let(:attributes) { { foo: :FOO } }
8
+
9
+ let(:clause) do
10
+ Class.new(QueryBuilder::Core::Clause) { def to_s; type.to_s; end }
11
+ end
12
+
13
+ let(:bar) { Class.new(clause) { type :bar }.new }
14
+ let(:baz) { Class.new(clause) { type :baz }.new }
15
+ let(:qux) { Class.new(clause) { type :qux }.new }
16
+
17
+ describe ".new" do
18
+ subject { statement }
19
+
20
+ it "is a node" do
21
+ expect(subject).to be_kind_of(QueryBuilder::Core::Base)
22
+ end
23
+
24
+ it "is immutable" do
25
+ expect(subject).to be_frozen
26
+ end
27
+ end # describe .new
28
+
29
+ describe "#context" do
30
+ subject { statement.context }
31
+
32
+ context "by default" do
33
+ it { is_expected.to be_nil }
34
+ end # context
35
+
36
+ context "when assigned" do
37
+ let(:statement) { described_class.new(context: :foo) }
38
+
39
+ it { is_expected.to eq(:foo) }
40
+ end
41
+ end # describe #context
42
+
43
+ describe "#clauses" do
44
+ subject { statement.clauses }
45
+
46
+ context "by default" do
47
+ let(:statement) { klass.new(attributes) }
48
+
49
+ it "returns the empty array" do
50
+ expect(subject).to eql %w()
51
+ end
52
+ end # context
53
+
54
+ context "without attributes" do
55
+ it "is initialized from the block" do
56
+ expect(subject).to eql %w(bar baz)
57
+ end
58
+ end
59
+
60
+ context "with an argument" do
61
+ subject { statement.clauses(:baz) }
62
+
63
+ it "selects clauses by type" do
64
+ expect(subject).to eql %w(baz)
65
+ end
66
+ end # context
67
+ end # describe #clauses
68
+
69
+ describe "#<<" do
70
+
71
+ context "new clause" do
72
+ subject { statement << qux }
73
+
74
+ it "adds the clause" do
75
+ expect(subject.clauses).to eql %w(bar baz qux)
76
+ end
77
+ end # context
78
+
79
+ context "existing clause" do
80
+ subject { statement << bar }
81
+
82
+ it "rewrites the clause" do
83
+ expect(subject.clauses).to eql %w(baz bar)
84
+ end
85
+ end
86
+ end # describe #<<
87
+
88
+ end # describe QueryBuilder::Core::Statement
@@ -0,0 +1,12 @@
1
+ # encoding: utf-8
2
+
3
+ describe QueryBuilder::CQL::Operators, ".cql_composite" do
4
+
5
+ let(:arguments) { [:cql_composite] }
6
+
7
+ it_behaves_like :transforming_immutable_data do
8
+ let(:input) { [:foo, :bar, :baz] }
9
+ let(:output) { "(foo, bar, baz)" }
10
+ end
11
+
12
+ end # describe QueryBuilder::CQL::Operators.cql_composite
@@ -0,0 +1,12 @@
1
+ # encoding: utf-8
2
+
3
+ describe QueryBuilder::CQL::Operators, ".cql_dec" do
4
+
5
+ let(:arguments) { [:cql_dec, 4] }
6
+
7
+ it_behaves_like :transforming_immutable_data do
8
+ let(:input) { :foo }
9
+ let(:output) { "foo = foo - 4" }
10
+ end
11
+
12
+ end # describe QueryBuilder::CQL::Operators.cql_dec
@@ -0,0 +1,12 @@
1
+ # encoding: utf-8
2
+
3
+ describe QueryBuilder::CQL::Operators, ".cql_element" do
4
+
5
+ let(:arguments) { [:cql_element, :bar] }
6
+
7
+ it_behaves_like :transforming_immutable_data do
8
+ let(:input) { :foo }
9
+ let(:output) { "foo['bar']" }
10
+ end
11
+
12
+ end # describe QueryBuilder::CQL::Operators.cql_element
@@ -0,0 +1,12 @@
1
+ # encoding: utf-8
2
+
3
+ describe QueryBuilder::CQL::Operators, ".cql_entries" do
4
+
5
+ let(:arguments) { [:cql_entries] }
6
+
7
+ it_behaves_like :transforming_immutable_data do
8
+ let(:input) { :foo }
9
+ let(:output) { "ENTRIES(foo)" }
10
+ end
11
+
12
+ end # describe QueryBuilder::CQL::Operators.cql_entries
@@ -0,0 +1,12 @@
1
+ # encoding: utf-8
2
+
3
+ describe QueryBuilder::CQL::Operators, ".cql_frozen" do
4
+
5
+ let(:arguments) { [:cql_frozen] }
6
+
7
+ it_behaves_like :transforming_immutable_data do
8
+ let(:input) { :foo }
9
+ let(:output) { "FROZEN <foo>" }
10
+ end
11
+
12
+ end # describe QueryBuilder::CQL::Operators.cql_frozen
@@ -0,0 +1,12 @@
1
+ # encoding: utf-8
2
+
3
+ describe QueryBuilder::CQL::Operators, ".cql_full" do
4
+
5
+ let(:arguments) { [:cql_full] }
6
+
7
+ it_behaves_like :transforming_immutable_data do
8
+ let(:input) { :foo }
9
+ let(:output) { "FULL(foo)" }
10
+ end
11
+
12
+ end # describe QueryBuilder::CQL::Operators.cql_full
@@ -0,0 +1,19 @@
1
+ # encoding: utf-8
2
+
3
+ describe QueryBuilder::CQL::Operators, ".cql_gt" do
4
+
5
+ it_behaves_like :transforming_immutable_data do
6
+ let(:arguments) { [:cql_gt, 4] }
7
+
8
+ let(:input) { :foo }
9
+ let(:output) { "foo > 4" }
10
+ end
11
+
12
+ it_behaves_like :transforming_immutable_data do
13
+ let(:arguments) { [:cql_gt, :bar] }
14
+
15
+ let(:input) { :foo }
16
+ let(:output) { "foo > 'bar'" }
17
+ end
18
+
19
+ end # describe QueryBuilder::CQL::Operators.cql_gt
@@ -0,0 +1,19 @@
1
+ # encoding: utf-8
2
+
3
+ describe QueryBuilder::CQL::Operators, ".cql_gte" do
4
+
5
+ it_behaves_like :transforming_immutable_data do
6
+ let(:arguments) { [:cql_gte, 4] }
7
+
8
+ let(:input) { :foo }
9
+ let(:output) { "foo >= 4" }
10
+ end
11
+
12
+ it_behaves_like :transforming_immutable_data do
13
+ let(:arguments) { [:cql_gte, :bar] }
14
+
15
+ let(:input) { :foo }
16
+ let(:output) { "foo >= 'bar'" }
17
+ end
18
+
19
+ end # describe QueryBuilder::CQL::Operators.cql_gte
@@ -0,0 +1,12 @@
1
+ # encoding: utf-8
2
+
3
+ describe QueryBuilder::CQL::Operators, ".cql_in" do
4
+
5
+ let(:arguments) { [:cql_in, :bar, :baz] }
6
+
7
+ it_behaves_like :transforming_immutable_data do
8
+ let(:input) { :foo }
9
+ let(:output) { "foo IN ('bar', 'baz')" }
10
+ end
11
+
12
+ end # describe QueryBuilder::CQL::Operators.cql_in
@@ -0,0 +1,12 @@
1
+ # encoding: utf-8
2
+
3
+ describe QueryBuilder::CQL::Operators, ".cql_inc" do
4
+
5
+ let(:arguments) { [:cql_inc, 4] }
6
+
7
+ it_behaves_like :transforming_immutable_data do
8
+ let(:input) { :foo }
9
+ let(:output) { "foo = foo + 4" }
10
+ end
11
+
12
+ end # describe QueryBuilder::CQL::Operators.cql_inc
@@ -0,0 +1,12 @@
1
+ # encoding: utf-8
2
+
3
+ describe QueryBuilder::CQL::Operators, ".cql_keys" do
4
+
5
+ let(:arguments) { [:cql_keys] }
6
+
7
+ it_behaves_like :transforming_immutable_data do
8
+ let(:input) { :foo }
9
+ let(:output) { "KEYS(foo)" }
10
+ end
11
+
12
+ end # describe QueryBuilder::CQL::Operators.cql_keys
@@ -0,0 +1,12 @@
1
+ # encoding: utf-8
2
+
3
+ describe QueryBuilder::CQL::Operators, ".cql_list" do
4
+
5
+ let(:arguments) { [:cql_list] }
6
+
7
+ it_behaves_like :transforming_immutable_data do
8
+ let(:input) { :int }
9
+ let(:output) { "LIST<int>" }
10
+ end
11
+
12
+ end # describe QueryBuilder::CQL::Operators.cql_list
@@ -0,0 +1,83 @@
1
+ # encoding: utf-8
2
+ require "securerandom"
3
+
4
+ describe QueryBuilder::CQL::Operators, ".cql_literal" do
5
+
6
+ let(:arguments) { [:cql_literal] }
7
+
8
+ it_behaves_like :transforming_immutable_data do
9
+ let(:input) { nil }
10
+ let(:output) { "NaN" }
11
+ end
12
+
13
+ it_behaves_like :transforming_immutable_data do
14
+ let(:input) { :NaN }
15
+ let(:output) { "NaN" }
16
+ end
17
+
18
+ it_behaves_like :transforming_immutable_data do
19
+ let(:input) { "NaN" }
20
+ let(:output) { "NaN" }
21
+ end
22
+
23
+ it_behaves_like :transforming_immutable_data do
24
+ let(:input) { :Infinity }
25
+ let(:output) { "Infinity" }
26
+ end
27
+
28
+ it_behaves_like :transforming_immutable_data do
29
+ let(:input) { "Infinity" }
30
+ let(:output) { "Infinity" }
31
+ end
32
+
33
+ it_behaves_like :transforming_immutable_data do
34
+ let(:input) { SecureRandom.uuid }
35
+ let(:output) { input }
36
+ end
37
+
38
+ it_behaves_like :transforming_immutable_data do
39
+ let(:input) { "0x03" }
40
+ let(:output) { input }
41
+ end
42
+
43
+ it_behaves_like :transforming_immutable_data do
44
+ let(:input) { 10.1 }
45
+ let(:output) { "10.1" }
46
+ end
47
+
48
+ it_behaves_like :transforming_immutable_data do
49
+ let(:input) { true }
50
+ let(:output) { "true" }
51
+ end
52
+
53
+ it_behaves_like :transforming_immutable_data do
54
+ let(:input) { false }
55
+ let(:output) { "false" }
56
+ end
57
+
58
+ it_behaves_like :transforming_immutable_data do
59
+ let(:input) { :true }
60
+ let(:output) { "'true'" }
61
+ end
62
+
63
+ it_behaves_like :transforming_immutable_data do
64
+ let(:input) { "true" }
65
+ let(:output) { "'true'" }
66
+ end
67
+
68
+ it_behaves_like :transforming_immutable_data do
69
+ let(:input) { "d'oh!" }
70
+ let(:output) { "'d''oh!'" }
71
+ end
72
+
73
+ it_behaves_like :transforming_immutable_data do
74
+ let(:input) { { foo: :bar, baz: "0x03", qux: { quxx: true } } }
75
+ let(:output) { "{'foo': 'bar', 'baz': 0x03, 'qux': {'quxx': true}}" }
76
+ end
77
+
78
+ it_behaves_like :transforming_immutable_data do
79
+ let(:input) { [:foo, :bar, baz: "0x03"] }
80
+ let(:output) { "['foo', 'bar', {'baz': 0x03}]" }
81
+ end
82
+
83
+ end # describe QueryBuilder::CQL::Operators.cql_literal