sequel 4.44.0 → 4.45.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.
Files changed (140) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +110 -0
  3. data/README.rdoc +8 -9
  4. data/doc/active_record.rdoc +2 -3
  5. data/doc/model_plugins.rdoc +1 -1
  6. data/doc/opening_databases.rdoc +0 -46
  7. data/doc/release_notes/4.45.0.txt +370 -0
  8. data/lib/sequel/adapters/cubrid.rb +2 -0
  9. data/lib/sequel/adapters/do.rb +2 -0
  10. data/lib/sequel/adapters/jdbc/as400.rb +2 -0
  11. data/lib/sequel/adapters/jdbc/cubrid.rb +2 -0
  12. data/lib/sequel/adapters/jdbc/firebirdsql.rb +2 -0
  13. data/lib/sequel/adapters/jdbc/informix-sqli.rb +2 -0
  14. data/lib/sequel/adapters/jdbc/jdbcprogress.rb +2 -0
  15. data/lib/sequel/adapters/jdbc/mysql.rb +1 -0
  16. data/lib/sequel/adapters/jdbc/postgresql.rb +5 -0
  17. data/lib/sequel/adapters/mysql.rb +1 -0
  18. data/lib/sequel/adapters/mysql2.rb +1 -0
  19. data/lib/sequel/adapters/odbc/oracle.rb +11 -0
  20. data/lib/sequel/adapters/odbc/progress.rb +2 -0
  21. data/lib/sequel/adapters/postgres.rb +0 -2
  22. data/lib/sequel/adapters/shared/cubrid.rb +2 -0
  23. data/lib/sequel/adapters/shared/firebird.rb +2 -0
  24. data/lib/sequel/adapters/shared/informix.rb +2 -0
  25. data/lib/sequel/adapters/shared/mssql.rb +47 -7
  26. data/lib/sequel/adapters/shared/mysql.rb +16 -1
  27. data/lib/sequel/adapters/shared/postgres.rb +9 -1
  28. data/lib/sequel/adapters/shared/progress.rb +2 -0
  29. data/lib/sequel/adapters/shared/sqlanywhere.rb +1 -1
  30. data/lib/sequel/adapters/swift.rb +2 -0
  31. data/lib/sequel/ast_transformer.rb +13 -6
  32. data/lib/sequel/core.rb +13 -16
  33. data/lib/sequel/database/connecting.rb +25 -10
  34. data/lib/sequel/database/dataset.rb +6 -1
  35. data/lib/sequel/database/dataset_defaults.rb +9 -2
  36. data/lib/sequel/database/misc.rb +10 -3
  37. data/lib/sequel/database/schema_methods.rb +4 -0
  38. data/lib/sequel/dataset/mutation.rb +8 -20
  39. data/lib/sequel/dataset/prepared_statements.rb +2 -0
  40. data/lib/sequel/dataset/query.rb +32 -7
  41. data/lib/sequel/dataset/sql.rb +13 -3
  42. data/lib/sequel/deprecated.rb +9 -1
  43. data/lib/sequel/exceptions.rb +37 -8
  44. data/lib/sequel/extensions/_deprecated_identifier_mangling.rb +117 -0
  45. data/lib/sequel/extensions/date_arithmetic.rb +1 -0
  46. data/lib/sequel/extensions/identifier_mangling.rb +3 -2
  47. data/lib/sequel/extensions/pg_hstore.rb +1 -5
  48. data/lib/sequel/extensions/schema_dumper.rb +3 -1
  49. data/lib/sequel/extensions/sequel_3_dataset_methods.rb +2 -2
  50. data/lib/sequel/extensions/string_agg.rb +1 -0
  51. data/lib/sequel/model.rb +23 -10
  52. data/lib/sequel/model/associations.rb +17 -5
  53. data/lib/sequel/model/base.rb +115 -62
  54. data/lib/sequel/model/dataset_module.rb +10 -3
  55. data/lib/sequel/model/exceptions.rb +7 -5
  56. data/lib/sequel/plugins/association_pks.rb +13 -1
  57. data/lib/sequel/plugins/association_proxies.rb +8 -1
  58. data/lib/sequel/plugins/before_after_save.rb +1 -0
  59. data/lib/sequel/plugins/class_table_inheritance.rb +7 -3
  60. data/lib/sequel/plugins/columns_updated.rb +42 -0
  61. data/lib/sequel/plugins/composition.rb +10 -5
  62. data/lib/sequel/plugins/error_splitter.rb +1 -1
  63. data/lib/sequel/plugins/hook_class_methods.rb +39 -5
  64. data/lib/sequel/plugins/instance_hooks.rb +58 -5
  65. data/lib/sequel/plugins/lazy_attributes.rb +10 -5
  66. data/lib/sequel/plugins/nested_attributes.rb +10 -5
  67. data/lib/sequel/plugins/prepared_statements.rb +7 -0
  68. data/lib/sequel/plugins/prepared_statements_associations.rb +2 -0
  69. data/lib/sequel/plugins/prepared_statements_with_pk.rb +2 -0
  70. data/lib/sequel/plugins/schema.rb +2 -0
  71. data/lib/sequel/plugins/scissors.rb +2 -0
  72. data/lib/sequel/plugins/serialization.rb +10 -5
  73. data/lib/sequel/plugins/split_values.rb +5 -1
  74. data/lib/sequel/plugins/static_cache.rb +2 -2
  75. data/lib/sequel/plugins/tactical_eager_loading.rb +1 -1
  76. data/lib/sequel/plugins/validation_contexts.rb +49 -0
  77. data/lib/sequel/plugins/validation_helpers.rb +1 -0
  78. data/lib/sequel/sql.rb +1 -1
  79. data/lib/sequel/version.rb +1 -1
  80. data/spec/adapters/mssql_spec.rb +31 -0
  81. data/spec/adapters/mysql_spec.rb +20 -2
  82. data/spec/adapters/postgres_spec.rb +43 -12
  83. data/spec/adapters/spec_helper.rb +5 -8
  84. data/spec/core/database_spec.rb +47 -12
  85. data/spec/core/dataset_mutation_spec.rb +22 -22
  86. data/spec/core/dataset_spec.rb +88 -20
  87. data/spec/core/deprecated_spec.rb +1 -1
  88. data/spec/core/expression_filters_spec.rb +1 -1
  89. data/spec/core/mock_adapter_spec.rb +0 -3
  90. data/spec/core/placeholder_literalizer_spec.rb +1 -1
  91. data/spec/core/schema_spec.rb +8 -1
  92. data/spec/core/spec_helper.rb +6 -1
  93. data/spec/core_extensions_spec.rb +4 -0
  94. data/spec/deprecation_helper.rb +17 -0
  95. data/spec/extensions/_deprecated_identifier_mangling_spec.rb +314 -0
  96. data/spec/extensions/association_pks_spec.rb +61 -13
  97. data/spec/extensions/association_proxies_spec.rb +3 -3
  98. data/spec/extensions/class_table_inheritance_spec.rb +39 -0
  99. data/spec/extensions/columns_updated_spec.rb +35 -0
  100. data/spec/extensions/composition_spec.rb +6 -1
  101. data/spec/extensions/hook_class_methods_spec.rb +114 -26
  102. data/spec/extensions/identifier_mangling_spec.rb +107 -73
  103. data/spec/extensions/instance_hooks_spec.rb +78 -14
  104. data/spec/extensions/lazy_attributes_spec.rb +8 -2
  105. data/spec/extensions/many_through_many_spec.rb +2 -2
  106. data/spec/extensions/mssql_optimistic_locking_spec.rb +1 -1
  107. data/spec/extensions/nested_attributes_spec.rb +8 -2
  108. data/spec/extensions/pg_array_spec.rb +18 -4
  109. data/spec/extensions/prepared_statements_associations_spec.rb +48 -39
  110. data/spec/extensions/prepared_statements_with_pk_spec.rb +13 -11
  111. data/spec/extensions/query_spec.rb +1 -1
  112. data/spec/extensions/schema_dumper_spec.rb +34 -6
  113. data/spec/extensions/schema_spec.rb +13 -7
  114. data/spec/extensions/scissors_spec.rb +3 -1
  115. data/spec/extensions/sequel_3_dataset_methods_spec.rb +4 -4
  116. data/spec/extensions/serialization_spec.rb +7 -1
  117. data/spec/extensions/set_overrides_spec.rb +2 -2
  118. data/spec/extensions/shared_caching_spec.rb +19 -15
  119. data/spec/extensions/spec_helper.rb +7 -3
  120. data/spec/extensions/split_values_spec.rb +45 -10
  121. data/spec/extensions/string_agg_spec.rb +2 -2
  122. data/spec/extensions/subset_conditions_spec.rb +3 -3
  123. data/spec/extensions/tactical_eager_loading_spec.rb +1 -1
  124. data/spec/extensions/validation_contexts_spec.rb +31 -0
  125. data/spec/guards_helper.rb +2 -0
  126. data/spec/integration/associations_test.rb +22 -20
  127. data/spec/integration/dataset_test.rb +25 -2
  128. data/spec/integration/model_test.rb +1 -1
  129. data/spec/integration/plugin_test.rb +11 -16
  130. data/spec/integration/prepared_statement_test.rb +40 -32
  131. data/spec/integration/spec_helper.rb +5 -8
  132. data/spec/model/association_reflection_spec.rb +4 -0
  133. data/spec/model/associations_spec.rb +37 -10
  134. data/spec/model/base_spec.rb +6 -0
  135. data/spec/model/hooks_spec.rb +56 -35
  136. data/spec/model/model_spec.rb +21 -5
  137. data/spec/model/record_spec.rb +14 -11
  138. data/spec/model/spec_helper.rb +7 -1
  139. data/spec/sequel_warning.rb +11 -0
  140. metadata +13 -3
@@ -8,42 +8,42 @@ describe "Dataset" do
8
8
  @d = Sequel.mock.dataset.from(:x)
9
9
  end
10
10
 
11
- it "should support self-changing select!" do
11
+ deprecated "should support self-changing select!" do
12
12
  @d.select!(:y)
13
13
  @d.sql.must_equal "SELECT y FROM x"
14
14
  end
15
15
 
16
- it "should support self-changing from!" do
16
+ deprecated "should support self-changing from!" do
17
17
  @d.from!(:y)
18
18
  @d.sql.must_equal "SELECT * FROM y"
19
19
  end
20
20
 
21
- it "should support self-changing order!" do
21
+ deprecated "should support self-changing order!" do
22
22
  @d.order!(:y)
23
23
  @d.sql.must_equal "SELECT * FROM x ORDER BY y"
24
24
  end
25
25
 
26
- it "should support self-changing filter!" do
26
+ deprecated "should support self-changing filter!" do
27
27
  @d.filter!(:y => 1)
28
28
  @d.sql.must_equal "SELECT * FROM x WHERE (y = 1)"
29
29
  end
30
30
 
31
- it "should support self-changing filter! with block" do
31
+ deprecated "should support self-changing filter! with block" do
32
32
  @d.filter!{y < 2}
33
33
  @d.sql.must_equal "SELECT * FROM x WHERE (y < 2)"
34
34
  end
35
35
 
36
- it "should raise for ! methods that don't return a dataset" do
36
+ deprecated "should raise for ! methods that don't return a dataset" do
37
37
  proc {@d.opts!}.must_raise(NoMethodError)
38
38
  end
39
39
 
40
- it "should raise for missing methods" do
40
+ deprecated "should raise for missing methods" do
41
41
  proc {@d.xuyz}.must_raise(NoMethodError)
42
42
  proc {@d.xyz!}.must_raise(NoMethodError)
43
43
  proc {@d.xyz?}.must_raise(NoMethodError)
44
44
  end
45
45
 
46
- it "should support chaining of bang methods" do
46
+ deprecated "should support chaining of bang methods" do
47
47
  @d.order!(:y).filter!(:y => 1).sql.must_equal "SELECT * FROM x WHERE (y = 1) ORDER BY y"
48
48
  end
49
49
  end
@@ -53,11 +53,11 @@ describe "Frozen Datasets" do
53
53
  @ds = Sequel.mock[:test].freeze
54
54
  end
55
55
 
56
- it "should have dups not be frozen" do
56
+ deprecated "should have dups not be frozen" do
57
57
  @ds.dup.wont_be :frozen?
58
58
  end
59
59
 
60
- it "should raise an error when calling mutation methods" do
60
+ deprecated "should raise an error when calling mutation methods" do
61
61
  proc{@ds.select!(:a)}.must_raise RuntimeError
62
62
  proc{@ds.row_proc = proc{}}.must_raise RuntimeError
63
63
  proc{@ds.extension! :query}.must_raise RuntimeError
@@ -74,7 +74,7 @@ describe "Dataset mutation methods" do
74
74
  ds.sql
75
75
  end
76
76
 
77
- it "should modify the dataset in place" do
77
+ deprecated "should modify the dataset in place" do
78
78
  dsc = Sequel.mock[:u]
79
79
  dsc.send(:columns=, [:v])
80
80
 
@@ -132,7 +132,7 @@ describe "Dataset mutation methods" do
132
132
  dsc.graph!(dsc, {:b=>:c}, :table_alias=>:foo).ungraphed!.opts[:graph].must_be_nil
133
133
  end
134
134
 
135
- it "should clear the cache" do
135
+ deprecated "should clear the cache" do
136
136
  ds = Sequel.mock[:a]
137
137
  ds.columns
138
138
  ds.send(:cache_set, :columns, [:a])
@@ -145,7 +145,7 @@ describe "Dataset#clone" do
145
145
  @dataset = Sequel.mock.dataset.from(:items)
146
146
  end
147
147
 
148
- it "should copy the dataset opts" do
148
+ deprecated "should copy the dataset opts" do
149
149
  clone = @dataset.clone
150
150
  clone.opts.must_equal @dataset.opts
151
151
  @dataset.filter!(:a => 'b')
@@ -173,20 +173,20 @@ describe "Dataset extensions" do
173
173
  @ds = Sequel.mock.dataset
174
174
  end
175
175
 
176
- it "should have #extension! modify the receiver" do
176
+ deprecated "should have #extension! modify the receiver" do
177
177
  Sequel::Dataset.register_extension(:foo, Module.new{def a; 1; end})
178
178
  @ds.extension!(:foo)
179
179
  @ds.a.must_equal 1
180
180
  end
181
181
 
182
- it "should have #extension! return the receiver" do
182
+ deprecated "should have #extension! return the receiver" do
183
183
  Sequel::Dataset.register_extension(:foo, Module.new{def a; 1; end})
184
184
  @ds.extension!(:foo).must_be_same_as(@ds)
185
185
  end
186
186
  end
187
187
 
188
188
  describe "Dataset#naked!" do
189
- it "should remove any existing row_proc" do
189
+ deprecated "should remove any existing row_proc" do
190
190
  d = Sequel.mock.dataset.with_row_proc(Proc.new{|r| r})
191
191
  d.naked!.row_proc.must_be_nil
192
192
  d.row_proc.must_be_nil
@@ -194,7 +194,7 @@ describe "Dataset#naked!" do
194
194
  end
195
195
 
196
196
  describe "Dataset#row_proc=" do
197
- it "should set the row_proc" do
197
+ deprecated "should set the row_proc" do
198
198
  d = Sequel.mock.dataset.with_row_proc(Proc.new{|r| r})
199
199
  d.row_proc.wont_be_nil
200
200
  d.row_proc = nil
@@ -203,7 +203,7 @@ describe "Dataset#row_proc=" do
203
203
  end
204
204
 
205
205
  describe "Dataset#quote_identifiers=" do
206
- it "should change quote identifiers setting" do
206
+ deprecated "should change quote identifiers setting" do
207
207
  d = Sequel.mock.dataset.with_quote_identifiers(true)
208
208
  d.literal(:a).must_equal '"a"'
209
209
  d.quote_identifiers = false
@@ -212,13 +212,13 @@ describe "Dataset#quote_identifiers=" do
212
212
  end
213
213
 
214
214
  describe "Dataset#from_self!" do
215
- it "should work" do
215
+ deprecated "should work" do
216
216
  Sequel.mock.dataset.from(:test).select(:name).limit(1).from_self!.sql.must_equal 'SELECT * FROM (SELECT name FROM test LIMIT 1) AS t1'
217
217
  end
218
218
  end
219
219
 
220
220
  describe "Sequel Mock Adapter" do
221
- it "should be able to set the rows returned by each on a per dataset basis using _fetch" do
221
+ deprecated "should be able to set the rows returned by each on a per dataset basis using _fetch" do
222
222
  rs = []
223
223
  db = Sequel.mock(:fetch=>{:a=>1})
224
224
  ds = db[:t]
@@ -229,7 +229,7 @@ describe "Sequel Mock Adapter" do
229
229
  rs.must_equal [{:a=>1}, {:b=>2}]
230
230
  end
231
231
 
232
- it "should be able to set the number of rows modified by update and delete on a per dataset basis" do
232
+ deprecated "should be able to set the number of rows modified by update and delete on a per dataset basis" do
233
233
  db = Sequel.mock(:numrows=>2)
234
234
  ds = db[:t]
235
235
  ds.update(:a=>1).must_equal 2
@@ -239,7 +239,7 @@ describe "Sequel Mock Adapter" do
239
239
  ds.delete.must_equal 3
240
240
  end
241
241
 
242
- it "should be able to set the autogenerated primary key returned by insert on a per dataset basis" do
242
+ deprecated "should be able to set the autogenerated primary key returned by insert on a per dataset basis" do
243
243
  db = Sequel.mock(:autoid=>1)
244
244
  ds = db[:t]
245
245
  ds.insert(:a=>1).must_equal 1
@@ -233,6 +233,68 @@ describe "A dataset with multiple tables in its FROM clause" do
233
233
  end
234
234
  end
235
235
 
236
+ describe "A dataset with a limit" do
237
+ before do
238
+ @dataset = Sequel.mock[:a].limit(1)
239
+ end
240
+
241
+ it "should ignore limit if skip_limit_check is used before #update" do
242
+ @dataset.skip_limit_check.update(:a=>1)
243
+ @dataset.db.sqls.must_equal ['UPDATE a SET a = 1']
244
+ end
245
+
246
+ it "should ignore limit if skip_limit_check is used before #delete" do
247
+ @dataset.skip_limit_check.delete
248
+ @dataset.db.sqls.must_equal ['DELETE FROM a']
249
+ end
250
+
251
+ if false #SEQUEL5
252
+ it "should raise on #update" do
253
+ proc{@dataset.update(:a=>1)}.must_raise(Sequel::InvalidOperation)
254
+ end
255
+
256
+ it "should raise on #delete" do
257
+ proc{@dataset.delete}.must_raise(Sequel::InvalidOperation)
258
+ end
259
+
260
+ it "should raise on #truncate" do
261
+ proc{@dataset.truncate}.must_raise(Sequel::InvalidOperation)
262
+ proc{@dataset.skip_limit_check.truncate}.must_raise(Sequel::InvalidOperation)
263
+ end
264
+ end
265
+ end
266
+
267
+ describe "A dataset with an offset" do
268
+ before do
269
+ @dataset = Sequel.mock[:a].offset(1)
270
+ end
271
+
272
+ it "should ignore offset if skip_limit_check is used before #update" do
273
+ @dataset.skip_limit_check.update(:a=>1)
274
+ @dataset.db.sqls.must_equal ['UPDATE a SET a = 1']
275
+ end
276
+
277
+ it "should ignore offset if skip_limit_check is used before #delete" do
278
+ @dataset.skip_limit_check.delete
279
+ @dataset.db.sqls.must_equal ['DELETE FROM a']
280
+ end
281
+
282
+ if false #SEQUEL5
283
+ it "should raise on #update" do
284
+ proc{@dataset.update(:a=>1)}.must_raise(Sequel::InvalidOperation)
285
+ end
286
+
287
+ it "should raise on #delete" do
288
+ proc{@dataset.delete}.must_raise(Sequel::InvalidOperation)
289
+ end
290
+
291
+ it "should raise on #truncate" do
292
+ proc{@dataset.truncate}.must_raise(Sequel::InvalidOperation)
293
+ proc{@dataset.skip_limit_check.truncate}.must_raise(Sequel::InvalidOperation)
294
+ end
295
+ end
296
+ end
297
+
236
298
  describe "Dataset#unused_table_alias" do
237
299
  before do
238
300
  @ds = Sequel.mock.dataset.from(:test)
@@ -498,7 +560,7 @@ describe "Dataset#where" do
498
560
  @dataset.filter(Sequel::SQLFALSE).sql.must_equal "SELECT * FROM test WHERE (1 = 0)"
499
561
  end
500
562
 
501
- it "should allow the use of multiple arguments" do
563
+ deprecated "should allow the use of multiple arguments" do
502
564
  @dataset.filter(:a, :b).sql.must_equal 'SELECT * FROM test WHERE (a AND b)'
503
565
  @dataset.filter(:a, :b=>1).sql.must_equal 'SELECT * FROM test WHERE (a AND (b = 1))'
504
566
  @dataset.filter(:a, Sequel.expr(:c) > 3, :b=>1).sql.must_equal 'SELECT * FROM test WHERE (a AND (c > 3) AND (b = 1))'
@@ -508,6 +570,10 @@ describe "Dataset#where" do
508
570
  @dataset.filter(Sequel.expr(:zz) < 3){yy > 3}.sql.must_equal 'SELECT * FROM test WHERE ((zz < 3) AND (yy > 3))'
509
571
  end
510
572
 
573
+ deprecated "should allow the use of procs" do
574
+ @dataset.filter(proc{yy > 3}).sql.must_equal 'SELECT * FROM test WHERE (yy > 3)'
575
+ end
576
+
511
577
  it "should yield a VirtualRow to the block" do
512
578
  x = nil
513
579
  @dataset.filter{|r| x = r; false}
@@ -3648,7 +3714,7 @@ describe "Dataset prepared statements and bound variables " do
3648
3714
  @db.sqls.must_equal ["SELECT * FROM items"]
3649
3715
  end
3650
3716
 
3651
- it "#call should default to using :all if an invalid type is given" do
3717
+ deprecated "#call should default to using :all if an invalid type is given" do
3652
3718
  @ds.filter(:num=>:$n).call(:select_all, :n=>1)
3653
3719
  @db.sqls.must_equal ['SELECT * FROM items WHERE (num = 1)']
3654
3720
  end
@@ -3698,7 +3764,7 @@ describe "Dataset prepared statements and bound variables " do
3698
3764
  it "should handle usage with Dataset.prepared_statements_module" do
3699
3765
  @ds = @ds.with_extend(Sequel::Dataset.send(:prepared_statements_module, :prepare_bind, [Sequel::Dataset::ArgumentMapper, Sequel::Dataset::PreparedStatementMethods]){def foo; :bar; end})
3700
3766
  @ds.foo.must_equal :bar
3701
- @ds = @ds.clone(:prepared_statement_name => 'foo')
3767
+ @ds = @ds.clone(:prepared_statement_name => 'foo', :prepared_type=>:select)
3702
3768
  @ds.call(:a=>1)
3703
3769
  @db.sqls.must_equal ["foo"]
3704
3770
  end
@@ -3749,7 +3815,7 @@ describe Sequel::Dataset::UnnumberedArgumentMapper do
3749
3815
  "UPDATE items SET num = ? WHERE (num = ?) -- args: [1, 1]"]
3750
3816
  end
3751
3817
 
3752
- it "should handle unrecognized statement types as :all" do
3818
+ deprecated "should handle unrecognized statement types as :all" do
3753
3819
  ps = @ds.prepare(:select_all, :s)
3754
3820
  ps = ps.with_extend(Sequel::Dataset::UnnumberedArgumentMapper)
3755
3821
  sql = ps.prepared_sql
@@ -3900,11 +3966,13 @@ end
3900
3966
 
3901
3967
  describe "Sequel::Dataset#unbind" do
3902
3968
  before do
3903
- @ds = Sequel.mock[:t]
3904
- @u = proc{|ds| ds, bv = ds.unbind; [ds.sql, bv]}
3969
+ deprecated do
3970
+ @ds = Sequel.mock[:t]
3971
+ @u = proc{|ds| ds, bv = ds.unbind; [ds.sql, bv]}
3972
+ end
3905
3973
  end
3906
3974
 
3907
- it "should unbind values assigned to equality and inequality statements" do
3975
+ deprecated "should unbind values assigned to equality and inequality statements" do
3908
3976
  @ds.filter(:foo=>1).unbind.first.sql.must_equal "SELECT * FROM t WHERE (foo = $foo)"
3909
3977
  @ds.exclude(:foo=>1).unbind.first.sql.must_equal "SELECT * FROM t WHERE (foo != $foo)"
3910
3978
  @ds.filter{foo > 1}.unbind.first.sql.must_equal "SELECT * FROM t WHERE (foo > $foo)"
@@ -3913,17 +3981,17 @@ describe "Sequel::Dataset#unbind" do
3913
3981
  @ds.filter{foo <= 1}.unbind.first.sql.must_equal "SELECT * FROM t WHERE (foo <= $foo)"
3914
3982
  end
3915
3983
 
3916
- it "should return variables that could be used bound to recreate the previous query" do
3984
+ deprecated "should return variables that could be used bound to recreate the previous query" do
3917
3985
  @ds.filter(:foo=>1).unbind.last.must_equal(:foo=>1)
3918
3986
  @ds.exclude(:foo=>1).unbind.last.must_equal(:foo=>1)
3919
3987
  end
3920
3988
 
3921
- it "should return variables as symbols" do
3989
+ deprecated "should return variables as symbols" do
3922
3990
  @ds.filter(Sequel.expr(:foo)=>1).unbind.last.must_equal(:foo=>1)
3923
3991
  @ds.exclude(Sequel.expr(:foo__bar)=>1).unbind.last.must_equal(:"foo.bar"=>1)
3924
3992
  end
3925
3993
 
3926
- it "should handle numerics, strings, dates, times, and datetimes" do
3994
+ deprecated "should handle numerics, strings, dates, times, and datetimes" do
3927
3995
  @u[@ds.filter(:foo=>1)].must_equal ["SELECT * FROM t WHERE (foo = $foo)", {:foo=>1}]
3928
3996
  @u[@ds.filter(:foo=>1.0)].must_equal ["SELECT * FROM t WHERE (foo = $foo)", {:foo=>1.0}]
3929
3997
  @u[@ds.filter(:foo=>BigDecimal.new('1.0'))].must_equal ["SELECT * FROM t WHERE (foo = $foo)", {:foo=>BigDecimal.new('1.0')}]
@@ -3935,43 +4003,43 @@ describe "Sequel::Dataset#unbind" do
3935
4003
  @u[@ds.filter(:foo=>dt)].must_equal ["SELECT * FROM t WHERE (foo = $foo)", {:foo=>dt}]
3936
4004
  end
3937
4005
 
3938
- it "should not unbind literal strings" do
4006
+ deprecated "should not unbind literal strings" do
3939
4007
  @u[@ds.filter(:foo=>Sequel.lit('a'))].must_equal ["SELECT * FROM t WHERE (foo = a)", {}]
3940
4008
  end
3941
4009
 
3942
- it "should not unbind Identifiers, QualifiedIdentifiers, or Symbols used as booleans" do
4010
+ deprecated "should not unbind Identifiers, QualifiedIdentifiers, or Symbols used as booleans" do
3943
4011
  @u[@ds.filter(:foo).filter{bar}.filter{foo__bar}].must_equal ["SELECT * FROM t WHERE (foo AND bar AND foo.bar)", {}]
3944
4012
  end
3945
4013
 
3946
- it "should not unbind for values it doesn't understand" do
4014
+ deprecated "should not unbind for values it doesn't understand" do
3947
4015
  @u[@ds.filter(:foo=>Class.new{def sql_literal(ds) 'bar' end}.new)].must_equal ["SELECT * FROM t WHERE (foo = bar)", {}]
3948
4016
  end
3949
4017
 
3950
- it "should handle QualifiedIdentifiers" do
4018
+ deprecated "should handle QualifiedIdentifiers" do
3951
4019
  @u[@ds.filter{foo__bar > 1}].must_equal ["SELECT * FROM t WHERE (foo.bar > $foo.bar)", {:"foo.bar"=>1}]
3952
4020
  end
3953
4021
 
3954
- it "should handle wrapped objects" do
4022
+ deprecated "should handle wrapped objects" do
3955
4023
  @u[@ds.filter{Sequel::SQL::Wrapper.new(foo__bar) > Sequel::SQL::Wrapper.new(1)}].must_equal ["SELECT * FROM t WHERE (foo.bar > $foo.bar)", {:"foo.bar"=>1}]
3956
4024
  end
3957
4025
 
3958
- it "should handle deep nesting" do
4026
+ deprecated "should handle deep nesting" do
3959
4027
  @u[@ds.filter{foo > 1}.and{bar < 2}.or(:baz=>3).and(Sequel.case({~Sequel.expr(:x=>4)=>true}, false))].must_equal ["SELECT * FROM t WHERE ((((foo > $foo) AND (bar < $bar)) OR (baz = $baz)) AND (CASE WHEN (x != $x) THEN 't' ELSE 'f' END))", {:foo=>1, :bar=>2, :baz=>3, :x=>4}]
3960
4028
  end
3961
4029
 
3962
- it "should handle JOIN ON" do
4030
+ deprecated "should handle JOIN ON" do
3963
4031
  @u[@ds.cross_join(:x).join(:a, [:u]).join(:b, [[:c, :d], [:e,1]])].must_equal ["SELECT * FROM t CROSS JOIN x INNER JOIN a USING (u) INNER JOIN b ON ((b.c = a.d) AND (b.e = $b.e))", {:"b.e"=>1}]
3964
4032
  end
3965
4033
 
3966
- it "should raise an UnbindDuplicate exception if same variable is used with multiple different values" do
4034
+ deprecated "should raise an UnbindDuplicate exception if same variable is used with multiple different values" do
3967
4035
  proc{@ds.filter(:foo=>1).or(:foo=>2).unbind}.must_raise(Sequel::UnbindDuplicate)
3968
4036
  end
3969
4037
 
3970
- it "should handle case where the same variable has the same value in multiple places " do
4038
+ deprecated "should handle case where the same variable has the same value in multiple places " do
3971
4039
  @u[@ds.filter(:foo=>1).or(:foo=>1)].must_equal ["SELECT * FROM t WHERE ((foo = $foo) OR (foo = $foo))", {:foo=>1}]
3972
4040
  end
3973
4041
 
3974
- it "should raise Error for unhandled objects inside Identifiers and QualifiedIndentifiers" do
4042
+ deprecated "should raise Error for unhandled objects inside Identifiers and QualifiedIndentifiers" do
3975
4043
  proc{@ds.filter(Sequel::SQL::Identifier.new([]) > 1).unbind}.must_raise(Sequel::Error)
3976
4044
  proc{@ds.filter{foo.qualify({}) > 1}.unbind}.must_raise(Sequel::Error)
3977
4045
  end
@@ -27,7 +27,7 @@ describe "Sequel::Deprecated" do
27
27
 
28
28
  it "should consider two arguments to be a method name and additional text" do
29
29
  @d.deprecate("foo", "Use bar instead")
30
- @output.must_equal ['foo is deprecated and will be removed in a future version of Sequel. Use bar instead.']
30
+ @output.must_equal ['foo is deprecated and will be removed in Sequel 5. Use bar instead.']
31
31
  end
32
32
 
33
33
  it "should include a prefix if set" do
@@ -653,7 +653,7 @@ describe Sequel::SQL::VirtualRow do
653
653
  end
654
654
 
655
655
  it "should handle filtered aggregate function calls" do
656
- @d.l{count{}.*.filter(:a, :b)}.must_equal 'count(*) FILTER (WHERE ("a" AND "b"))'
656
+ @d.l{count{}.*.filter(Sequel.&(:a, :b))}.must_equal 'count(*) FILTER (WHERE ("a" AND "b"))'
657
657
  @d.l{count{}.*.filter(:a=>1)}.must_equal 'count(*) FILTER (WHERE ("a" = 1))'
658
658
  @d.l{count{}.*.filter{b > 1}}.must_equal 'count(*) FILTER (WHERE ("b" > 1))'
659
659
  @d.l{count{}.*.filter(:a=>1){b > 1}}.must_equal 'count(*) FILTER (WHERE (("a" = 1) AND ("b" > 1)))'
@@ -450,10 +450,7 @@ describe "Sequel Mock Adapter" do
450
450
 
451
451
  it "should be able to load dialects based on the database name" do
452
452
  Sequel.mock(:host=>'access').select(Date.new(2011, 12, 13)).sql.must_equal 'SELECT #2011-12-13#'
453
- Sequel.mock(:host=>'cubrid').from(:a).offset(1).with_quote_identifiers(false).sql.must_equal 'SELECT * FROM a LIMIT 1,4294967295'
454
453
  Sequel.mock(:host=>'db2').select(1).sql.must_equal 'SELECT 1 FROM "SYSIBM"."SYSDUMMY1"'
455
- Sequel.mock(:host=>'firebird')[:A].distinct.limit(1, 2).with_quote_identifiers(false).sql.must_equal 'SELECT DISTINCT FIRST 1 SKIP 2 * FROM A'
456
- Sequel.mock(:host=>'informix')[:a].distinct.limit(1, 2).sql.upcase.must_equal 'SELECT SKIP 2 FIRST 1 DISTINCT * FROM A'
457
454
  Sequel.mock(:host=>'mssql', :identifier_mangling=>false)[:A].full_text_search(:B, 'C').with_quote_identifiers(false).sql.must_equal "SELECT * FROM A WHERE (CONTAINS (B, 'C'))"
458
455
  Sequel.mock(:host=>'mysql')[:a].full_text_search(:b, 'c').with_quote_identifiers(false).sql.must_equal "SELECT * FROM a WHERE (MATCH (b) AGAINST ('c'))"
459
456
  Sequel.mock(:host=>'oracle')[:a].limit(1).with_quote_identifiers(false).sql.upcase.must_equal 'SELECT * FROM (SELECT * FROM A) T1 WHERE (ROWNUM <= 1)'
@@ -52,7 +52,7 @@ describe "Dataset::PlaceholderLiteralizer" do
52
52
  it "should handle calls with a placeholders used as filter arguments" do
53
53
  loader = @c.loader(@ds){|pl, ds| ds.where(pl.arg)}
54
54
  loader.first(:id=>1).must_equal @h
55
- loader.first(proc{a(b)}).must_equal @h
55
+ loader.first(Sequel.expr{a(b)}).must_equal @h
56
56
  loader.first("a = 1").must_equal @h
57
57
  @db.sqls.must_equal ["SELECT * FROM items WHERE (id = 1)", "SELECT * FROM items WHERE a(b)", "SELECT * FROM items WHERE (a = 1)"]
58
58
  end
@@ -598,13 +598,20 @@ describe "DB#create_table" do
598
598
  @db.sqls.must_equal ["CREATE TABLE cats (CHECK (price = 100))"]
599
599
  end
600
600
 
601
- it "should accept array constraints" do
601
+ deprecated "should accept array constraints" do
602
602
  @db.create_table(:cats) do
603
603
  check [Sequel.expr(:x) > 0, Sequel.expr(:y) < 1]
604
604
  end
605
605
  @db.sqls.must_equal ["CREATE TABLE cats (CHECK ((x > 0) AND (y < 1)))"]
606
606
  end
607
607
 
608
+ it "should accept expression constraints" do
609
+ @db.create_table(:cats) do
610
+ check Sequel.&(Sequel.expr(:x) > 0, Sequel.expr(:y) < 1)
611
+ end
612
+ @db.sqls.must_equal ["CREATE TABLE cats (CHECK ((x > 0) AND (y < 1)))"]
613
+ end
614
+
608
615
  it "should accept named constraint definitions" do
609
616
  @db.create_table(:cats) do
610
617
  integer :score
@@ -10,13 +10,14 @@ unless Object.const_defined?('Sequel')
10
10
  $:.unshift(File.join(File.dirname(File.expand_path(__FILE__)), "../../lib/"))
11
11
  require 'sequel/core'
12
12
  end
13
- Sequel::Deprecation.backtrace_filter = lambda{|line, lineno| lineno < 4 || line =~ /_spec\.rb/}
14
13
 
15
14
  gem 'minitest'
16
15
  require 'minitest/autorun'
17
16
  require 'minitest/hooks/default'
18
17
  require 'minitest/shared_description'
19
18
 
19
+ require "#{File.dirname(File.dirname(__FILE__))}/deprecation_helper.rb"
20
+
20
21
  class Minitest::HooksSpec
21
22
  def meta_def(obj, name, &block)
22
23
  (class << obj; self end).send(:define_method, name, &block)
@@ -30,6 +31,10 @@ if ENV['SEQUEL_COLUMNS_INTROSPECTION']
30
31
  Sequel::Mock::Dataset.send(:include, Sequel::ColumnsIntrospection)
31
32
  end
32
33
 
34
+ # SEQUEL5: Remove
35
+ output = Sequel::Deprecation.output
36
+ Sequel::Deprecation.output = nil
33
37
  Sequel.quote_identifiers = false
34
38
  Sequel.identifier_input_method = nil
35
39
  Sequel.identifier_output_method = nil
40
+ Sequel::Deprecation.output = output