sequel_core 1.5.1 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. data/CHANGELOG +116 -0
  2. data/COPYING +19 -19
  3. data/README +83 -32
  4. data/Rakefile +9 -20
  5. data/bin/sequel +43 -112
  6. data/doc/cheat_sheet.rdoc +225 -0
  7. data/doc/dataset_filtering.rdoc +257 -0
  8. data/lib/sequel_core/adapters/adapter_skeleton.rb +4 -2
  9. data/lib/sequel_core/adapters/ado.rb +3 -1
  10. data/lib/sequel_core/adapters/db2.rb +4 -2
  11. data/lib/sequel_core/adapters/dbi.rb +127 -113
  12. data/lib/sequel_core/adapters/informix.rb +4 -2
  13. data/lib/sequel_core/adapters/jdbc.rb +5 -3
  14. data/lib/sequel_core/adapters/mysql.rb +112 -46
  15. data/lib/sequel_core/adapters/odbc.rb +5 -7
  16. data/lib/sequel_core/adapters/odbc_mssql.rb +12 -3
  17. data/lib/sequel_core/adapters/openbase.rb +3 -1
  18. data/lib/sequel_core/adapters/oracle.rb +11 -9
  19. data/lib/sequel_core/adapters/postgres.rb +261 -262
  20. data/lib/sequel_core/adapters/sqlite.rb +72 -22
  21. data/lib/sequel_core/connection_pool.rb +140 -73
  22. data/lib/sequel_core/core_ext.rb +201 -66
  23. data/lib/sequel_core/core_sql.rb +123 -153
  24. data/lib/sequel_core/database/schema.rb +156 -0
  25. data/lib/sequel_core/database.rb +321 -338
  26. data/lib/sequel_core/dataset/callback.rb +11 -12
  27. data/lib/sequel_core/dataset/convenience.rb +213 -240
  28. data/lib/sequel_core/dataset/pagination.rb +58 -43
  29. data/lib/sequel_core/dataset/parse_tree_sequelizer.rb +331 -0
  30. data/lib/sequel_core/dataset/query.rb +41 -0
  31. data/lib/sequel_core/dataset/schema.rb +15 -0
  32. data/lib/sequel_core/dataset/sequelizer.rb +41 -373
  33. data/lib/sequel_core/dataset/sql.rb +741 -632
  34. data/lib/sequel_core/dataset.rb +183 -168
  35. data/lib/sequel_core/deprecated.rb +1 -169
  36. data/lib/sequel_core/exceptions.rb +24 -19
  37. data/lib/sequel_core/migration.rb +44 -52
  38. data/lib/sequel_core/object_graph.rb +43 -42
  39. data/lib/sequel_core/pretty_table.rb +71 -76
  40. data/lib/sequel_core/schema/generator.rb +163 -105
  41. data/lib/sequel_core/schema/sql.rb +250 -93
  42. data/lib/sequel_core/schema.rb +2 -8
  43. data/lib/sequel_core/sql.rb +394 -0
  44. data/lib/sequel_core/worker.rb +37 -27
  45. data/lib/sequel_core.rb +99 -45
  46. data/spec/adapters/informix_spec.rb +0 -1
  47. data/spec/adapters/mysql_spec.rb +177 -124
  48. data/spec/adapters/oracle_spec.rb +0 -1
  49. data/spec/adapters/postgres_spec.rb +98 -58
  50. data/spec/adapters/sqlite_spec.rb +45 -4
  51. data/spec/blockless_filters_spec.rb +269 -0
  52. data/spec/connection_pool_spec.rb +21 -18
  53. data/spec/core_ext_spec.rb +169 -19
  54. data/spec/core_sql_spec.rb +56 -49
  55. data/spec/database_spec.rb +78 -17
  56. data/spec/dataset_spec.rb +300 -428
  57. data/spec/migration_spec.rb +1 -1
  58. data/spec/object_graph_spec.rb +5 -11
  59. data/spec/rcov.opts +1 -1
  60. data/spec/schema_generator_spec.rb +16 -4
  61. data/spec/schema_spec.rb +89 -10
  62. data/spec/sequelizer_spec.rb +56 -56
  63. data/spec/spec.opts +0 -5
  64. data/spec/spec_config.rb +7 -0
  65. data/spec/spec_config.rb.example +5 -5
  66. data/spec/spec_helper.rb +6 -0
  67. data/spec/worker_spec.rb +1 -1
  68. metadata +78 -63
@@ -258,4 +258,4 @@ context "Sequel::Migrator" do
258
258
 
259
259
  Sequel::Migrator.apply(@db, '.').should == 5
260
260
  end
261
- end
261
+ end
@@ -62,21 +62,15 @@ describe Sequel::Dataset, " graphing" do
62
62
  end
63
63
 
64
64
  it "#graph should pass all join_conditions to join_table" do
65
- ds = @ds1.graph(@ds2, :x=>:id, :y=>:id)
66
- ['SELECT points.id, points.x, points.y, lines.id AS lines_id, lines.x AS lines_x, lines.y AS lines_y, lines.graph_id FROM points LEFT OUTER JOIN lines ON (lines.x = points.id) AND (lines.y = points.id)',
67
- 'SELECT points.id, points.x, points.y, lines.id AS lines_id, lines.x AS lines_x, lines.y AS lines_y, lines.graph_id FROM points LEFT OUTER JOIN lines ON (lines.y = points.id) AND (lines.x = points.id)'
68
- ].should(include(ds.sql))
65
+ ds = @ds1.graph(@ds2, [[:x, :id], [:y, :id]])
66
+ ds.sql.should == 'SELECT points.id, points.x, points.y, lines.id AS lines_id, lines.x AS lines_x, lines.y AS lines_y, lines.graph_id FROM points LEFT OUTER JOIN lines ON ((lines.x = points.id) AND (lines.y = points.id))'
69
67
  end
70
68
 
71
69
  it "#graph should not add columns if graph is called after set_graph_aliases" do
72
- ds = @ds1.set_graph_aliases(:x=>[:points, :x], :y=>[:lines, :y])
73
- ['SELECT points.x, lines.y FROM points',
74
- 'SELECT lines.y, points.x FROM points'
75
- ].should(include(ds.sql))
70
+ ds = @ds1.set_graph_aliases([[:x,[:points, :x]], [:y,[:lines, :y]]])
71
+ ds.sql.should == 'SELECT points.x, lines.y FROM points'
76
72
  ds = ds.graph(:lines, :x=>:id)
77
- ['SELECT points.x, lines.y FROM points LEFT OUTER JOIN lines ON (lines.x = points.id)',
78
- 'SELECT lines.y, points.x FROM points LEFT OUTER JOIN lines ON (lines.x = points.id)'
79
- ].should(include(ds.sql))
73
+ ds.sql.should == 'SELECT points.x, lines.y FROM points LEFT OUTER JOIN lines ON (lines.x = points.id)'
80
74
  end
81
75
 
82
76
  it "#graph should allow graphing of multiple datasets" do
data/spec/rcov.opts CHANGED
@@ -3,4 +3,4 @@ gems
3
3
  --exclude
4
4
  spec
5
5
  --exclude
6
- 00*
6
+ 00*
@@ -1,7 +1,7 @@
1
1
  require File.join(File.dirname(__FILE__), 'spec_helper')
2
2
 
3
3
  describe Sequel::Schema::Generator do
4
- before :all do
4
+ before do
5
5
  @generator = Sequel::Schema::Generator.new(SchemaDummyDatabase.new) do
6
6
  string :title
7
7
  column :body, :text
@@ -11,6 +11,7 @@ describe Sequel::Schema::Generator do
11
11
  constraint(:xxx) {:yyy == :zzz}
12
12
  index :title
13
13
  index [:title, :body]
14
+ foreign_key :node_id, :nodes
14
15
  end
15
16
  @columns, @indexes = @generator.create_info
16
17
  end
@@ -22,7 +23,7 @@ describe Sequel::Schema::Generator do
22
23
  end
23
24
 
24
25
  it "counts primary key, column and constraint definitions as columns" do
25
- @columns.size.should == 6
26
+ @columns.size.should == 7
26
27
  end
27
28
 
28
29
  it "places primary key first" do
@@ -45,6 +46,13 @@ describe Sequel::Schema::Generator do
45
46
  it "creates foreign key column" do
46
47
  @columns[3][:name].should == :parent_id
47
48
  @columns[3][:type].should == :integer
49
+ @columns[6][:name].should == :node_id
50
+ @columns[6][:type].should == :integer
51
+ end
52
+
53
+ it "uses table for foreign key columns, if specified" do
54
+ @columns[6][:table].should == :nodes
55
+ @columns[3][:table].should == nil
48
56
  end
49
57
 
50
58
  it "finds columns" do
@@ -72,7 +80,7 @@ describe Sequel::Schema::Generator do
72
80
  end
73
81
 
74
82
  describe Sequel::Schema::AlterTableGenerator do
75
- before :all do
83
+ before do
76
84
  @generator = Sequel::Schema::AlterTableGenerator.new(SchemaDummyDatabase.new) do
77
85
  add_column :aaa, :text
78
86
  drop_column :bbb
@@ -87,6 +95,8 @@ describe Sequel::Schema::AlterTableGenerator do
87
95
  add_index :blah, :where => {:something => true}
88
96
  add_constraint :con1, ':fred > 100'
89
97
  drop_constraint :con2
98
+ add_primary_key :id
99
+ add_foreign_key :node_id, :nodes
90
100
  end
91
101
  end
92
102
 
@@ -104,7 +114,9 @@ describe Sequel::Schema::AlterTableGenerator do
104
114
  {:op => :add_index, :columns => [:blah], :type => :hash},
105
115
  {:op => :add_index, :columns => [:blah], :where => {:something => true}},
106
116
  {:op => :add_constraint, :type => :check, :name => :con1, :check => [':fred > 100']},
107
- {:op => :drop_constraint, :name => :con2}
117
+ {:op => :drop_constraint, :name => :con2},
118
+ {:op => :add_column, :name => :id, :type => :integer, :primary_key=>true, :auto_increment=>true},
119
+ {:op => :add_column, :name => :node_id, :type => :integer, :table=>:nodes}
108
120
  ]
109
121
  end
110
122
  end
data/spec/schema_spec.rb CHANGED
@@ -110,12 +110,26 @@ context "DB#create_table" do
110
110
  @db.sqls.should == ["CREATE TABLE cats (name varchar(102))"]
111
111
  end
112
112
 
113
- specify "should accept foreign keys" do
113
+ specify "should accept foreign keys without options" do
114
+ @db.create_table(:cats) do
115
+ foreign_key :project_id
116
+ end
117
+ @db.sqls.should == ["CREATE TABLE cats (project_id integer)"]
118
+ end
119
+
120
+ specify "should accept foreign keys with options" do
114
121
  @db.create_table(:cats) do
115
122
  foreign_key :project_id, :table => :projects
116
123
  end
117
124
  @db.sqls.should == ["CREATE TABLE cats (project_id integer REFERENCES projects)"]
118
125
  end
126
+
127
+ specify "should accept foreign keys with separate table argument" do
128
+ @db.create_table(:cats) do
129
+ foreign_key :project_id, :projects, :default=>3
130
+ end
131
+ @db.sqls.should == ["CREATE TABLE cats (project_id integer DEFAULT 3 REFERENCES projects)"]
132
+ end
119
133
 
120
134
  specify "should accept foreign keys with arbitrary keys" do
121
135
  @db.create_table(:cats) do
@@ -264,14 +278,15 @@ context "DB#create_table" do
264
278
  @db.sqls.should == ["CREATE TABLE cats (id integer)", "CREATE UNIQUE INDEX cats_id_name_index ON cats (id, name)"]
265
279
  end
266
280
 
267
- specify "should accept unnamed constraint definitions" do
281
+ pt_specify "should accept unnamed constraint definitions with blocks" do
268
282
  @db.create_table(:cats) do
269
283
  integer :score
270
284
  check {:x > 0 && :y < 1}
271
285
  end
272
- @db.sqls.should == ["CREATE TABLE cats (score integer, CHECK (((x > 0) AND (y < 1))))"]
273
- @db.sqls.clear
286
+ @db.sqls.should == ["CREATE TABLE cats (score integer, CHECK ((x > 0) AND (y < 1)))"]
287
+ end
274
288
 
289
+ specify "should accept unnamed constraint definitions" do
275
290
  @db.create_table(:cats) do
276
291
  check 'price < ?', 100
277
292
  end
@@ -284,12 +299,13 @@ context "DB#create_table" do
284
299
  constraint :valid_score, 'score <= 100'
285
300
  end
286
301
  @db.sqls.should == ["CREATE TABLE cats (score integer, CONSTRAINT valid_score CHECK (score <= 100))"]
287
- @db.sqls.clear
302
+ end
288
303
 
304
+ pt_specify "should accept named constraint definitions with block" do
289
305
  @db.create_table(:cats) do
290
306
  constraint(:blah_blah) {:x > 0 && :y < 1}
291
307
  end
292
- @db.sqls.should == ["CREATE TABLE cats (CONSTRAINT blah_blah CHECK (((x > 0) AND (y < 1))))"]
308
+ @db.sqls.should == ["CREATE TABLE cats (CONSTRAINT blah_blah CHECK ((x > 0) AND (y < 1)))"]
293
309
  end
294
310
  end
295
311
 
@@ -320,24 +336,87 @@ context "DB#alter_table" do
320
336
  @db = SchemaDummyDatabase.new
321
337
  end
322
338
 
323
- specify "should accept add constraint definitions" do
339
+ specify "should support add_column" do
340
+ @db.alter_table(:cats) do
341
+ add_column :score, :integer
342
+ end
343
+ @db.sqls.should == ["ALTER TABLE cats ADD COLUMN score integer"]
344
+ end
345
+
346
+ specify "should support add_constraint" do
324
347
  @db.alter_table(:cats) do
325
348
  add_constraint :valid_score, 'score <= 100'
326
349
  end
327
350
  @db.sqls.should == ["ALTER TABLE cats ADD CONSTRAINT valid_score CHECK (score <= 100)"]
328
- @db.sqls.clear
351
+ end
329
352
 
353
+ pt_specify "should support add_constraint with block" do
330
354
  @db.alter_table(:cats) do
331
355
  add_constraint(:blah_blah) {:x > 0 && :y < 1}
332
356
  end
333
- @db.sqls.should == ["ALTER TABLE cats ADD CONSTRAINT blah_blah CHECK (((x > 0) AND (y < 1)))"]
357
+ @db.sqls.should == ["ALTER TABLE cats ADD CONSTRAINT blah_blah CHECK ((x > 0) AND (y < 1))"]
334
358
  end
335
359
 
336
- specify "should accept drop constraint definitions" do
360
+ specify "should support add_foreign_key" do
361
+ @db.alter_table(:cats) do
362
+ add_foreign_key :node_id, :nodes
363
+ end
364
+ @db.sqls.should == ["ALTER TABLE cats ADD COLUMN node_id integer REFERENCES nodes"]
365
+ end
366
+
367
+ specify "should support add_index" do
368
+ @db.alter_table(:cats) do
369
+ add_index :name
370
+ end
371
+ @db.sqls.should == ["CREATE INDEX cats_name_index ON cats (name)"]
372
+ end
373
+
374
+ specify "should support add_primary_key" do
375
+ @db.alter_table(:cats) do
376
+ add_primary_key :id
377
+ end
378
+ @db.sqls.should == ["ALTER TABLE cats ADD COLUMN id integer PRIMARY KEY AUTOINCREMENT"]
379
+ end
380
+
381
+ specify "should support drop_column" do
382
+ @db.alter_table(:cats) do
383
+ drop_column :score
384
+ end
385
+ @db.sqls.should == ["ALTER TABLE cats DROP COLUMN score"]
386
+ end
387
+
388
+ specify "should support drop_constraint" do
337
389
  @db.alter_table(:cats) do
338
390
  drop_constraint :valid_score
339
391
  end
340
392
  @db.sqls.should == ["ALTER TABLE cats DROP CONSTRAINT valid_score"]
341
393
  end
342
394
 
395
+ specify "should support drop_index" do
396
+ @db.alter_table(:cats) do
397
+ drop_index :name
398
+ end
399
+ @db.sqls.should == ["DROP INDEX cats_name_index"]
400
+ end
401
+
402
+ specify "should support rename_column" do
403
+ @db.alter_table(:cats) do
404
+ rename_column :name, :old_name
405
+ end
406
+ @db.sqls.should == ["ALTER TABLE cats RENAME COLUMN name TO old_name"]
407
+ end
408
+
409
+ specify "should support set_column_default" do
410
+ @db.alter_table(:cats) do
411
+ set_column_default :score, 3
412
+ end
413
+ @db.sqls.should == ["ALTER TABLE cats ALTER COLUMN score SET DEFAULT 3"]
414
+ end
415
+
416
+ specify "should support set_column_type" do
417
+ @db.alter_table(:cats) do
418
+ set_column_type :score, :real
419
+ end
420
+ @db.sqls.should == ["ALTER TABLE cats ALTER COLUMN score TYPE real"]
421
+ end
343
422
  end
@@ -53,7 +53,7 @@ context "Sequelizer without Ruby2Ruby" do
53
53
  $VERBOSE = old_verbose
54
54
  end
55
55
 
56
- specify "should raise error only when using external expressions" do
56
+ pt_specify "should raise error only when using external expressions" do
57
57
  proc {proc {:x > 1}.to_sql(@ds)}.should_not raise_error(Sequel::Error)
58
58
  proc {proc {1 + 1}.to_sql(@ds)}.should raise_error(Sequel::Error)
59
59
  end
@@ -84,7 +84,7 @@ context "Proc#to_sql" do
84
84
  end
85
85
  end
86
86
 
87
- specify "should support <sym> <op> <lit>" do
87
+ pt_specify "should support <sym> <op> <lit>" do
88
88
  proc {:x > 100}.sql.should == '(x > 100)'
89
89
  proc {:x < 100}.sql.should == '(x < 100)'
90
90
  proc {:x >= 100}.sql.should == '(x >= 100)'
@@ -92,27 +92,27 @@ context "Proc#to_sql" do
92
92
  proc {:x == 100}.sql.should == '(x = 100)'
93
93
  end
94
94
 
95
- specify "should support number literals" do
95
+ pt_specify "should support number literals" do
96
96
  proc {:x > 123.45}.sql.should == '(x > 123.45)'
97
97
  proc {:x > -30_000}.sql.should == '(x > -30000)'
98
98
  end
99
99
 
100
- specify "should support string literals" do
100
+ pt_specify "should support string literals" do
101
101
  proc {:x == 'abc'}.sql.should == "(x = 'abc')"
102
102
  proc {:y == "ab'cd"}.sql.should == "(y = 'ab''cd')"
103
103
  end
104
104
 
105
- specify "should support boolean literals" do
105
+ pt_specify "should support boolean literals" do
106
106
  proc {:x == false}.sql.should == "(x = 'f')"
107
107
  proc {:x == true}.sql.should == "(x = 't')"
108
108
  end
109
109
 
110
- specify "should support nil literal and nil?" do
110
+ pt_specify "should support nil literal and nil?" do
111
111
  proc {:x == nil}.sql.should == "(x IS NULL)"
112
112
  proc {:x.nil?}.sql.should == "(x IS NULL)"
113
113
  end
114
114
 
115
- specify "should support local vars or method references" do
115
+ pt_specify "should support local vars or method references" do
116
116
  proc {proc {:x == a}.sql}.should raise_error(NameError)
117
117
  b = 123
118
118
  proc {:x == b}.sql.should == "(x = 123)"
@@ -127,13 +127,13 @@ context "Proc#to_sql" do
127
127
  proc {:x == y2}.sql.should == "(x = 111)"
128
128
  end
129
129
 
130
- specify "sould support subscript access on symbols" do
130
+ pt_specify "sould support subscript access on symbols" do
131
131
  proc {:x|1 > 0}.sql.should == "(x[1] > 0)"
132
132
  proc {:x|2|3 > 0}.sql.should == "(x[2, 3] > 0)"
133
133
  proc {:x|[4, 5] > 0}.sql.should == "(x[4, 5] > 0)"
134
134
  end
135
135
 
136
- specify "should support constants" do
136
+ pt_specify "should support constants" do
137
137
  ZZZ = 444
138
138
  proc {:x == ZZZ}.sql.should == "(x = 444)"
139
139
 
@@ -142,33 +142,33 @@ context "Proc#to_sql" do
142
142
  proc {:x == CCCD::DDD}.sql.should == "(x = 'hi')"
143
143
  end
144
144
 
145
- specify "should support instance attributes" do
145
+ pt_specify "should support instance attributes" do
146
146
  @abc = 123
147
147
  proc {:x == @abc}.sql.should == "(x = 123)"
148
148
  end
149
149
 
150
- specify "should support class attributes" do
150
+ pt_specify "should support class attributes" do
151
151
  @@abc = 321
152
152
  proc {:x == @@abc}.sql.should == "(x = 321)"
153
153
  end
154
154
 
155
- specify "should support like? pattern" do
155
+ pt_specify "should support like? pattern" do
156
156
  proc {:x.like? '%abc'}.sql.should == "(x LIKE '%abc')"
157
157
  end
158
158
 
159
- specify "should support like? pattern with multiple choices" do
159
+ pt_specify "should support like? pattern with multiple choices" do
160
160
  proc {:x.like? ['%abc', '%def', '%ghi']}.sql.should == \
161
161
  "((x LIKE '%abc') OR (x LIKE '%def') OR (x LIKE '%ghi'))"
162
162
  end
163
163
 
164
- specify "should support =~ operator" do
164
+ pt_specify "should support =~ operator" do
165
165
  # stock SQL version does not know about regexps
166
166
  proc {:x =~ '123'}.sql.should == "(x LIKE '123')"
167
167
 
168
168
  proc {:x =~ /^123/}.sql.should == "(x ~ '^123')"
169
169
  end
170
170
 
171
- specify "should support =~ operator with multiple choices" do
171
+ pt_specify "should support =~ operator with multiple choices" do
172
172
  # stock SQL version does not know about regexps
173
173
  proc {:x =~ ['123', '456', '789']}.sql.should == "((x LIKE '123') OR (x LIKE '456') OR (x LIKE '789'))"
174
174
 
@@ -177,101 +177,101 @@ context "Proc#to_sql" do
177
177
  proc {:x =~ [/^123/, '456%', /^789/]}.sql.should == "((x ~ '^123') OR (x LIKE '456%') OR (x ~ '^789'))"
178
178
  end
179
179
 
180
- specify "should raise on =~ operator for unsupported types" do
180
+ pt_specify "should raise on =~ operator for unsupported types" do
181
181
  proc {proc {:x =~ 123}.sql}.should raise_error(Sequel::Error)
182
182
  end
183
183
 
184
- specify "should support != operator" do
184
+ pt_specify "should support != operator" do
185
185
  proc {:x != 100}.sql.should == "(NOT (x = 100))"
186
186
  end
187
187
 
188
- specify "should support != operator with multiple choices" do
188
+ pt_specify "should support != operator with multiple choices" do
189
189
  proc {:x != [100, 200, 300]}.sql.should == "(NOT (x IN (100, 200, 300)))"
190
190
  end
191
191
 
192
- specify "should support !~ operator" do
192
+ pt_specify "should support !~ operator" do
193
193
  proc {:x !~ '123'}.sql.should == "(NOT (x LIKE '123'))"
194
194
  end
195
195
 
196
- specify "should support !~ operator with multiple choices" do
196
+ pt_specify "should support !~ operator with multiple choices" do
197
197
  proc {:x !~ ['123', '456']}.sql.should == "(NOT ((x LIKE '123') OR (x LIKE '456')))"
198
198
  end
199
199
 
200
- specify "should support ! operator" do
200
+ pt_specify "should support ! operator" do
201
201
  proc {!:x}.sql.should == "(x = 'f')"
202
202
  proc {!(:x > 100)}.sql.should == "(NOT (x > 100))"
203
203
  end
204
204
 
205
- specify "should support && operator" do
205
+ pt_specify "should support && operator" do
206
206
  proc {1 && 2}.sql.should == "(1 AND 2)"
207
207
  proc {:x > 100 && :y < 100}.sql.should == "((x > 100) AND (y < 100))"
208
208
  proc {:x && :y && :z}.sql.should == "(x AND (y AND z))"
209
209
  end
210
210
 
211
- specify "should support << operator for assignment" do
211
+ pt_specify "should support << operator for assignment" do
212
212
  proc {:x << 1}.sql.should == "x = 1"
213
213
  end
214
214
 
215
- specify "should concatenate separate statements using AND" do
215
+ pt_specify "should concatenate separate statements using AND" do
216
216
  proc {:x == 20; :y == 30}.sql.should == "((x = 20) AND (y = 30))"
217
217
  proc {:x != 1; :y != 2; :z != 3}.sql.should == \
218
218
  "((NOT (x = 1)) AND (NOT (y = 2)) AND (NOT (z = 3)))"
219
219
  end
220
220
 
221
- specify "should concatenate separate statements using custom join argument" do
221
+ pt_specify "should concatenate separate statements using custom join argument" do
222
222
  proc {:x << 20; :y << 30}.sql_comma_separated.should == "x = 20, y = 30"
223
223
  z = 333
224
224
  proc {:x << :x + 1; :y << z}.sql_comma_separated.should == "x = (x + 1), y = 333"
225
225
  end
226
226
 
227
- specify "should support || operator" do
227
+ pt_specify "should support || operator" do
228
228
  proc {1 || 2}.sql.should == "(1 OR 2)"
229
229
  proc {:x > 100 || :y < 100}.sql.should == "((x > 100) OR (y < 100))"
230
230
  proc {:x || :y || :z}.sql.should == "(x OR (y OR z))"
231
231
  end
232
232
 
233
- specify "should support operator combinations" do
233
+ pt_specify "should support operator combinations" do
234
234
  proc {(:x > 1 || :y > 2) && (:z > 3)}.sql.should == "(((x > 1) OR (y > 2)) AND (z > 3))"
235
235
  proc {(1 && 2) || (3 || 4)}.sql.should == "((1 AND 2) OR (3 OR 4))"
236
236
  proc {(:x != 2) || (:y == 3) || !(:z == 4)}.sql.should == \
237
237
  "((NOT (x = 2)) OR ((y = 3) OR (NOT (z = 4))))"
238
238
  end
239
239
 
240
- specify "should support late bound column references" do
240
+ pt_specify "should support late bound column references" do
241
241
  def abc; :tttt; end
242
242
  proc {abc > 2}.sql.should == "(tttt > 2)"
243
243
  end
244
244
 
245
- specify "should support qualified column references" do
245
+ pt_specify "should support qualified column references" do
246
246
  proc {:x__y > 3}.sql.should == "(x.y > 3)"
247
247
  end
248
248
 
249
- specify "should support functions on columns" do
249
+ pt_specify "should support functions on columns" do
250
250
  proc {:max[:x] > 100}.sql.should == "(max(x) > 100)"
251
251
  proc {:count[:x] > 100}.sql.should == "(count(x) > 100)"
252
252
  end
253
253
 
254
- specify "should support SQL functions" do
254
+ pt_specify "should support SQL functions" do
255
255
  proc {:MAX[:x] > 100}.sql.should == "(MAX(x) > 100)"
256
256
 
257
257
  proc {:MAX[:x__y] > 100}.sql.should == "(MAX(x.y) > 100)"
258
258
  end
259
259
 
260
- specify "should support SQL functions with multiple arguments" do
260
+ pt_specify "should support SQL functions with multiple arguments" do
261
261
  proc {:sum[1, 2, 3] > 100}.sql.should == "(sum(1, 2, 3) > 100)"
262
262
 
263
263
  proc {:x[1, DB[:y].select(:z), "a'b"] > 100}.sql.should == \
264
264
  "(x(1, (SELECT z FROM y), 'a''b') > 100)"
265
265
  end
266
266
 
267
- specify "should support SQL functions without arguments" do
267
+ pt_specify "should support SQL functions without arguments" do
268
268
  proc {:abc[] > 100}.sql.should == "(abc() > 100)"
269
269
 
270
270
  proc {:now[] - :last_stamp > 100}.sql.should == \
271
271
  "((now() - last_stamp) > 100)"
272
272
  end
273
273
 
274
- specify "should do stuff like..." do
274
+ pt_specify "should do stuff like..." do
275
275
  proc {:price < 100 || :category != 'ruby'}.sql.should == \
276
276
  "((price < 100) OR (NOT (category = 'ruby')))"
277
277
  t = Time.now
@@ -281,13 +281,13 @@ context "Proc#to_sql" do
281
281
  proc {1 < :x}.sql.should == "(1 < x)"
282
282
  end
283
283
 
284
- specify "should complain if someone is crazy" do
284
+ pt_specify "should complain if someone is crazy" do
285
285
  proc {proc {def x; 1; end}.sql}.should raise_error(Sequel::Error::InvalidExpression)
286
286
  a = 1
287
287
  proc {proc {a = 1}.sql}.should raise_error(Sequel::Error::InvalidExpression)
288
288
  end
289
289
 
290
- specify "should support comparison to Range objects" do
290
+ pt_specify "should support comparison to Range objects" do
291
291
  proc {:x == (1..10)}.sql.should == \
292
292
  "(x >= 1 AND x <= 10)"
293
293
 
@@ -308,7 +308,7 @@ context "Proc#to_sql" do
308
308
  "(stamp >= #{DS.literal(t1)} AND stamp <= #{DS.literal(t2)})"
309
309
  end
310
310
 
311
- specify "should support comparison to sub-queries" do
311
+ pt_specify "should support comparison to sub-queries" do
312
312
  @ds2 = DB[:test].select(:node_id)
313
313
 
314
314
  proc {:id == @ds2}.sql.should == \
@@ -324,17 +324,17 @@ context "Proc#to_sql" do
324
324
  "(price >= (SELECT price FROM items))"
325
325
  end
326
326
 
327
- specify "should support comparison to arrays" do
327
+ pt_specify "should support comparison to arrays" do
328
328
  proc {:id == [1, 3, 7, 15]}.sql.should == \
329
329
  "(id IN (1, 3, 7, 15))"
330
330
  end
331
331
 
332
- specify "should not literalize String#expr and String#lit" do
332
+ pt_specify "should not literalize String#expr and String#lit" do
333
333
  proc {'x'.lit == 1}.sql.should == "(x = 1)"
334
334
  proc {'x.y'.expr == 1}.sql.should == "(x.y = 1)"
335
335
  end
336
336
 
337
- specify "should support in/in? operator" do
337
+ pt_specify "should support in/in? operator" do
338
338
  proc {:x.in [3, 4, 5]}.sql.should == "(x IN (3, 4, 5))"
339
339
  proc {:x.in?(3, 4, 5)}.sql.should == "(x IN (3, 4, 5))"
340
340
 
@@ -345,7 +345,7 @@ context "Proc#to_sql" do
345
345
  proc {:x.in @ds2}.sql.should == "(x IN (SELECT node_id FROM test))"
346
346
  end
347
347
 
348
- specify "should support nested procs" do
348
+ pt_specify "should support nested procs" do
349
349
  proc {:x > 10 || proc{:y > 20}}.sql.should == \
350
350
  "((x > 10) OR (y > 20))"
351
351
 
@@ -357,7 +357,7 @@ context "Proc#to_sql" do
357
357
  "((x > 10) OR (y > 20))"
358
358
  end
359
359
 
360
- specify "should support unfolding of calls to #each" do
360
+ pt_specify "should support unfolding of calls to #each" do
361
361
  # from http://groups.google.com/group/sequel-talk/browse_thread/thread/54a660568515fbb7
362
362
  periods = [:day, :week, :month, :year, :alltime]
363
363
  idx = 1
@@ -371,7 +371,7 @@ context "Proc#to_sql" do
371
371
  "day[1] = (day[1] + 2), week[1] = (week[1] + 2), month[1] = (month[1] + 2), year[1] = (year[1] + 2), alltime[1] = (alltime[1] + 2)"
372
372
  end
373
373
 
374
- specify "should support unfolding of calls to Hash#each" do
374
+ pt_specify "should support unfolding of calls to Hash#each" do
375
375
  periods = {:month => 3}
376
376
  idx = 1
377
377
  pr = proc do
@@ -382,14 +382,14 @@ context "Proc#to_sql" do
382
382
  pr.sql_comma_separated.should == "month = (month + 3)"
383
383
  end
384
384
 
385
- specify "should support local arguments" do
385
+ pt_specify "should support local arguments" do
386
386
  def t(x)
387
387
  proc {x > 10}.sql
388
388
  end
389
389
  t(:y).should == "(y > 10)"
390
390
  end
391
391
 
392
- specify "should support binary operators on local context" do
392
+ pt_specify "should support binary operators on local context" do
393
393
  XXX = 1
394
394
  YYY = 2
395
395
  proc {XXX || YYY}.sql.should == "(1 OR 2)"
@@ -399,7 +399,7 @@ context "Proc#to_sql" do
399
399
  proc {xxx && yyy}.sql.should == "(1 AND 2)"
400
400
  end
401
401
 
402
- specify "should support arithmetics" do
402
+ pt_specify "should support arithmetics" do
403
403
  zzz = 300
404
404
  proc {(:x + 100) > zzz}.sql.should == "((x + 100) > 300)"
405
405
 
@@ -408,22 +408,22 @@ context "Proc#to_sql" do
408
408
  proc {:units * :price}.sql.should == "(units * price)"
409
409
  end
410
410
 
411
- specify "should support | operator" do
411
+ pt_specify "should support | operator" do
412
412
  proc {(:x | 1) > 0}.sql.should == "(x[1] > 0)"
413
413
  proc {10 | 1}.sql.should == 11
414
414
  end
415
415
 
416
- specify "should support globals" do
416
+ pt_specify "should support globals" do
417
417
  $aaaa_zzzz = 400
418
418
  proc {:x > $aaaa_zzzz}.sql.should == "(x > 400)"
419
419
  end
420
420
 
421
- specify "should support Regexp macros" do
421
+ pt_specify "should support Regexp macros" do
422
422
  "abc" =~ /(ab)/
423
423
  proc {:x == $1}.sql.should == "(x = 'ab')"
424
424
  end
425
425
 
426
- specify "should evaluate expression not referring to symbols or literal strings." do
426
+ pt_specify "should evaluate expression not referring to symbols or literal strings." do
427
427
  proc {:x > 2 * 3}.sql.should == "(x > 6)"
428
428
  y = 3
429
429
  proc {:x > y * 4}.sql.should == "(x > 12)"
@@ -435,14 +435,14 @@ context "Proc#to_sql" do
435
435
  proc {:y == (1 > 2)}.sql.should == "(y = 'f')"
436
436
  end
437
437
 
438
- specify "should support ternary operator" do
438
+ pt_specify "should support ternary operator" do
439
439
  y = true
440
440
  proc {:x > (y ? 1 : 2)}.sql.should == "(x > 1)"
441
441
 
442
442
  proc {((1 > 2) ? :x : :y) > 3}.sql.should == "(y > 3)"
443
443
  end
444
444
 
445
- specify "should support strings with embedded Ruby code in them and literalize them" do
445
+ pt_specify "should support strings with embedded Ruby code in them and literalize them" do
446
446
  proc {:n == "#{1+2}"}.sql.should == "(n = '3')"
447
447
 
448
448
  y = "12'34"
@@ -450,14 +450,14 @@ context "Proc#to_sql" do
450
450
  proc {:x > "#{y}"}.sql.should == "(x > '12''34')"
451
451
  end
452
452
 
453
- specify "should support format strings and literalize the result" do
453
+ pt_specify "should support format strings and literalize the result" do
454
454
  prod = 1
455
455
  proc {:x == "abc%d" % prod}.sql.should == "(x = 'abc1')"
456
456
 
457
457
  proc {:x == ("%d" % prod).lit}.sql.should == "(x = 1)"
458
458
  end
459
459
 
460
- specify "should support conditional filters" do
460
+ pt_specify "should support conditional filters" do
461
461
  @criteria = nil
462
462
  proc {if @criteria; :x.like @criteria; end}.sql.should == nil
463
463
 
@@ -468,7 +468,7 @@ context "Proc#to_sql" do
468
468
  proc {if @criteria; :x.like @criteria; else; :x.like 'ddd'; end}.sql.should == "(x LIKE 'ddd')"
469
469
  end
470
470
 
471
- specify "should support more complex conditional filters" do
471
+ pt_specify "should support more complex conditional filters" do
472
472
  x, y = true, false
473
473
  proc {
474
474
  if x || y
@@ -502,7 +502,7 @@ context "Proc#to_sql" do
502
502
  end
503
503
 
504
504
  context "Proc#to_sql stock" do
505
- specify "should not support regexps" do
505
+ pt_specify "should not support regexps" do
506
506
  db = Sequel::Database.new
507
507
  ds = db[:items]
508
508
 
data/spec/spec.opts CHANGED
@@ -1,5 +0,0 @@
1
- --colour
2
- --backtrace
3
- --format
4
- specdoc
5
- --diff