sequel 4.40.0 → 4.41.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 (62) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +30 -0
  3. data/Rakefile +6 -3
  4. data/doc/association_basics.rdoc +3 -3
  5. data/doc/opening_databases.rdoc +3 -3
  6. data/doc/release_notes/4.41.0.txt +77 -0
  7. data/doc/schema_modification.rdoc +11 -11
  8. data/lib/sequel/adapters/ado.rb +137 -9
  9. data/lib/sequel/adapters/ado/mssql.rb +1 -1
  10. data/lib/sequel/adapters/jdbc.rb +1 -1
  11. data/lib/sequel/adapters/mysql2.rb +0 -1
  12. data/lib/sequel/adapters/shared/db2.rb +30 -10
  13. data/lib/sequel/adapters/shared/mssql.rb +11 -6
  14. data/lib/sequel/database/query.rb +3 -6
  15. data/lib/sequel/database/schema_generator.rb +7 -1
  16. data/lib/sequel/database/schema_methods.rb +0 -6
  17. data/lib/sequel/dataset/actions.rb +4 -4
  18. data/lib/sequel/dataset/graph.rb +3 -2
  19. data/lib/sequel/dataset/misc.rb +23 -0
  20. data/lib/sequel/dataset/mutation.rb +15 -14
  21. data/lib/sequel/dataset/query.rb +25 -5
  22. data/lib/sequel/extensions/constraint_validations.rb +1 -3
  23. data/lib/sequel/extensions/sql_comments.rb +6 -1
  24. data/lib/sequel/model/associations.rb +7 -1
  25. data/lib/sequel/model/base.rb +1 -1
  26. data/lib/sequel/plugins/class_table_inheritance.rb +6 -6
  27. data/lib/sequel/plugins/hook_class_methods.rb +2 -2
  28. data/lib/sequel/plugins/json_serializer.rb +29 -7
  29. data/lib/sequel/version.rb +1 -1
  30. data/spec/adapters/firebird_spec.rb +2 -8
  31. data/spec/adapters/mssql_spec.rb +12 -12
  32. data/spec/adapters/mysql_spec.rb +11 -11
  33. data/spec/adapters/postgres_spec.rb +8 -9
  34. data/spec/adapters/spec_helper.rb +1 -0
  35. data/spec/adapters/sqlite_spec.rb +1 -3
  36. data/spec/core/database_spec.rb +3 -2
  37. data/spec/core/dataset_spec.rb +66 -22
  38. data/spec/core/expression_filters_spec.rb +4 -0
  39. data/spec/core/mock_adapter_spec.rb +1 -1
  40. data/spec/core/schema_generator_spec.rb +1 -1
  41. data/spec/core/schema_spec.rb +10 -1
  42. data/spec/core/spec_helper.rb +1 -0
  43. data/spec/extensions/class_table_inheritance_spec.rb +3 -0
  44. data/spec/extensions/connection_expiration_spec.rb +1 -1
  45. data/spec/extensions/graph_each_spec.rb +6 -0
  46. data/spec/extensions/hook_class_methods_spec.rb +46 -0
  47. data/spec/extensions/json_serializer_spec.rb +8 -3
  48. data/spec/extensions/set_overrides_spec.rb +4 -0
  49. data/spec/extensions/single_table_inheritance_spec.rb +2 -2
  50. data/spec/extensions/spec_helper.rb +1 -0
  51. data/spec/extensions/string_agg_spec.rb +4 -0
  52. data/spec/extensions/uuid_spec.rb +1 -2
  53. data/spec/integration/associations_test.rb +14 -0
  54. data/spec/integration/dataset_test.rb +17 -22
  55. data/spec/integration/schema_test.rb +3 -3
  56. data/spec/integration/spec_helper.rb +1 -0
  57. data/spec/integration/type_test.rb +1 -7
  58. data/spec/model/associations_spec.rb +26 -1
  59. data/spec/model/model_spec.rb +7 -1
  60. data/spec/model/spec_helper.rb +2 -0
  61. data/spec/sequel_warning.rb +4 -0
  62. metadata +6 -3
@@ -192,6 +192,10 @@ describe "Blockless Ruby Filters" do
192
192
  @d.lit(1 + Sequel.lit('?', :x)).must_equal '(1 + x)'
193
193
  end
194
194
 
195
+ it "should raise a NoMethodError if coerce is called with a non-Numeric" do
196
+ proc{Sequel.expr(:x).coerce(:a)}.must_raise NoMethodError
197
+ end
198
+
195
199
  it "should support AND conditions via &" do
196
200
  @d.l(Sequel.expr(:x) & :y).must_equal '(x AND y)'
197
201
  @d.l(Sequel.expr(:x).sql_boolean & :y).must_equal '(x AND y)'
@@ -9,7 +9,7 @@ describe "Sequel Mock Adapter" do
9
9
 
10
10
  it "should support registering mock adapter type" do
11
11
  begin
12
- mod = Module.new do
12
+ Module.new do
13
13
  Sequel::Database.set_shared_adapter_scheme(:foo, self)
14
14
 
15
15
  def self.mock_adapter_setup(db)
@@ -198,6 +198,6 @@ describe "Sequel::Schema::Generator generic type methods" do
198
198
  File :k
199
199
  TrueClass :l
200
200
  FalseClass :m
201
- end.columns.map{|c| c[:type]}.must_equal [String, Integer, Fixnum, :Bignum, Float, BigDecimal, Date, DateTime, Time, Numeric, File, TrueClass, FalseClass]
201
+ end.columns.map{|c| c[:type]}.must_equal [String, Integer, Integer, :Bignum, Float, BigDecimal, Date, DateTime, Time, Numeric, File, TrueClass, FalseClass]
202
202
  end
203
203
  end
@@ -61,7 +61,7 @@ describe "DB#create_table" do
61
61
  File :k
62
62
  TrueClass :l
63
63
  FalseClass :m
64
- column :n, Fixnum
64
+ column :n, Integer
65
65
  primary_key :o, :type=>String
66
66
  foreign_key :p, :f, :type=>Date
67
67
  end
@@ -93,6 +93,15 @@ describe "DB#create_table" do
93
93
  @db.sqls.must_equal ['CREATE TABLE cats (a varchar(50), b text, c char(40), d time, e numeric(11, 2))']
94
94
  end
95
95
 
96
+ it "should allow the use of modifiers with ruby class types" do
97
+ c = Class.new
98
+ def c.name; 'Fixnum'; end
99
+ @db.create_table(:cats) do
100
+ column :a, c
101
+ end
102
+ @db.sqls.must_equal ['CREATE TABLE cats (a integer)']
103
+ end
104
+
96
105
  it "should raise an error if you use a ruby class that isn't handled" do
97
106
  proc{@db.create_table(:cats){column :a, Class}}.must_raise(Sequel::Error)
98
107
  end
@@ -1,4 +1,5 @@
1
1
  require 'rubygems'
2
+ require "#{File.dirname(File.dirname(__FILE__))}/sequel_warning.rb"
2
3
 
3
4
  if ENV['COVERAGE']
4
5
  require File.join(File.dirname(File.expand_path(__FILE__)), "../sequel_coverage")
@@ -57,6 +57,9 @@ describe "class_table_inheritance plugin" do
57
57
  @db.sqls.must_equal ["SELECT employees.id, employees.name, employees.kind, managers.num_staff FROM employees INNER JOIN managers ON (managers.id = employees.id) WHERE (managers.id = 1) LIMIT 1"]
58
58
  Manager.load(:id=>1, :kind=>'Manager', :num_staff=>2).save
59
59
  @db.sqls.must_equal ["UPDATE employees SET kind = 'Manager' WHERE (id = 1)", "UPDATE managers SET num_staff = 2 WHERE (id = 1)"]
60
+ @db.fetch = {:id=>1, :kind=>'Manager', :num_staff=>2}
61
+ Manager.load(:id=>1, :kind=>'Manager', :num_staff=>2).refresh
62
+ @db.sqls.must_equal ["SELECT employees.id, employees.name, employees.kind, managers.num_staff FROM employees INNER JOIN managers ON (managers.id = employees.id) WHERE (managers.id = 1) LIMIT 1"]
60
63
  end
61
64
 
62
65
  it "#cti_base_model should be the model that loaded the plugin" do
@@ -73,7 +73,7 @@ connection_expiration_specs = shared_description do
73
73
  end
74
74
 
75
75
  it "should not leak connection references during disconnect" do
76
- c1, c2 = multiple_connections
76
+ multiple_connections
77
77
  @db.pool.instance_variable_get(:@connection_expiration_timestamps).size.must_equal 2
78
78
  @db.disconnect
79
79
  @db.pool.instance_variable_get(:@connection_expiration_timestamps).size.must_equal 0
@@ -116,4 +116,10 @@ describe Sequel::Dataset, " graphing" do
116
116
  @db.fetch = {:id=>1,:x=>2,:y=>3,:lines_id=>4,:lines_x=>5,:lines_y=>6,:graph_id=>7}
117
117
  @ds1.graph(@ds2, :x=>:id).all.must_equal [{:points=>{:id=>2, :x=>4, :y=>6}, :lines=>{:id=>12, :x=>15, :y=>18, :graph_id=>21}}]
118
118
  end
119
+
120
+ it "#with_sql_each should work normally if the dataset is not graphed" do
121
+ @db.fetch = {:x=>1}
122
+ @db.dataset.with_sql_each('SELECT 1 AS x'){|r| r.must_equal(:x=>1)}
123
+ @db.sqls.must_equal ['SELECT 1 AS x']
124
+ end
119
125
  end
@@ -361,6 +361,52 @@ describe "Model#before_validation && Model#after_validation" do
361
361
  end
362
362
  end
363
363
 
364
+ describe "Model transaction hooks" do
365
+ before do
366
+ DB.reset
367
+
368
+ @c = model_class.call(Sequel::Model(:items)) do
369
+ columns :x
370
+ after_save {DB << "AS"}
371
+ after_destroy {DB << "AD"}
372
+ self.use_transactions = true
373
+ end
374
+ end
375
+
376
+ it "should call after_commit or after_rollback depending on whether the transaction commits or rolls back" do
377
+ @c.after_commit{DB << 'AC'}
378
+ @c.after_rollback{DB << 'AR'}
379
+ m = @c.load(:id => 2233, :x=>123)
380
+
381
+ m.save
382
+ DB.sqls.must_equal ['BEGIN', 'UPDATE items SET x = 123 WHERE (id = 2233)', 'AS', 'COMMIT', 'AC']
383
+
384
+ @c.db.transaction(:rollback=>:always){m.save}
385
+ DB.sqls.must_equal ['BEGIN', 'UPDATE items SET x = 123 WHERE (id = 2233)', 'AS', 'ROLLBACK', 'AR']
386
+
387
+ @c.db.transaction do
388
+ m.save
389
+ DB.sqls.must_equal ['BEGIN', 'UPDATE items SET x = 123 WHERE (id = 2233)', 'AS']
390
+ end
391
+ end
392
+
393
+ it "should call after_destroy_commit or after_destroy_rollback depending on whether the transaction commits or rolls back" do
394
+ @c.after_destroy_commit {DB << 'ADC'}
395
+ @c.after_destroy_rollback{DB << 'ADR'}
396
+
397
+ @c.load(:id => 2233).destroy
398
+ DB.sqls.must_equal ['BEGIN', 'DELETE FROM items WHERE id = 2233', 'AD', 'COMMIT', 'ADC']
399
+
400
+ @c.db.transaction(:rollback=>:always){@c.load(:id => 2233).destroy}
401
+ DB.sqls.must_equal ['BEGIN', 'DELETE FROM items WHERE id = 2233', 'AD', 'ROLLBACK', 'ADR']
402
+
403
+ @c.db.transaction do
404
+ @c.load(:id => 2233).destroy
405
+ DB.sqls.must_equal ['BEGIN', 'DELETE FROM items WHERE id = 2233', 'AD']
406
+ end
407
+ end
408
+ end
409
+
364
410
  describe "Model.has_hooks?" do
365
411
  before do
366
412
  @c = model_class.call(Sequel::Model(:items))
@@ -66,12 +66,12 @@ describe "Sequel::Plugins::JsonSerializer" do
66
66
  end
67
67
 
68
68
  it "should raise an error if attempting to parse json when providing array to non-array association or vice-versa" do
69
- proc{Artist.from_json('{"albums":{"id":1,"name":"RF","artist_id":2,"json_class":"Album"},"id":2,"name":"YJM"}', :associations=>:albums)}.must_raise(Sequel::Error)
70
- proc{Album.from_json('{"artist":[{"id":2,"name":"YJM","json_class":"Artist"}],"id":1,"name":"RF","artist_id":2}', :associations=>:artist)}.must_raise(Sequel::Error)
69
+ proc{Artist.from_json('{"albums":{"id":1,"name":"RF","artist_id":2},"id":2,"name":"YJM"}', :associations=>:albums)}.must_raise(Sequel::Error)
70
+ proc{Album.from_json('{"artist":[{"id":2,"name":"YJM"}],"id":1,"name":"RF","artist_id":2}', :associations=>:artist)}.must_raise(Sequel::Error)
71
71
  end
72
72
 
73
73
  it "should raise an error if attempting to parse an array containing non-hashes" do
74
- proc{Artist.from_json('[{"id":2,"name":"YJM","json_class":"Artist"}, 2]')}.must_raise(Sequel::Error)
74
+ proc{Artist.from_json('[{"id":2,"name":"YJM"}, 2]')}.must_raise(Sequel::Error)
75
75
  end
76
76
 
77
77
  it "should raise an error if attempting to parse invalid JSON" do
@@ -260,6 +260,11 @@ describe "Sequel::Plugins::JsonSerializer" do
260
260
  Album.dataset.to_json(:root=>"bars", :only => :id).to_s.must_equal '{"bars":[{"id":1},{"id":1}]}'
261
261
  end
262
262
 
263
+ it "should use an alias for an included asscociation to qualify an association" do
264
+ JSON.parse(@album.to_json(:include=>Sequel.as(:artist, :singer)).to_s).must_equal JSON.parse('{"id":1,"name":"RF","artist_id":2,"singer":{"id":2,"name":"YJM"}}')
265
+ JSON.parse(@album.to_json(:include=>{Sequel.as(:artist, :singer)=>{:only=>:name}}).to_s).must_equal JSON.parse('{"id":1,"name":"RF","artist_id":2,"singer":{"name":"YJM"}}')
266
+ end
267
+
263
268
  it "should store the default options in json_serializer_opts" do
264
269
  Album.json_serializer_opts.must_equal(:naked=>true)
265
270
  c = Class.new(Album)
@@ -58,4 +58,8 @@ describe "Sequel::Dataset #set_overrides" do
58
58
  @ds.set_overrides!(:x=>1)
59
59
  @ds.insert_sql.must_equal "INSERT INTO items (x) VALUES (1)"
60
60
  end
61
+
62
+ it "should consider dataset with select overrides and default a simple select all" do
63
+ @ds.send(:simple_select_all?).must_equal true
64
+ end
61
65
  end
@@ -30,7 +30,7 @@ describe Sequel::Model, "single table inheritance plugin" do
30
30
  Object.send(:remove_const, :StiTestSub2)
31
31
  class ::StiTestSub1 < StiTest; end
32
32
  class ::StiTestSub2 < StiTest; end
33
- @ds._fetch = [{:blah=>'StiTest'}, {:blah=>'StiTestSub1'}, {:blah=>'StiTestSub2'}]
33
+ StiTest.dataset._fetch = [{:blah=>'StiTest'}, {:blah=>'StiTestSub1'}, {:blah=>'StiTestSub2'}]
34
34
  StiTest.all.collect{|x| x.class}.must_equal [StiTest, StiTestSub1, StiTestSub2]
35
35
  StiTest.dataset.sql.must_equal "SELECT * FROM sti_tests"
36
36
  StiTestSub1.dataset.sql.must_equal "SELECT * FROM sti_tests WHERE (sti_tests.blah IN ('StiTestSub1'))"
@@ -65,7 +65,7 @@ describe Sequel::Model, "single table inheritance plugin" do
65
65
  Object
66
66
  end
67
67
  StiTest.plugin :single_table_inheritance, :kind
68
- @ds._fetch = [{:kind=>''}, {:kind=>nil}]
68
+ StiTest.dataset._fetch = [{:kind=>''}, {:kind=>nil}]
69
69
  StiTest.all.collect{|x| x.class}.must_equal [StiTest, StiTest]
70
70
  called.must_equal false
71
71
  end
@@ -1,4 +1,5 @@
1
1
  require 'rubygems'
2
+ require "#{File.dirname(File.dirname(__FILE__))}/sequel_warning.rb"
2
3
 
3
4
  if ENV['COVERAGE']
4
5
  require File.join(File.dirname(File.expand_path(__FILE__)), "../sequel_coverage")
@@ -66,6 +66,10 @@ describe "string_agg extension" do
66
66
  end
67
67
  end
68
68
 
69
+ it "should raise Sequel::Error on unsupported database" do
70
+ proc{dbf.call(:foo).literal(@sa1)}.must_raise Sequel::Error
71
+ end
72
+
69
73
  it "should handle order without arguments" do
70
74
  db = dbf.call(:postgres)
71
75
  db.literal(@sa1.order).must_equal "string_agg(c, ',')"
@@ -4,7 +4,6 @@ describe "Sequel::Plugins::Uuid" do
4
4
  before do
5
5
  uuid = @uuid = '57308544-4e83-47b8-b87f-6f68b987f4f9'
6
6
  @alt_uuid = 'd5d1ec46-5e8e-4a7b-adc9-50e76b819e19'
7
- dc = Object.new
8
7
  @c = Class.new(Sequel::Model(:t))
9
8
  @c.class_eval do
10
9
  columns :id, :uuid
@@ -49,7 +48,7 @@ describe "Sequel::Plugins::Uuid" do
49
48
  end
50
49
  o = c.create
51
50
  c.db.sqls.first.must_match(/INSERT INTO t \(u\) VALUES \('[-0-9a-f]+'\)/)
52
- o.u.must_match /[-0-9a-f]+/
51
+ o.u.must_match(/[-0-9a-f]+/)
53
52
  end
54
53
  end
55
54
 
@@ -1496,13 +1496,20 @@ BasicRegularAndCompositeKeyAssociations = shared_description do
1496
1496
 
1497
1497
  it "should return no objects if none are associated" do
1498
1498
  @album.artist.must_equal nil
1499
+ @album.artist_dataset.first.must_equal nil
1499
1500
  @artist.first_album.must_equal nil
1501
+ @artist.first_album_dataset.first.must_equal nil
1500
1502
  @artist.albums.must_equal []
1503
+ @artist.albums_dataset.all.must_equal []
1501
1504
  @album.tags.must_equal []
1505
+ @album.tags_dataset.all.must_equal []
1502
1506
  @album.alias_tags.must_equal []
1507
+ @album.alias_tags_dataset.all.must_equal []
1503
1508
  @tag.albums.must_equal []
1509
+ @tag.albums_dataset.all.must_equal []
1504
1510
  unless @no_many_through_many
1505
1511
  @album.first_tag.must_equal nil
1512
+ @album.first_tag_dataset.first.must_equal nil
1506
1513
  end
1507
1514
  end
1508
1515
 
@@ -2245,6 +2252,13 @@ describe "Sequel::Model Composite Key Associations" do
2245
2252
  proc{@artist.remove_album([@album.id1, @album.id2])}.must_raise(Sequel::Error)
2246
2253
  proc{@artist.remove_album(@album)}.must_raise(Sequel::Error)
2247
2254
  end
2255
+
2256
+ it "should not have association method or dataset method return rows with NULL keys" do
2257
+ Album.one_to_many :other_albums, :class=>Album, :key=>[:artist_id1, :artist_id2], :primary_key=>[:artist_id1, :artist_id2]
2258
+ @album.update(:artist_id1=>1)
2259
+ @album.other_albums.must_equal []
2260
+ @album.other_albums_dataset.all.must_equal []
2261
+ end
2248
2262
  end
2249
2263
 
2250
2264
  describe "Sequel::Model pg_array_to_many" do
@@ -108,7 +108,7 @@ describe "Simple Dataset operations" do
108
108
  @ds.all.must_equal [{:id=>1, :number=>11}]
109
109
  end
110
110
 
111
- cspecify "should have update return the number of matched rows", [:do, :mysql], [:ado] do
111
+ cspecify "should have update return the number of matched rows", [:do, :mysql] do
112
112
  @ds.update(:number=>:number).must_equal 1
113
113
  @ds.filter(:id=>1).update(:number=>:number).must_equal 1
114
114
  @ds.filter(:id=>2).update(:number=>:number).must_equal 0
@@ -494,7 +494,7 @@ describe Sequel::Database do
494
494
  end
495
495
 
496
496
  cspecify "should properly escape identifiers", :db2, :oracle, :sqlanywhere do
497
- DB.create_table(:"\\'\"[]"){Integer :id}
497
+ DB.create_table!(:"\\'\"[]"){Integer :id}
498
498
  DB.drop_table(:"\\'\"[]")
499
499
  end
500
500
 
@@ -559,7 +559,7 @@ describe "Simple Dataset operations" do
559
559
  @ds.insert(:number=>1, :flag=>true)
560
560
  @ds.insert(:number=>2, :flag=>false)
561
561
  @ds.insert(:number=>3, :flag=>nil)
562
- @ds.order!(:number)
562
+ @ds = @ds.order(:number)
563
563
  @ds.filter(:flag=>true).map(:number).must_equal [1]
564
564
  @ds.filter(:flag=>false).map(:number).must_equal [2]
565
565
  @ds.filter(:flag=>nil).map(:number).must_equal [3]
@@ -899,7 +899,7 @@ describe Sequel::SQL::Constants do
899
899
  d.to_s.must_equal Date.today.to_s
900
900
  end
901
901
 
902
- cspecify "should have working CURRENT_TIME", [:jdbc, :sqlite], [:mysql2], [:tinytds] do
902
+ cspecify "should have working CURRENT_TIME", [:jdbc, :sqlite], [:mysql2], [:tinytds], [:ado] do
903
903
  @db.create_table!(:constants){Time :t, :only_time=>true}
904
904
  @ds.insert(:t=>Sequel::CURRENT_TIME)
905
905
  (Time.now - @c[@ds.get(:t)]).must_be_close_to 0, 60
@@ -1134,7 +1134,7 @@ describe "Sequel::Dataset main SQL methods" do
1134
1134
  end
1135
1135
 
1136
1136
  it "#select_group should work correctly" do
1137
- @ds.unordered!
1137
+ @ds = @ds.unordered
1138
1138
  @ds.select_group(:a).all.must_equal []
1139
1139
  @ds.insert(20, 30)
1140
1140
  @ds.select_group(:a).all.must_equal [{:a=>20}]
@@ -1145,13 +1145,13 @@ describe "Sequel::Dataset main SQL methods" do
1145
1145
  end
1146
1146
 
1147
1147
  it "#select_group should work correctly when aliasing" do
1148
- @ds.unordered!
1148
+ @ds = @ds.unordered
1149
1149
  @ds.insert(20, 30)
1150
1150
  @ds.select_group(Sequel[:b].as(:c)).all.must_equal [{:c=>30}]
1151
1151
  end
1152
1152
 
1153
1153
  it "#having should work correctly" do
1154
- @ds.unordered!
1154
+ @ds = @ds.unordered
1155
1155
  @ds.select{[b, max(a).as(c)]}.group(:b).having{max(a) > 30}.all.must_equal []
1156
1156
  @ds.insert(20, 30)
1157
1157
  @ds.select{[b, max(a).as(c)]}.group(:b).having{max(a) > 30}.all.must_equal []
@@ -1160,7 +1160,7 @@ describe "Sequel::Dataset main SQL methods" do
1160
1160
  end
1161
1161
 
1162
1162
  cspecify "#having should work without a previous group", :sqlite do
1163
- @ds.unordered!
1163
+ @ds = @ds.unordered
1164
1164
  @ds.select{max(a).as(c)}.having{max(a) > 30}.all.must_equal []
1165
1165
  @ds.insert(20, 30)
1166
1166
  @ds.select{max(a).as(c)}.having{max(a) > 30}.all.must_equal []
@@ -1435,7 +1435,7 @@ describe "Sequel::Dataset DSL support" do
1435
1435
 
1436
1436
  it "should work with multiple value arrays" do
1437
1437
  @ds.insert(20, 10)
1438
- @ds.quote_identifiers = false
1438
+ @ds = @ds.with_quote_identifiers(false)
1439
1439
  @ds.filter([:a, :b]=>[[20, 10]]).all.must_equal [{:a=>20, :b=>10}]
1440
1440
  @ds.filter([:a, :b]=>[[10, 20]]).all.must_equal []
1441
1441
  @ds.filter([:a, :b]=>[[20, 10], [1, 2]]).all.must_equal [{:a=>20, :b=>10}]
@@ -1449,8 +1449,7 @@ describe "Sequel::Dataset DSL support" do
1449
1449
 
1450
1450
  it "should work with IN/NOT in with datasets" do
1451
1451
  @ds.insert(20, 10)
1452
- ds = @ds.unordered
1453
- @ds.quote_identifiers = false
1452
+ ds = @ds.unordered.with_quote_identifiers(false)
1454
1453
 
1455
1454
  @ds.filter(:a=>ds.select(:a)).all.must_equal [{:a=>20, :b=>10}]
1456
1455
  @ds.filter(:a=>ds.select(:a).where(:a=>15)).all.must_equal []
@@ -1474,7 +1473,7 @@ describe "Sequel::Dataset DSL support" do
1474
1473
  @ds.exclude([:a, :b]=>[]).all.must_equal [{:a=>20, :b=>10}]
1475
1474
  end
1476
1475
 
1477
- it "should work empty arrays with nulls" do
1476
+ it "should work empty arrays with nulls when using empty_array_consider_nulls extension" do
1478
1477
  @ds = @ds.extension(:empty_array_consider_nulls)
1479
1478
  @ds.insert(nil, nil)
1480
1479
  @ds.filter(:a=>[]).all.must_equal []
@@ -1492,7 +1491,7 @@ describe "Sequel::Dataset DSL support" do
1492
1491
  end
1493
1492
  end
1494
1493
 
1495
- it "should work empty arrays with nulls and the empty_array_ignore_nulls extension" do
1494
+ it "should work empty arrays with nulls" do
1496
1495
  ds = @ds
1497
1496
  ds.insert(nil, nil)
1498
1497
  ds.filter(:a=>[]).all.must_equal []
@@ -1532,7 +1531,7 @@ describe "SQL Extract Function" do
1532
1531
 
1533
1532
  it "should return the part of the datetime asked for" do
1534
1533
  t = Time.now
1535
- def @ds.supports_timestamp_timezones?() false end
1534
+ @ds = @ds.with_extend(Module.new do def supports_timestamp_timezones?() false end end)
1536
1535
  @ds.insert(t)
1537
1536
  @ds.get{a.extract(:year)}.must_equal t.year
1538
1537
  @ds.get{a.extract(:month)}.must_equal t.month
@@ -1715,20 +1714,16 @@ describe "Dataset identifier methods" do
1715
1714
  end
1716
1715
 
1717
1716
  it "#identifier_output_method should change how identifiers are output" do
1718
- @ds.identifier_output_method = :upcase
1719
- @ds.first.must_equal(:AB=>1)
1720
- @ds.identifier_output_method = :uprev
1721
- @ds.first.must_equal(:BA=>1)
1717
+ @ds.with_identifier_output_method(:upcase).first.must_equal(:AB=>1)
1718
+ @ds.with_identifier_output_method(:uprev).first.must_equal(:BA=>1)
1722
1719
  end
1723
1720
 
1724
1721
  it "should work with a nil identifier_output_method" do
1725
- @ds.identifier_output_method = nil
1726
- [{:ab=>1}, {:AB=>1}].must_include(@ds.first)
1722
+ [{:ab=>1}, {:AB=>1}].must_include(@ds.with_identifier_output_method(nil).first)
1727
1723
  end
1728
1724
 
1729
1725
  it "should work when not quoting identifiers" do
1730
- @ds.quote_identifiers = false
1731
- @ds.first.must_equal(:ab=>1)
1726
+ @ds.with_quote_identifiers(false).first.must_equal(:ab=>1)
1732
1727
  end
1733
1728
  end
1734
1729
 
@@ -33,9 +33,9 @@ describe "Database schema parser" do
33
33
  DB.create_table!(:items){Integer :number}
34
34
  DB.identifier_output_method = @iom
35
35
  DB.identifier_input_method = @iim
36
- ds = DB[:items]
37
- ds.identifier_output_method = :reverse
38
- ds.identifier_input_method = :reverse
36
+ ds = DB[:items].
37
+ with_identifier_output_method(:reverse).
38
+ with_identifier_input_method(:reverse)
39
39
  begin
40
40
  DB.schema(ds, :reload=>true).must_be_kind_of(Array)
41
41
  DB.schema(ds, :reload=>true).first.first.must_equal :number
@@ -1,5 +1,6 @@
1
1
  require 'rubygems'
2
2
  require 'logger'
3
+ require "#{File.dirname(File.dirname(__FILE__))}/sequel_warning.rb"
3
4
 
4
5
  if ENV['COVERAGE']
5
6
  require File.join(File.dirname(File.expand_path(__FILE__)), "../sequel_coverage")
@@ -31,12 +31,6 @@ describe "Supported types" do
31
31
  ds.all.must_equal [{:number=>2}]
32
32
  end
33
33
 
34
- it "should support generic fixnum type" do
35
- ds = create_items_table_with_column(:number, Fixnum)
36
- ds.insert(:number => 2)
37
- ds.all.must_equal [{:number=>2}]
38
- end
39
-
40
34
  it "should support generic bignum type" do
41
35
  ds = create_items_table_with_column(:number, :Bignum)
42
36
  ds.insert(:number => 2**34)
@@ -81,7 +75,7 @@ describe "Supported types" do
81
75
  ds.first[:dat].to_s.must_equal d.to_s
82
76
  end
83
77
 
84
- cspecify "should support generic time type", [:do], [:swift], [:odbc], [:jdbc, :mssql], [:jdbc, :sqlite], [:mysql2], [:tinytds], :oracle do
78
+ cspecify "should support generic time type", [:do], [:swift], [:odbc], [:jdbc, :mssql], [:jdbc, :sqlite], [:mysql2], [:tinytds], :oracle, [:ado] do
85
79
  ds = create_items_table_with_column(:tim, Time, :only_time=>true)
86
80
  t = Sequel::SQLTime.now
87
81
  ds.insert(:tim => t)