sequel 0.1.7 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +50 -28
- data/README +1 -1
- data/Rakefile +13 -3
- data/lib/sequel/database.rb +2 -2
- data/lib/sequel/dataset.rb +180 -674
- data/lib/sequel/dataset/dataset_convenience.rb +132 -0
- data/lib/sequel/dataset/dataset_sql.rb +564 -0
- data/lib/sequel/dbi.rb +5 -4
- data/lib/sequel/model.rb +2 -2
- data/lib/sequel/mysql.rb +5 -48
- data/lib/sequel/odbc.rb +7 -12
- data/lib/sequel/postgres.rb +22 -73
- data/lib/sequel/sqlite.rb +54 -15
- data/spec/adapters/sqlite_spec.rb +104 -0
- data/spec/connection_pool_spec.rb +270 -0
- data/spec/core_ext_spec.rb +127 -0
- data/spec/database_spec.rb +366 -0
- data/spec/dataset_spec.rb +1449 -0
- data/spec/expressions_spec.rb +151 -0
- metadata +12 -2
@@ -0,0 +1,151 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '../lib/sequel')
|
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
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.4
|
|
3
3
|
specification_version: 1
|
4
4
|
name: sequel
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.1.
|
7
|
-
date: 2007-
|
6
|
+
version: 0.1.8
|
7
|
+
date: 2007-07-10 00:00:00 +03:00
|
8
8
|
summary: Concise ORM for Ruby.
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -33,11 +33,19 @@ files:
|
|
33
33
|
- README
|
34
34
|
- Rakefile
|
35
35
|
- bin/sequel
|
36
|
+
- spec/adapters
|
37
|
+
- spec/connection_pool_spec.rb
|
38
|
+
- spec/core_ext_spec.rb
|
39
|
+
- spec/database_spec.rb
|
40
|
+
- spec/dataset_spec.rb
|
41
|
+
- spec/expressions_spec.rb
|
42
|
+
- spec/adapters/sqlite_spec.rb
|
36
43
|
- lib/sequel
|
37
44
|
- lib/sequel.rb
|
38
45
|
- lib/sequel/connection_pool.rb
|
39
46
|
- lib/sequel/core_ext.rb
|
40
47
|
- lib/sequel/database.rb
|
48
|
+
- lib/sequel/dataset
|
41
49
|
- lib/sequel/dataset.rb
|
42
50
|
- lib/sequel/dbi.rb
|
43
51
|
- lib/sequel/error.rb
|
@@ -49,6 +57,8 @@ files:
|
|
49
57
|
- lib/sequel/pretty_table.rb
|
50
58
|
- lib/sequel/schema.rb
|
51
59
|
- lib/sequel/sqlite.rb
|
60
|
+
- lib/sequel/dataset/dataset_convenience.rb
|
61
|
+
- lib/sequel/dataset/dataset_sql.rb
|
52
62
|
- CHANGELOG
|
53
63
|
test_files: []
|
54
64
|
|