sequel 0.1.9.12 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +52 -0
- data/README +3 -3
- data/Rakefile +3 -1
- data/lib/sequel.rb +1 -1
- data/lib/sequel/connection_pool.rb +2 -1
- data/lib/sequel/core_ext.rb +22 -20
- data/lib/sequel/database.rb +6 -2
- data/lib/sequel/dataset.rb +6 -4
- data/lib/sequel/dataset/{dataset_convenience.rb → convenience.rb} +0 -0
- data/lib/sequel/dataset/sequelizer.rb +246 -0
- data/lib/sequel/dataset/{dataset_sql.rb → sql.rb} +13 -81
- data/lib/sequel/model.rb +4 -4
- data/lib/sequel/mysql.rb +14 -2
- data/lib/sequel/postgres.rb +5 -7
- data/lib/sequel/schema/schema_generator.rb +1 -2
- data/spec/adapters/mysql_spec.rb +7 -0
- data/spec/adapters/postgres_spec.rb +87 -0
- data/spec/adapters/sqlite_spec.rb +2 -2
- data/spec/connection_pool_spec.rb +2 -2
- data/spec/core_ext_spec.rb +43 -2
- data/spec/database_spec.rb +6 -0
- data/spec/dataset_spec.rb +29 -30
- data/spec/sequelizer_spec.rb +250 -0
- metadata +48 -29
- data/spec/expressions_spec.rb +0 -151
@@ -0,0 +1,250 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'spec_helper')
|
2
|
+
|
3
|
+
context "Proc#to_sql" do
|
4
|
+
DB = Sequel::Database.new
|
5
|
+
DS = DB[:items]
|
6
|
+
|
7
|
+
class ::Proc
|
8
|
+
def to_sql
|
9
|
+
DS.proc_to_sql(self)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
specify "should support <sym> <op> <lit>" do
|
14
|
+
proc {:x > 100}.to_sql.should == '(x > 100)'
|
15
|
+
proc {:x < 100}.to_sql.should == '(x < 100)'
|
16
|
+
proc {:x >= 100}.to_sql.should == '(x >= 100)'
|
17
|
+
proc {:x <= 100}.to_sql.should == '(x <= 100)'
|
18
|
+
proc {:x == 100}.to_sql.should == '(x = 100)'
|
19
|
+
end
|
20
|
+
|
21
|
+
specify "should support number literals" do
|
22
|
+
proc {:x > 123.45}.to_sql.should == '(x > 123.45)'
|
23
|
+
proc {:x > -30_000}.to_sql.should == '(x > -30000)'
|
24
|
+
end
|
25
|
+
|
26
|
+
specify "should support string literals" do
|
27
|
+
proc {:x == 'abc'}.to_sql.should == "(x = 'abc')"
|
28
|
+
proc {:y == "ab'cd"}.to_sql.should == "(y = 'ab''cd')"
|
29
|
+
end
|
30
|
+
|
31
|
+
specify "should support boolean literals" do
|
32
|
+
proc {:x == false}.to_sql.should == "(x = 'f')"
|
33
|
+
proc {:x == true}.to_sql.should == "(x = 't')"
|
34
|
+
end
|
35
|
+
|
36
|
+
specify "should support nil literal and nil?" do
|
37
|
+
proc {:x == nil}.to_sql.should == "(x IS NULL)"
|
38
|
+
proc {:x.nil?}.to_sql.should == "(x IS NULL)"
|
39
|
+
end
|
40
|
+
|
41
|
+
specify "should support local vars or method references" do
|
42
|
+
proc {proc {:x == a}.to_sql}.should raise_error(NameError)
|
43
|
+
b = 123
|
44
|
+
proc {:x == b}.to_sql.should == "(x = 123)"
|
45
|
+
def xyz; 321; end
|
46
|
+
proc {:x == xyz}.to_sql.should == "(x = 321)"
|
47
|
+
proc {:x == xyz.to_s}.to_sql.should == "(x = '321')"
|
48
|
+
end
|
49
|
+
|
50
|
+
specify "should support constants" do
|
51
|
+
ZZZ = 444
|
52
|
+
proc {:x == ZZZ}.to_sql.should == "(x = 444)"
|
53
|
+
|
54
|
+
CCCD = Module.new
|
55
|
+
CCCD::DDD = 'hi'
|
56
|
+
proc {:x == CCCD::DDD}.to_sql.should == "(x = 'hi')"
|
57
|
+
end
|
58
|
+
|
59
|
+
specify "should support instance attributes" do
|
60
|
+
@abc = 123
|
61
|
+
proc {:x == @abc}.to_sql.should == "(x = 123)"
|
62
|
+
end
|
63
|
+
|
64
|
+
specify "should support class attributes" do
|
65
|
+
@@abc = 321
|
66
|
+
proc {:x == @@abc}.to_sql.should == "(x = 321)"
|
67
|
+
end
|
68
|
+
|
69
|
+
specify "should support like? pattern" do
|
70
|
+
proc {:x.like? '%abc'}.to_sql.should == "(x LIKE '%abc')"
|
71
|
+
end
|
72
|
+
|
73
|
+
specify "should support =~ operator" do
|
74
|
+
# stock SQL version does not know about regexps
|
75
|
+
proc {:x =~ '123'}.to_sql.should == "(x LIKE '123')"
|
76
|
+
end
|
77
|
+
|
78
|
+
specify "should raise on =~ operator for unsupported types" do
|
79
|
+
# stock SQL version does not know about regexps
|
80
|
+
proc {proc {:x =~ /123/}.to_sql}.should raise_error(SequelError)
|
81
|
+
proc {proc {:x =~ 123}.to_sql}.should raise_error(SequelError)
|
82
|
+
end
|
83
|
+
|
84
|
+
specify "should support != operator" do
|
85
|
+
proc {:x != 100}.to_sql.should == "(NOT (x = 100))"
|
86
|
+
end
|
87
|
+
|
88
|
+
specify "should support !~ operator" do
|
89
|
+
proc {:x !~ '123'}.to_sql.should == "(NOT (x LIKE '123'))"
|
90
|
+
end
|
91
|
+
|
92
|
+
specify "should support ! operator" do
|
93
|
+
proc {!:x}.to_sql.should == "(x = 'f')"
|
94
|
+
proc {!(:x > 100)}.to_sql.should == "(NOT (x > 100))"
|
95
|
+
end
|
96
|
+
|
97
|
+
specify "should support && operator" do
|
98
|
+
proc {1 && 2}.to_sql.should == "(1 AND 2)"
|
99
|
+
proc {:x > 100 && :y < 100}.to_sql.should == "((x > 100) AND (y < 100))"
|
100
|
+
proc {:x && :y && :z}.to_sql.should == "(x AND (y AND z))"
|
101
|
+
end
|
102
|
+
|
103
|
+
specify "should concatenate separate statements using AND" do
|
104
|
+
proc {:x == 20; :y == 30}.to_sql.should == "((x = 20) AND (y = 30))"
|
105
|
+
proc {:x != 1; :y != 2; :z != 3}.to_sql.should == \
|
106
|
+
"((NOT (x = 1)) AND (NOT (y = 2)) AND (NOT (z = 3)))"
|
107
|
+
end
|
108
|
+
|
109
|
+
specify "should support || operator" do
|
110
|
+
proc {1 || 2}.to_sql.should == "(1 OR 2)"
|
111
|
+
proc {:x > 100 || :y < 100}.to_sql.should == "((x > 100) OR (y < 100))"
|
112
|
+
proc {:x || :y || :z}.to_sql.should == "(x OR (y OR z))"
|
113
|
+
end
|
114
|
+
|
115
|
+
specify "should support operator combinations" do
|
116
|
+
proc {(:x > 1 || :y > 2) && (:z > 3)}.to_sql.should == "(((x > 1) OR (y > 2)) AND (z > 3))"
|
117
|
+
proc {(1 && 2) || (3 || 4)}.to_sql.should == "((1 AND 2) OR (3 OR 4))"
|
118
|
+
proc {(:x != 2) || (:y == 3) || !(:z == 4)}.to_sql.should == \
|
119
|
+
"((NOT (x = 2)) OR ((y = 3) OR (NOT (z = 4))))"
|
120
|
+
end
|
121
|
+
|
122
|
+
specify "should support late bound column references" do
|
123
|
+
def abc; :tttt; end
|
124
|
+
proc {abc > 2}.to_sql.should == "(tttt > 2)"
|
125
|
+
end
|
126
|
+
|
127
|
+
specify "should support qualified column references" do
|
128
|
+
proc {:x__y > 3}.to_sql.should == "(x.y > 3)"
|
129
|
+
end
|
130
|
+
|
131
|
+
specify "should support functions on columns" do
|
132
|
+
proc {:x.MAX > 100}.to_sql.should == "(max(x) > 100)"
|
133
|
+
proc {:x.COUNT > 100}.to_sql.should == "(count(x) > 100)"
|
134
|
+
end
|
135
|
+
|
136
|
+
specify "should support SQL functions" do
|
137
|
+
proc {:MAX[:x] > 100}.to_sql.should == "(MAX(x) > 100)"
|
138
|
+
|
139
|
+
proc {:MAX[:x__y] > 100}.to_sql.should == "(MAX(x.y) > 100)"
|
140
|
+
end
|
141
|
+
|
142
|
+
specify "should support SQL functions with multiple arguments" do
|
143
|
+
proc {:sum[1, 2, 3] > 100}.to_sql.should == "(sum(1, 2, 3) > 100)"
|
144
|
+
|
145
|
+
proc {:x[1, DB[:y].select(:z), "a'b"] > 100}.to_sql.should == \
|
146
|
+
"(x(1, (SELECT z FROM y), 'a''b') > 100)"
|
147
|
+
end
|
148
|
+
|
149
|
+
specify "should do stuff like..." do
|
150
|
+
proc {:price < 100 || :category != 'ruby'}.to_sql.should == \
|
151
|
+
"((price < 100) OR (NOT (category = 'ruby')))"
|
152
|
+
t = Time.now
|
153
|
+
proc {:node_id == 1 && :stamp < t}.to_sql.should == \
|
154
|
+
"((node_id = 1) AND (stamp < #{DS.literal(t)}))"
|
155
|
+
|
156
|
+
proc {1 < :x}.to_sql.should == "(1 < x)"
|
157
|
+
end
|
158
|
+
|
159
|
+
specify "should complain if someone is crazy" do
|
160
|
+
proc {proc {def x; 1; end}.to_sql}.should raise_error(SequelError)
|
161
|
+
a = 1
|
162
|
+
proc {proc {a = 1}.to_sql}.should raise_error(SequelError)
|
163
|
+
end
|
164
|
+
|
165
|
+
specify "should support comparison to Range objects" do
|
166
|
+
proc {:x == (1..10)}.to_sql.should == \
|
167
|
+
"(x >= 1 AND x <= 10)"
|
168
|
+
|
169
|
+
proc {:x == (1...10)}.to_sql.should == \
|
170
|
+
"(x >= 1 AND x < 10)"
|
171
|
+
|
172
|
+
a, b = 3, 5
|
173
|
+
proc {:x == (a..b)}.to_sql.should == \
|
174
|
+
"(x >= 3 AND x <= 5)"
|
175
|
+
|
176
|
+
proc {:x == (a...b)}.to_sql.should == \
|
177
|
+
"(x >= 3 AND x < 5)"
|
178
|
+
end
|
179
|
+
|
180
|
+
specify "should support comparison to sub-queries" do
|
181
|
+
@ds2 = DB[:test].select(:node_id)
|
182
|
+
|
183
|
+
proc {:id == @ds2}.to_sql.should == \
|
184
|
+
"(id IN (SELECT node_id FROM test))"
|
185
|
+
end
|
186
|
+
|
187
|
+
specify "should support comparison to arrays" do
|
188
|
+
proc {:id == [1, 3, 7, 15]}.to_sql.should == \
|
189
|
+
"(id IN (1, 3, 7, 15))"
|
190
|
+
end
|
191
|
+
|
192
|
+
specify "should support in/in? operator" do
|
193
|
+
proc {:x.in [3, 4, 5]}.to_sql.should == "(x IN (3, 4, 5))"
|
194
|
+
proc {:x.in?(3, 4, 5)}.to_sql.should == "(x IN (3, 4, 5))"
|
195
|
+
|
196
|
+
proc {:x.in(1..10)}.to_sql.should == "(x >= 1 AND x <= 10)"
|
197
|
+
proc {:x.in?(1..10)}.to_sql.should == "(x >= 1 AND x <= 10)"
|
198
|
+
|
199
|
+
@ds2 = DB[:test].select(:node_id)
|
200
|
+
proc {:x.in @ds2}.to_sql.should == "(x IN (SELECT node_id FROM test))"
|
201
|
+
end
|
202
|
+
|
203
|
+
specify "should support nested procs" do
|
204
|
+
proc {:x > 10 || proc{:y > 20}}.to_sql.should == \
|
205
|
+
"((x > 10) OR (y > 20))"
|
206
|
+
|
207
|
+
def pr(&block)
|
208
|
+
proc {:x > 10 || block}
|
209
|
+
end
|
210
|
+
|
211
|
+
pr {:y > 20}.to_sql.should == \
|
212
|
+
"((x > 10) OR (y > 20))"
|
213
|
+
end
|
214
|
+
|
215
|
+
specify "should support local arguments" do
|
216
|
+
def t(x)
|
217
|
+
proc {x > 10}.to_sql
|
218
|
+
end
|
219
|
+
t(:y).should == "(y > 10)"
|
220
|
+
end
|
221
|
+
|
222
|
+
specify "should support binary operators on local context" do
|
223
|
+
XXX = 1
|
224
|
+
YYY = 2
|
225
|
+
proc {XXX || YYY}.to_sql.should == "(1 OR 2)"
|
226
|
+
|
227
|
+
xxx = 1
|
228
|
+
yyy = 2
|
229
|
+
proc {xxx && yyy}.to_sql.should == "(1 AND 2)"
|
230
|
+
end
|
231
|
+
|
232
|
+
specify "should support arithmetics" do
|
233
|
+
zzz = 300
|
234
|
+
proc {(:x + 100) > zzz}.to_sql.should == "((x + 100) > 300)"
|
235
|
+
|
236
|
+
proc {(:x + :y * 100) > zzz}.to_sql.should == "((x + (y * 100)) > 300)"
|
237
|
+
|
238
|
+
proc {:units * :price}.to_sql.should == "(units * price)"
|
239
|
+
end
|
240
|
+
|
241
|
+
specify "should support globals" do
|
242
|
+
$aaaa_zzzz = 400
|
243
|
+
proc {:x > $aaaa_zzzz}.to_sql.should == "(x > 400)"
|
244
|
+
end
|
245
|
+
|
246
|
+
specify "should support Regexp macros" do
|
247
|
+
"abc" =~ /(ab)/
|
248
|
+
proc {:x == $1}.to_sql.should == "(x = 'ab')"
|
249
|
+
end
|
250
|
+
end
|
metadata
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.9.
|
2
|
+
rubygems_version: 0.9.2
|
3
3
|
specification_version: 1
|
4
4
|
name: sequel
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.
|
7
|
-
date: 2007-
|
6
|
+
version: 0.2.0
|
7
|
+
date: 2007-09-03 00:00:00 +03:00
|
8
8
|
summary: Lightweight ORM library for Ruby
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -33,45 +33,46 @@ files:
|
|
33
33
|
- README
|
34
34
|
- Rakefile
|
35
35
|
- bin/sequel
|
36
|
-
-
|
37
|
-
- spec/adapters
|
36
|
+
- spec/dataset_spec.rb
|
38
37
|
- spec/connection_pool_spec.rb
|
39
|
-
- spec/core_ext_spec.rb
|
40
38
|
- spec/database_spec.rb
|
41
|
-
- spec/
|
42
|
-
- spec/
|
39
|
+
- spec/core_ext_spec.rb
|
40
|
+
- spec/adapters
|
41
|
+
- spec/adapters/sqlite_spec.rb
|
42
|
+
- spec/adapters/mysql_spec.rb
|
43
|
+
- spec/adapters/postgres_spec.rb
|
43
44
|
- spec/migration_spec.rb
|
44
|
-
- spec/model_spec.rb
|
45
|
-
- spec/pretty_table_spec.rb
|
46
|
-
- spec/schema_generator_spec.rb
|
47
45
|
- spec/schema_spec.rb
|
46
|
+
- spec/schema_generator_spec.rb
|
47
|
+
- spec/pretty_table_spec.rb
|
48
48
|
- spec/spec_helper.rb
|
49
|
-
- spec/
|
50
|
-
- spec/
|
49
|
+
- spec/model_spec.rb
|
50
|
+
- spec/sequelizer_spec.rb
|
51
51
|
- lib/sequel
|
52
|
-
- lib/sequel.rb
|
53
|
-
- lib/sequel/
|
54
|
-
- lib/sequel/
|
55
|
-
- lib/sequel/
|
52
|
+
- lib/sequel/pretty_table.rb
|
53
|
+
- lib/sequel/model.rb
|
54
|
+
- lib/sequel/schema.rb
|
55
|
+
- lib/sequel/sqlite.rb
|
56
56
|
- lib/sequel/database.rb
|
57
|
-
- lib/sequel/dataset
|
58
57
|
- lib/sequel/dataset.rb
|
59
|
-
- lib/sequel/
|
58
|
+
- lib/sequel/mysql.rb
|
59
|
+
- lib/sequel/postgres.rb
|
60
|
+
- lib/sequel/connection_pool.rb
|
61
|
+
- lib/sequel/core_ext.rb
|
60
62
|
- lib/sequel/error.rb
|
61
63
|
- lib/sequel/expressions.rb
|
62
|
-
- lib/sequel/
|
63
|
-
- lib/sequel/model.rb
|
64
|
-
- lib/sequel/mysql.rb
|
64
|
+
- lib/sequel/dbi.rb
|
65
65
|
- lib/sequel/odbc.rb
|
66
|
-
- lib/sequel/
|
67
|
-
- lib/sequel/
|
66
|
+
- lib/sequel/dataset
|
67
|
+
- lib/sequel/dataset/sql.rb
|
68
|
+
- lib/sequel/dataset/sequelizer.rb
|
69
|
+
- lib/sequel/dataset/convenience.rb
|
70
|
+
- lib/sequel/migration.rb
|
68
71
|
- lib/sequel/schema
|
69
|
-
- lib/sequel/schema.rb
|
70
|
-
- lib/sequel/sqlite.rb
|
71
|
-
- lib/sequel/dataset/dataset_convenience.rb
|
72
|
-
- lib/sequel/dataset/dataset_sql.rb
|
73
|
-
- lib/sequel/schema/schema_generator.rb
|
74
72
|
- lib/sequel/schema/schema_sql.rb
|
73
|
+
- lib/sequel/schema/schema_generator.rb
|
74
|
+
- lib/sequel/ado.rb
|
75
|
+
- lib/sequel.rb
|
75
76
|
- CHANGELOG
|
76
77
|
test_files: []
|
77
78
|
|
@@ -109,3 +110,21 @@ dependencies:
|
|
109
110
|
- !ruby/object:Gem::Version
|
110
111
|
version: 0.0.0
|
111
112
|
version:
|
113
|
+
- !ruby/object:Gem::Dependency
|
114
|
+
name: ParseTree
|
115
|
+
version_requirement:
|
116
|
+
version_requirements: !ruby/object:Gem::Version::Requirement
|
117
|
+
requirements:
|
118
|
+
- - ">"
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: 0.0.0
|
121
|
+
version:
|
122
|
+
- !ruby/object:Gem::Dependency
|
123
|
+
name: ruby2ruby
|
124
|
+
version_requirement:
|
125
|
+
version_requirements: !ruby/object:Gem::Version::Requirement
|
126
|
+
requirements:
|
127
|
+
- - ">"
|
128
|
+
- !ruby/object:Gem::Version
|
129
|
+
version: 0.0.0
|
130
|
+
version:
|
data/spec/expressions_spec.rb
DELETED
@@ -1,151 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), 'spec_helper')
|
2
|
-
|
3
|
-
context "A Proc object containing a single comparison" do
|
4
|
-
setup do
|
5
|
-
@p1 = proc {a > 1}
|
6
|
-
@e = @p1.to_expressions
|
7
|
-
end
|
8
|
-
|
9
|
-
specify "should compile into an array containing a single expression" do
|
10
|
-
@e.should be_a_kind_of(Array)
|
11
|
-
@e.size.should == 1
|
12
|
-
|
13
|
-
expr = @e.first
|
14
|
-
expr.left.should == :a
|
15
|
-
expr.op.should == :gt
|
16
|
-
expr.right.should == 1
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
context "A Proc object containing numerous expressions" do
|
21
|
-
setup do
|
22
|
-
@p1 = proc {a > 1 && b < 5 && c <=> 4}
|
23
|
-
@e = @p1.to_expressions
|
24
|
-
end
|
25
|
-
|
26
|
-
specify "should compile into a list of expressions" do
|
27
|
-
@e.should be_a_kind_of(Array)
|
28
|
-
@e.size.should == 3
|
29
|
-
|
30
|
-
e1 = @e[0]
|
31
|
-
e1.left.should == :a
|
32
|
-
e1.op.should == :gt
|
33
|
-
e1.right.should == 1
|
34
|
-
|
35
|
-
e2 = @e[1]
|
36
|
-
e2.left.should == :b
|
37
|
-
e2.op.should == :lt
|
38
|
-
e2.right.should == 5
|
39
|
-
|
40
|
-
e3 = @e[2]
|
41
|
-
e3.left.should == :c
|
42
|
-
e3.op.should == :not
|
43
|
-
e3.right.should == 4
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
context "Expression" do
|
48
|
-
setup do
|
49
|
-
@e = Sequel::Dataset::Expression.new(:a)
|
50
|
-
end
|
51
|
-
|
52
|
-
specify "should support ==" do
|
53
|
-
@e == 3
|
54
|
-
@e.op.should == :eql
|
55
|
-
@e.right.should == 3
|
56
|
-
end
|
57
|
-
|
58
|
-
specify "should support <=> (!=)" do
|
59
|
-
@e <=> 3
|
60
|
-
@e.op.should == :not
|
61
|
-
@e.right.should == 3
|
62
|
-
end
|
63
|
-
|
64
|
-
specify "should support >" do
|
65
|
-
@e > 3
|
66
|
-
@e.op.should == :gt
|
67
|
-
@e.right.should == 3
|
68
|
-
end
|
69
|
-
|
70
|
-
specify "should support <" do
|
71
|
-
@e < 3
|
72
|
-
@e.op.should == :lt
|
73
|
-
@e.right.should == 3
|
74
|
-
end
|
75
|
-
|
76
|
-
specify "should support >=" do
|
77
|
-
@e >= 3
|
78
|
-
@e.op.should == :gte
|
79
|
-
@e.right.should == 3
|
80
|
-
end
|
81
|
-
|
82
|
-
specify "should support <=" do
|
83
|
-
@e <= 3
|
84
|
-
@e.op.should == :lte
|
85
|
-
@e.right.should == 3
|
86
|
-
end
|
87
|
-
|
88
|
-
specify "should support =~" do
|
89
|
-
@e =~ 3
|
90
|
-
@e.op.should == :like
|
91
|
-
@e.right.should == 3
|
92
|
-
end
|
93
|
-
|
94
|
-
specify "should support nil?" do
|
95
|
-
@e.nil?
|
96
|
-
@e.op.should == :eql
|
97
|
-
@e.right.should == nil
|
98
|
-
end
|
99
|
-
|
100
|
-
specify "should support in" do
|
101
|
-
@e.in 1..5
|
102
|
-
@e.op.should == :eql
|
103
|
-
@e.right.should == (1..5)
|
104
|
-
end
|
105
|
-
|
106
|
-
specify "should support in?" do
|
107
|
-
@e.in? 1..5
|
108
|
-
@e.op.should == :eql
|
109
|
-
@e.right.should == (1..5)
|
110
|
-
end
|
111
|
-
|
112
|
-
specify "should support like" do
|
113
|
-
@e.like "1028%"
|
114
|
-
@e.op.should == :like
|
115
|
-
@e.right.should == "1028%"
|
116
|
-
end
|
117
|
-
|
118
|
-
specify "should support like?" do
|
119
|
-
@e.like? "1028%"
|
120
|
-
@e.op.should == :like
|
121
|
-
@e.right.should == "1028%"
|
122
|
-
end
|
123
|
-
|
124
|
-
specify "should support is_not" do
|
125
|
-
@e.is_not 5
|
126
|
-
@e.op.should == :not
|
127
|
-
@e.right.should == 5
|
128
|
-
end
|
129
|
-
|
130
|
-
specify "should turn an unknown operator into a qualified field name" do
|
131
|
-
@e.id <=> 5
|
132
|
-
@e.left.should == 'a.id'
|
133
|
-
@e.op.should == :not
|
134
|
-
@e.right.should == 5
|
135
|
-
end
|
136
|
-
end
|
137
|
-
|
138
|
-
context "An invalid expression" do
|
139
|
-
specify "should raise a SequelError" do
|
140
|
-
proc {proc {abc < Object.vzxczs}.to_expressions}.should raise_error(SequelError)
|
141
|
-
end
|
142
|
-
end
|
143
|
-
|
144
|
-
context "Expressions" do
|
145
|
-
specify "should support SUM" do
|
146
|
-
e = proc {SUM(:test) >= 100}.to_expressions.first
|
147
|
-
e.left.should == 'sum(test)'
|
148
|
-
e.op.should == :gte
|
149
|
-
e.right.should == 100
|
150
|
-
end
|
151
|
-
end
|