sequel 3.37.0 → 3.38.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (129) hide show
  1. data/CHANGELOG +56 -0
  2. data/README.rdoc +82 -58
  3. data/Rakefile +6 -5
  4. data/bin/sequel +1 -1
  5. data/doc/active_record.rdoc +67 -52
  6. data/doc/advanced_associations.rdoc +33 -48
  7. data/doc/association_basics.rdoc +41 -51
  8. data/doc/cheat_sheet.rdoc +21 -21
  9. data/doc/core_extensions.rdoc +374 -0
  10. data/doc/dataset_basics.rdoc +5 -5
  11. data/doc/dataset_filtering.rdoc +47 -43
  12. data/doc/mass_assignment.rdoc +1 -1
  13. data/doc/migration.rdoc +4 -5
  14. data/doc/model_hooks.rdoc +3 -3
  15. data/doc/object_model.rdoc +31 -25
  16. data/doc/opening_databases.rdoc +19 -5
  17. data/doc/prepared_statements.rdoc +2 -2
  18. data/doc/querying.rdoc +109 -52
  19. data/doc/reflection.rdoc +6 -6
  20. data/doc/release_notes/3.38.0.txt +234 -0
  21. data/doc/schema_modification.rdoc +22 -13
  22. data/doc/sharding.rdoc +8 -9
  23. data/doc/sql.rdoc +154 -112
  24. data/doc/testing.rdoc +47 -7
  25. data/doc/thread_safety.rdoc +1 -1
  26. data/doc/transactions.rdoc +1 -1
  27. data/doc/validations.rdoc +1 -1
  28. data/doc/virtual_rows.rdoc +29 -43
  29. data/lib/sequel/adapters/do/postgres.rb +1 -4
  30. data/lib/sequel/adapters/jdbc.rb +14 -3
  31. data/lib/sequel/adapters/jdbc/db2.rb +9 -0
  32. data/lib/sequel/adapters/jdbc/derby.rb +41 -4
  33. data/lib/sequel/adapters/jdbc/jtds.rb +11 -0
  34. data/lib/sequel/adapters/jdbc/postgresql.rb +3 -6
  35. data/lib/sequel/adapters/mock.rb +10 -4
  36. data/lib/sequel/adapters/postgres.rb +1 -28
  37. data/lib/sequel/adapters/shared/mssql.rb +23 -13
  38. data/lib/sequel/adapters/shared/postgres.rb +46 -0
  39. data/lib/sequel/adapters/swift.rb +21 -13
  40. data/lib/sequel/adapters/swift/mysql.rb +1 -0
  41. data/lib/sequel/adapters/swift/postgres.rb +4 -5
  42. data/lib/sequel/adapters/swift/sqlite.rb +2 -1
  43. data/lib/sequel/adapters/tinytds.rb +14 -2
  44. data/lib/sequel/adapters/utils/pg_types.rb +5 -0
  45. data/lib/sequel/core.rb +29 -17
  46. data/lib/sequel/database/query.rb +1 -1
  47. data/lib/sequel/database/schema_generator.rb +3 -0
  48. data/lib/sequel/dataset/actions.rb +5 -6
  49. data/lib/sequel/dataset/query.rb +7 -7
  50. data/lib/sequel/dataset/sql.rb +5 -18
  51. data/lib/sequel/extensions/core_extensions.rb +8 -12
  52. data/lib/sequel/extensions/pg_array.rb +59 -33
  53. data/lib/sequel/extensions/pg_array_ops.rb +32 -4
  54. data/lib/sequel/extensions/pg_auto_parameterize.rb +1 -1
  55. data/lib/sequel/extensions/pg_hstore.rb +32 -17
  56. data/lib/sequel/extensions/pg_hstore_ops.rb +32 -3
  57. data/lib/sequel/extensions/pg_inet.rb +1 -2
  58. data/lib/sequel/extensions/pg_interval.rb +0 -1
  59. data/lib/sequel/extensions/pg_json.rb +41 -23
  60. data/lib/sequel/extensions/pg_range.rb +36 -11
  61. data/lib/sequel/extensions/pg_range_ops.rb +32 -4
  62. data/lib/sequel/extensions/pg_row.rb +572 -0
  63. data/lib/sequel/extensions/pg_row_ops.rb +164 -0
  64. data/lib/sequel/extensions/query.rb +3 -3
  65. data/lib/sequel/extensions/schema_dumper.rb +7 -8
  66. data/lib/sequel/extensions/select_remove.rb +1 -1
  67. data/lib/sequel/model/base.rb +1 -0
  68. data/lib/sequel/no_core_ext.rb +1 -1
  69. data/lib/sequel/plugins/pg_row.rb +121 -0
  70. data/lib/sequel/plugins/pg_typecast_on_load.rb +65 -0
  71. data/lib/sequel/plugins/validation_helpers.rb +31 -0
  72. data/lib/sequel/sql.rb +64 -44
  73. data/lib/sequel/version.rb +1 -1
  74. data/spec/adapters/mssql_spec.rb +37 -12
  75. data/spec/adapters/mysql_spec.rb +39 -75
  76. data/spec/adapters/oracle_spec.rb +11 -11
  77. data/spec/adapters/postgres_spec.rb +414 -237
  78. data/spec/adapters/spec_helper.rb +1 -1
  79. data/spec/adapters/sqlite_spec.rb +14 -14
  80. data/spec/core/database_spec.rb +6 -6
  81. data/spec/core/dataset_spec.rb +169 -205
  82. data/spec/core/expression_filters_spec.rb +182 -295
  83. data/spec/core/object_graph_spec.rb +6 -6
  84. data/spec/core/schema_spec.rb +14 -14
  85. data/spec/core/spec_helper.rb +1 -0
  86. data/spec/{extensions/core_extensions_spec.rb → core_extensions_spec.rb} +208 -14
  87. data/spec/extensions/columns_introspection_spec.rb +5 -5
  88. data/spec/extensions/hook_class_methods_spec.rb +28 -36
  89. data/spec/extensions/many_through_many_spec.rb +4 -4
  90. data/spec/extensions/pg_array_ops_spec.rb +15 -7
  91. data/spec/extensions/pg_array_spec.rb +81 -48
  92. data/spec/extensions/pg_auto_parameterize_spec.rb +2 -2
  93. data/spec/extensions/pg_hstore_ops_spec.rb +13 -9
  94. data/spec/extensions/pg_hstore_spec.rb +66 -65
  95. data/spec/extensions/pg_inet_spec.rb +2 -4
  96. data/spec/extensions/pg_interval_spec.rb +2 -3
  97. data/spec/extensions/pg_json_spec.rb +20 -18
  98. data/spec/extensions/pg_range_ops_spec.rb +11 -4
  99. data/spec/extensions/pg_range_spec.rb +30 -7
  100. data/spec/extensions/pg_row_ops_spec.rb +48 -0
  101. data/spec/extensions/pg_row_plugin_spec.rb +45 -0
  102. data/spec/extensions/pg_row_spec.rb +323 -0
  103. data/spec/extensions/pg_typecast_on_load_spec.rb +58 -0
  104. data/spec/extensions/query_literals_spec.rb +11 -11
  105. data/spec/extensions/query_spec.rb +3 -3
  106. data/spec/extensions/schema_dumper_spec.rb +20 -4
  107. data/spec/extensions/schema_spec.rb +18 -41
  108. data/spec/extensions/select_remove_spec.rb +4 -4
  109. data/spec/extensions/spec_helper.rb +4 -8
  110. data/spec/extensions/to_dot_spec.rb +5 -5
  111. data/spec/extensions/validation_class_methods_spec.rb +28 -16
  112. data/spec/integration/associations_test.rb +20 -20
  113. data/spec/integration/dataset_test.rb +98 -98
  114. data/spec/integration/eager_loader_test.rb +13 -27
  115. data/spec/integration/plugin_test.rb +5 -5
  116. data/spec/integration/prepared_statement_test.rb +22 -13
  117. data/spec/integration/schema_test.rb +28 -18
  118. data/spec/integration/spec_helper.rb +1 -1
  119. data/spec/integration/timezone_test.rb +2 -2
  120. data/spec/integration/type_test.rb +15 -6
  121. data/spec/model/association_reflection_spec.rb +1 -1
  122. data/spec/model/associations_spec.rb +4 -4
  123. data/spec/model/base_spec.rb +5 -5
  124. data/spec/model/eager_loading_spec.rb +15 -15
  125. data/spec/model/model_spec.rb +32 -32
  126. data/spec/model/record_spec.rb +16 -0
  127. data/spec/model/spec_helper.rb +2 -6
  128. data/spec/model/validations_spec.rb +1 -1
  129. metadata +16 -4
@@ -244,22 +244,22 @@ shared_examples_for "filtering/excluding by associations" do
244
244
  album.update(:artist => artist)
245
245
 
246
246
  @Artist.filter(:albums=>@Album).all.sort_by{|x| x.pk}.should == [@artist, artist]
247
- @Artist.filter(:albums=>@Album.filter(Array(Album.primary_key).map{|k| k.qualify(Album.table_name)}.zip(Array(album.pk)))).all.sort_by{|x| x.pk}.should == [artist]
247
+ @Artist.filter(:albums=>@Album.filter(Array(Album.primary_key).map{|k| Sequel.qualify(Album.table_name, k)}.zip(Array(album.pk)))).all.sort_by{|x| x.pk}.should == [artist]
248
248
  @Artist.filter(:albums=>@Album.filter(1=>0)).all.sort_by{|x| x.pk}.should == []
249
249
  @Artist.filter(:first_album=>@Album).all.sort_by{|x| x.pk}.should == [@artist, artist]
250
- @Artist.filter(:first_album=>@Album.filter(Array(Album.primary_key).map{|k| k.qualify(Album.table_name)}.zip(Array(album.pk)))).all.sort_by{|x| x.pk}.should == [artist]
250
+ @Artist.filter(:first_album=>@Album.filter(Array(Album.primary_key).map{|k| Sequel.qualify(Album.table_name, k)}.zip(Array(album.pk)))).all.sort_by{|x| x.pk}.should == [artist]
251
251
  @Artist.filter(:first_album=>@Album.filter(1=>0)).all.sort_by{|x| x.pk}.should == []
252
252
  @Album.filter(:artist=>@Artist).all.sort_by{|x| x.pk}.should == [@album, album]
253
- @Album.filter(:artist=>@Artist.filter(Array(Artist.primary_key).map{|k| k.qualify(Artist.table_name)}.zip(Array(artist.pk)))).all.sort_by{|x| x.pk}.should == [album]
253
+ @Album.filter(:artist=>@Artist.filter(Array(Artist.primary_key).map{|k| Sequel.qualify(Artist.table_name, k)}.zip(Array(artist.pk)))).all.sort_by{|x| x.pk}.should == [album]
254
254
  @Album.filter(:artist=>@Artist.filter(1=>0)).all.sort_by{|x| x.pk}.should == []
255
255
  @Album.filter(:tags=>@Tag).all.sort_by{|x| x.pk}.should == [@album, album]
256
- @Album.filter(:tags=>@Tag.filter(Array(Tag.primary_key).map{|k| k.qualify(Tag.table_name)}.zip(Array(tag.pk)))).all.sort_by{|x| x.pk}.should == [album]
256
+ @Album.filter(:tags=>@Tag.filter(Array(Tag.primary_key).map{|k| Sequel.qualify(Tag.table_name, k)}.zip(Array(tag.pk)))).all.sort_by{|x| x.pk}.should == [album]
257
257
  @Album.filter(:tags=>@Tag.filter(1=>0)).all.sort_by{|x| x.pk}.should == []
258
258
  @Album.filter(:alias_tags=>@Tag).all.sort_by{|x| x.pk}.should == [@album, album]
259
- @Album.filter(:alias_tags=>@Tag.filter(Array(Tag.primary_key).map{|k| k.qualify(Tag.table_name)}.zip(Array(tag.pk)))).all.sort_by{|x| x.pk}.should == [album]
259
+ @Album.filter(:alias_tags=>@Tag.filter(Array(Tag.primary_key).map{|k| Sequel.qualify(Tag.table_name, k)}.zip(Array(tag.pk)))).all.sort_by{|x| x.pk}.should == [album]
260
260
  @Album.filter(:alias_tags=>@Tag.filter(1=>0)).all.sort_by{|x| x.pk}.should == []
261
261
  @Tag.filter(:albums=>@Album).all.sort_by{|x| x.pk}.should == [@tag, tag]
262
- @Tag.filter(:albums=>@Album.filter(Array(Album.primary_key).map{|k| k.qualify(Album.table_name)}.zip(Array(album.pk)))).all.sort_by{|x| x.pk}.should == [tag]
262
+ @Tag.filter(:albums=>@Album.filter(Array(Album.primary_key).map{|k| Sequel.qualify(Album.table_name, k)}.zip(Array(album.pk)))).all.sort_by{|x| x.pk}.should == [tag]
263
263
  @Tag.filter(:albums=>@Album.filter(1=>0)).all.sort_by{|x| x.pk}.should == []
264
264
  end
265
265
 
@@ -271,19 +271,19 @@ shared_examples_for "filtering/excluding by associations" do
271
271
  album.update(:artist => artist)
272
272
 
273
273
  @Artist.exclude(:albums=>@Album).all.sort_by{|x| x.pk}.should == []
274
- @Artist.exclude(:albums=>@Album.filter(Array(Album.primary_key).map{|k| k.qualify(Album.table_name)}.zip(Array(album.pk)))).all.sort_by{|x| x.pk}.should == [@artist]
274
+ @Artist.exclude(:albums=>@Album.filter(Array(Album.primary_key).map{|k| Sequel.qualify(Album.table_name, k)}.zip(Array(album.pk)))).all.sort_by{|x| x.pk}.should == [@artist]
275
275
  @Artist.exclude(:albums=>@Album.filter(1=>0)).all.sort_by{|x| x.pk}.should == [@artist, artist]
276
276
  @Album.exclude(:artist=>@Artist).all.sort_by{|x| x.pk}.should == []
277
- @Album.exclude(:artist=>@Artist.filter(Array(Artist.primary_key).map{|k| k.qualify(Artist.table_name)}.zip(Array(artist.pk)))).all.sort_by{|x| x.pk}.should == [@album]
277
+ @Album.exclude(:artist=>@Artist.filter(Array(Artist.primary_key).map{|k| Sequel.qualify(Artist.table_name, k)}.zip(Array(artist.pk)))).all.sort_by{|x| x.pk}.should == [@album]
278
278
  @Album.exclude(:artist=>@Artist.filter(1=>0)).all.sort_by{|x| x.pk}.should == [@album, album]
279
279
  @Album.exclude(:tags=>@Tag).all.sort_by{|x| x.pk}.should == []
280
- @Album.exclude(:tags=>@Tag.filter(Array(Tag.primary_key).map{|k| k.qualify(Tag.table_name)}.zip(Array(tag.pk)))).all.sort_by{|x| x.pk}.should == [@album]
280
+ @Album.exclude(:tags=>@Tag.filter(Array(Tag.primary_key).map{|k| Sequel.qualify(Tag.table_name, k)}.zip(Array(tag.pk)))).all.sort_by{|x| x.pk}.should == [@album]
281
281
  @Album.exclude(:tags=>@Tag.filter(1=>0)).all.sort_by{|x| x.pk}.should == [@album, album]
282
282
  @Album.exclude(:alias_tags=>@Tag).all.sort_by{|x| x.pk}.should == []
283
- @Album.exclude(:alias_tags=>@Tag.filter(Array(Tag.primary_key).map{|k| k.qualify(Tag.table_name)}.zip(Array(tag.pk)))).all.sort_by{|x| x.pk}.should == [@album]
283
+ @Album.exclude(:alias_tags=>@Tag.filter(Array(Tag.primary_key).map{|k| Sequel.qualify(Tag.table_name, k)}.zip(Array(tag.pk)))).all.sort_by{|x| x.pk}.should == [@album]
284
284
  @Album.exclude(:alias_tags=>@Tag.filter(1=>0)).all.sort_by{|x| x.pk}.should == [@album, album]
285
285
  @Tag.exclude(:albums=>@Album).all.sort_by{|x| x.pk}.should == []
286
- @Tag.exclude(:albums=>@Album.filter(Array(Album.primary_key).map{|k| k.qualify(Album.table_name)}.zip(Array(album.pk)))).all.sort_by{|x| x.pk}.should == [@tag]
286
+ @Tag.exclude(:albums=>@Album.filter(Array(Album.primary_key).map{|k| Sequel.qualify(Album.table_name, k)}.zip(Array(album.pk)))).all.sort_by{|x| x.pk}.should == [@tag]
287
287
  @Tag.exclude(:albums=>@Album.filter(1=>0)).all.sort_by{|x| x.pk}.should == [@tag, tag]
288
288
  end
289
289
  end
@@ -456,7 +456,7 @@ shared_examples_for "regular and composite key associations" do
456
456
 
457
457
  describe "when filtering/excluding by associations when joining" do
458
458
  def self_join(c)
459
- c.join(c.table_name.as(:b), Array(c.primary_key).zip(Array(c.primary_key))).select_all(c.table_name)
459
+ c.join(Sequel.as(c.table_name, :b), Array(c.primary_key).zip(Array(c.primary_key))).select_all(c.table_name)
460
460
  end
461
461
 
462
462
  before do
@@ -561,15 +561,15 @@ describe "Sequel::Model Simple Associations" do
561
561
  plugin :dataset_associations
562
562
  one_to_many :albums, :order=>:name
563
563
  one_to_one :first_album, :class=>:Album, :order=>:name
564
- one_to_one :last_album, :class=>:Album, :order=>:name.desc
564
+ one_to_one :last_album, :class=>:Album, :order=>Sequel.desc(:name)
565
565
  one_to_many :first_two_albums, :class=>:Album, :order=>:name, :limit=>2
566
566
  one_to_many :second_two_albums, :class=>:Album, :order=>:name, :limit=>[2, 1]
567
- one_to_many :last_two_albums, :class=>:Album, :order=>:name.desc, :limit=>2
567
+ one_to_many :last_two_albums, :class=>:Album, :order=>Sequel.desc(:name), :limit=>2
568
568
  plugin :many_through_many
569
569
  many_through_many :tags, [[:albums, :artist_id, :id], [:albums_tags, :album_id, :tag_id]]
570
570
  many_through_many :first_two_tags, :clone=>:tags, :order=>:tags__name, :limit=>2
571
571
  many_through_many :second_two_tags, :clone=>:tags, :order=>:tags__name, :limit=>[2, 1]
572
- many_through_many :last_two_tags, :clone=>:tags, :order=>:tags__name.desc, :limit=>2
572
+ many_through_many :last_two_tags, :clone=>:tags, :order=>Sequel.desc(:tags__name), :limit=>2
573
573
  end
574
574
  class ::Album < Sequel::Model(@db)
575
575
  plugin :dataset_associations
@@ -578,7 +578,7 @@ describe "Sequel::Model Simple Associations" do
578
578
  many_to_many :alias_tags, :clone=>:tags, :join_table=>:albums_tags___at
579
579
  many_to_many :first_two_tags, :clone=>:tags, :order=>:name, :limit=>2
580
580
  many_to_many :second_two_tags, :clone=>:tags, :order=>:name, :limit=>[2, 1]
581
- many_to_many :last_two_tags, :clone=>:tags, :order=>:name.desc, :limit=>2
581
+ many_to_many :last_two_tags, :clone=>:tags, :order=>Sequel.desc(:name), :limit=>2
582
582
  end
583
583
  class ::Tag < Sequel::Model(@db)
584
584
  plugin :dataset_associations
@@ -770,15 +770,15 @@ describe "Sequel::Model Composite Key Associations" do
770
770
  unrestrict_primary_key
771
771
  one_to_many :albums, :key=>[:artist_id1, :artist_id2], :order=>:name
772
772
  one_to_one :first_album, :clone=>:albums, :order=>:name
773
- one_to_one :last_album, :clone=>:albums, :order=>:name.desc
773
+ one_to_one :last_album, :clone=>:albums, :order=>Sequel.desc(:name)
774
774
  one_to_many :first_two_albums, :clone=>:albums, :order=>:name, :limit=>2
775
775
  one_to_many :second_two_albums, :clone=>:albums, :order=>:name, :limit=>[2, 1]
776
- one_to_many :last_two_albums, :clone=>:albums, :order=>:name.desc, :limit=>2
776
+ one_to_many :last_two_albums, :clone=>:albums, :order=>Sequel.desc(:name), :limit=>2
777
777
  plugin :many_through_many
778
778
  many_through_many :tags, [[:albums, [:artist_id1, :artist_id2], [:id1, :id2]], [:albums_tags, [:album_id1, :album_id2], [:tag_id1, :tag_id2]]]
779
779
  many_through_many :first_two_tags, :clone=>:tags, :order=>:tags__name, :limit=>2
780
780
  many_through_many :second_two_tags, :clone=>:tags, :order=>:tags__name, :limit=>[2, 1]
781
- many_through_many :last_two_tags, :clone=>:tags, :order=>:tags__name.desc, :limit=>2
781
+ many_through_many :last_two_tags, :clone=>:tags, :order=>Sequel.desc(:tags__name), :limit=>2
782
782
  end
783
783
  class ::Album < Sequel::Model(@db)
784
784
  plugin :dataset_associations
@@ -789,7 +789,7 @@ describe "Sequel::Model Composite Key Associations" do
789
789
  many_to_many :alias_tags, :clone=>:tags, :join_table=>:albums_tags___at
790
790
  many_to_many :first_two_tags, :clone=>:tags, :order=>:name, :limit=>2
791
791
  many_to_many :second_two_tags, :clone=>:tags, :order=>:name, :limit=>[2, 1]
792
- many_to_many :last_two_tags, :clone=>:tags, :order=>:name.desc, :limit=>2
792
+ many_to_many :last_two_tags, :clone=>:tags, :order=>Sequel.desc(:name), :limit=>2
793
793
  end
794
794
  class ::Tag < Sequel::Model(@db)
795
795
  plugin :dataset_associations
@@ -60,8 +60,8 @@ describe "Simple Dataset operations" do
60
60
  end
61
61
 
62
62
  specify "should correctly deal with qualified columns and subselects" do
63
- @ds.from_self(:alias=>:a).select(:a__id, :number.qualify(:a)).all.should == [{:id=>1, :number=>10}]
64
- @ds.join(@ds.as(:a), :id=>:id).select(:a__id, :number.qualify(:a)).all.should == [{:id=>1, :number=>10}]
63
+ @ds.from_self(:alias=>:a).select(:a__id, Sequel.qualify(:a, :number)).all.should == [{:id=>1, :number=>10}]
64
+ @ds.join(@ds.as(:a), :id=>:id).select(:a__id, Sequel.qualify(:a, :number)).all.should == [{:id=>1, :number=>10}]
65
65
  end
66
66
 
67
67
  specify "should graph correctly" do
@@ -87,7 +87,7 @@ describe "Simple Dataset operations" do
87
87
  end
88
88
 
89
89
  specify "should update correctly" do
90
- @ds.update(:number=>:number+1).should == 1
90
+ @ds.update(:number=>Sequel.expr(:number)+1).should == 1
91
91
  @ds.all.should == [{:id=>1, :number=>11}]
92
92
  end
93
93
 
@@ -301,16 +301,16 @@ describe Sequel::Database do
301
301
  "\\'dingo",
302
302
  "\\\\''dingo",
303
303
  ].each do |str|
304
- INTEGRATION_DB.get(str.cast(String)).should == str
304
+ INTEGRATION_DB.get(Sequel.cast(str, String)).should == str
305
305
  str = "1#{str}1"
306
- INTEGRATION_DB.get(str.cast(String)).should == str
306
+ INTEGRATION_DB.get(Sequel.cast(str, String)).should == str
307
307
  str = "#{str}#{str}"
308
- INTEGRATION_DB.get(str.cast(String)).should == str
308
+ INTEGRATION_DB.get(Sequel.cast(str, String)).should == str
309
309
  end
310
310
  end
311
311
 
312
- cspecify "should properly escape binary data", [:odbc], [:jdbc, :hsqldb], [:swift], :oracle do
313
- INTEGRATION_DB.get("\1\2\3".to_sequel_blob.cast(File).as(:a)).should == "\1\2\3"
312
+ cspecify "should properly escape binary data", [:odbc], [:jdbc, :hsqldb], :oracle do
313
+ INTEGRATION_DB.get(Sequel.cast(Sequel.blob("\1\2\3"), File).as(:a)).should == "\1\2\3"
314
314
  end
315
315
 
316
316
  specify "should have a working table_exists?" do
@@ -443,20 +443,20 @@ describe "Dataset UNION, EXCEPT, and INTERSECT" do
443
443
  @ds1.insert(:number=>38)
444
444
  @ds2.insert(:number=>39)
445
445
 
446
- @ds1.order(:number.desc).union(@ds2).order(:number).map{|x| x[:number].to_s}.should == %w'8 9 10 20 30 38 39'
447
- @ds1.union(@ds2.order(:number.desc)).order(:number).map{|x| x[:number].to_s}.should == %w'8 9 10 20 30 38 39'
446
+ @ds1.reverse_order(:number).union(@ds2).order(:number).map{|x| x[:number].to_s}.should == %w'8 9 10 20 30 38 39'
447
+ @ds1.union(@ds2.reverse_order(:number)).order(:number).map{|x| x[:number].to_s}.should == %w'8 9 10 20 30 38 39'
448
448
 
449
- @ds1.order(:number.desc).limit(1).union(@ds2).order(:number).map{|x| x[:number].to_s}.should == %w'9 10 30 38 39'
450
- @ds2.order(:number.desc).limit(1).union(@ds1).order(:number).map{|x| x[:number].to_s}.should == %w'8 10 20 38 39'
449
+ @ds1.reverse_order(:number).limit(1).union(@ds2).order(:number).map{|x| x[:number].to_s}.should == %w'9 10 30 38 39'
450
+ @ds2.reverse_order(:number).limit(1).union(@ds1).order(:number).map{|x| x[:number].to_s}.should == %w'8 10 20 38 39'
451
451
 
452
452
  @ds1.union(@ds2.order(:number).limit(1)).order(:number).map{|x| x[:number].to_s}.should == %w'8 9 10 20 38'
453
453
  @ds2.union(@ds1.order(:number).limit(1)).order(:number).map{|x| x[:number].to_s}.should == %w'8 9 10 30 39'
454
454
 
455
455
  @ds1.union(@ds2).limit(2).order(:number).map{|x| x[:number].to_s}.should == %w'8 9'
456
- @ds2.union(@ds1).order(:number.desc).limit(2).map{|x| x[:number].to_s}.should == %w'39 38'
456
+ @ds2.union(@ds1).reverse_order(:number).limit(2).map{|x| x[:number].to_s}.should == %w'39 38'
457
457
 
458
- @ds1.order(:number.desc).limit(2).union(@ds2.order(:number.desc).limit(2)).order(:number).limit(3).map{|x| x[:number].to_s}.should == %w'20 30 38'
459
- @ds2.order(:number).limit(2).union(@ds1.order(:number).limit(2)).order(:number.desc).limit(3).map{|x| x[:number].to_s}.should == %w'10 9 8'
458
+ @ds1.reverse_order(:number).limit(2).union(@ds2.reverse_order(:number).limit(2)).order(:number).limit(3).map{|x| x[:number].to_s}.should == %w'20 30 38'
459
+ @ds2.order(:number).limit(2).union(@ds1.order(:number).limit(2)).reverse_order(:number).limit(3).map{|x| x[:number].to_s}.should == %w'10 9 8'
460
460
  end
461
461
 
462
462
  specify "should give the correct results for compound UNION, EXCEPT, and INTERSECT" do
@@ -562,7 +562,7 @@ if INTEGRATION_DB.dataset.supports_cte?(:update) # Assume INSERT and DELETE supp
562
562
  specify "should give correct results for WITH" do
563
563
  @ds2.insert(@db[:t])
564
564
  @ds.select_order_map(:id).should == [1, 1, 2, 2]
565
- @ds2.filter(:id=>@db[:t].select{max(id)}).update(:id=>:id+1)
565
+ @ds2.filter(:id=>@db[:t].select{max(id)}).update(:id=>Sequel.+(:id, 1))
566
566
  @ds.select_order_map(:id).should == [1, 1, 3, 3]
567
567
  @ds2.filter(:id=>@db[:t].select{max(id)}).delete
568
568
  @ds.select_order_map(:id).should == [1, 1]
@@ -609,16 +609,16 @@ if INTEGRATION_DB.dataset.supports_returning?(:update) # Assume DELETE support a
609
609
 
610
610
  specify "should give correct results" do
611
611
  h = []
612
- @ds.returning(:foo).update(:id=>:id+1, :foo=>:foo*2){|r| h << r}
612
+ @ds.returning(:foo).update(:id=>Sequel.+(:id, 1), :foo=>Sequel.*(:foo, 2)){|r| h << r}
613
613
  h.should == [{:foo=>4}]
614
614
  h.clear
615
- @ds.returning(:id).update(:id=>:id+1, :foo=>:foo*2){|r| h << r}
615
+ @ds.returning(:id).update(:id=>Sequel.+(:id, 1), :foo=>Sequel.*(:foo, 2)){|r| h << r}
616
616
  h.should == [{:id=>3}]
617
617
  h.clear
618
- @ds.returning.update(:id=>:id+1, :foo=>:foo*2){|r| h << r}
618
+ @ds.returning.update(:id=>Sequel.+(:id, 1), :foo=>Sequel.*(:foo, 2)){|r| h << r}
619
619
  h.should == [{:id=>4, :foo=>16}]
620
620
  h.clear
621
- @ds.returning(:id___foo, :foo___id).update(:id=>:id+1, :foo=>:foo*2){|r| h << r}
621
+ @ds.returning(:id___foo, :foo___id).update(:id=>Sequel.+(:id, 1), :foo=>Sequel.*(:foo, 2)){|r| h << r}
622
622
  h.should == [{:id=>32, :foo=>5}]
623
623
  h.clear
624
624
 
@@ -783,7 +783,7 @@ describe "Sequel::Dataset#import and #multi_insert :return=>:primary_key " do
783
783
  @db.drop_table?(:imp)
784
784
  end
785
785
 
786
- specify "should return primary key values " do
786
+ specify "should return primary key values" do
787
787
  @ds.multi_insert([{:i=>10}, {:i=>20}, {:i=>30}], :return=>:primary_key).should == [1, 2, 3]
788
788
  @ds.import([:i], [[40], [50], [60]], :return=>:primary_key).should == [4, 5, 6]
789
789
  @ds.order(:id).map([:id, :i]).should == [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50], [6, 60]]
@@ -812,13 +812,13 @@ describe "Sequel::Dataset convenience methods" do
812
812
  end
813
813
 
814
814
  it "#group_rollup should include hierarchy of groupings" do
815
- @ds.group_by(:a).group_rollup.select_map([:a, :sum.sql_function(:b).cast(Integer).as(:b), :sum.sql_function(:c).cast(Integer).as(:c)]).sort_by{|x| x.inspect}.should == [[1, 10, 16], [2, 7, 11], [nil, 17, 27]]
816
- @ds.group_by(:a, :b).group_rollup.select_map([:a, :b, :sum.sql_function(:c).cast(Integer).as(:c)]).sort_by{|x| x.inspect}.should == [[1, 3, 11], [1, 4, 5], [1, nil, 16], [2, 3, 5], [2, 4, 6], [2, nil, 11], [nil, nil, 27]]
815
+ @ds.group_by(:a).group_rollup.select_map([:a, Sequel.function(:sum, :b).cast(Integer).as(:b), Sequel.function(:sum, :c).cast(Integer).as(:c)]).sort_by{|x| x.inspect}.should == [[1, 10, 16], [2, 7, 11], [nil, 17, 27]]
816
+ @ds.group_by(:a, :b).group_rollup.select_map([:a, :b, Sequel.function(:sum, :c).cast(Integer).as(:c)]).sort_by{|x| x.inspect}.should == [[1, 3, 11], [1, 4, 5], [1, nil, 16], [2, 3, 5], [2, 4, 6], [2, nil, 11], [nil, nil, 27]]
817
817
  end if INTEGRATION_DB.dataset.supports_group_rollup?
818
818
 
819
819
  it "#group_cube should include all combinations of groupings" do
820
- @ds.group_by(:a).group_cube.select_map([:a, :sum.sql_function(:b).cast(Integer).as(:b), :sum.sql_function(:c).cast(Integer).as(:c)]).sort_by{|x| x.inspect}.should == [[1, 10, 16], [2, 7, 11], [nil, 17, 27]]
821
- @ds.group_by(:a, :b).group_cube.select_map([:a, :b, :sum.sql_function(:c).cast(Integer).as(:c)]).sort_by{|x| x.inspect}.should == [[1, 3, 11], [1, 4, 5], [1, nil, 16], [2, 3, 5], [2, 4, 6], [2, nil, 11], [nil, 3, 16], [nil, 4, 11], [nil, nil, 27]]
820
+ @ds.group_by(:a).group_cube.select_map([:a, Sequel.function(:sum, :b).cast(Integer).as(:b), Sequel.function(:sum, :c).cast(Integer).as(:c)]).sort_by{|x| x.inspect}.should == [[1, 10, 16], [2, 7, 11], [nil, 17, 27]]
821
+ @ds.group_by(:a, :b).group_cube.select_map([:a, :b, Sequel.function(:sum, :c).cast(Integer).as(:c)]).sort_by{|x| x.inspect}.should == [[1, 3, 11], [1, 4, 5], [1, nil, 16], [2, 3, 5], [2, 4, 6], [2, nil, 11], [nil, 3, 16], [nil, 4, 11], [nil, nil, 27]]
822
822
  end if INTEGRATION_DB.dataset.supports_group_cube?
823
823
  end
824
824
 
@@ -1026,34 +1026,34 @@ describe "Sequel::Dataset convenience methods" do
1026
1026
  @ds.select_map(:b___e).should == [2, 6]
1027
1027
  @ds.select_map([:a___e, :b___f]).should == [[1, 2], [5, 6]]
1028
1028
  @ds.select_map([:a__a___e, :a__b___f]).should == [[1, 2], [5, 6]]
1029
- @ds.select_map([:a__a.as(:e), :a__b.as(:f)]).should == [[1, 2], [5, 6]]
1030
- @ds.select_map([:a.qualify(:a).as(:e), :b.qualify(:a).as(:f)]).should == [[1, 2], [5, 6]]
1031
- @ds.select_map([:a.identifier.qualify(:a).as(:e), :b.qualify(:a).as(:f)]).should == [[1, 2], [5, 6]]
1029
+ @ds.select_map([Sequel.expr(:a__a).as(:e), Sequel.expr(:a__b).as(:f)]).should == [[1, 2], [5, 6]]
1030
+ @ds.select_map([Sequel.qualify(:a, :a).as(:e), Sequel.qualify(:a, :b).as(:f)]).should == [[1, 2], [5, 6]]
1031
+ @ds.select_map([Sequel.identifier(:a).qualify(:a).as(:e), Sequel.qualify(:a, :b).as(:f)]).should == [[1, 2], [5, 6]]
1032
1032
  end
1033
1033
 
1034
1034
  specify "should have working #select_order_map" do
1035
1035
  @ds.select_order_map(:a).should == [1, 5]
1036
- @ds.select_order_map(:a__b.desc).should == [6, 2]
1037
- @ds.select_order_map(:a__b___e.desc).should == [6, 2]
1038
- @ds.select_order_map(:b.qualify(:a).as(:e)).should == [2, 6]
1036
+ @ds.select_order_map(Sequel.desc(:a__b)).should == [6, 2]
1037
+ @ds.select_order_map(Sequel.desc(:a__b___e)).should == [6, 2]
1038
+ @ds.select_order_map(Sequel.qualify(:a, :b).as(:e)).should == [2, 6]
1039
1039
  @ds.select_order_map([:a]).should == [[1], [5]]
1040
- @ds.select_order_map([:a.desc, :b]).should == [[5, 6], [1, 2]]
1040
+ @ds.select_order_map([Sequel.desc(:a), :b]).should == [[5, 6], [1, 2]]
1041
1041
 
1042
1042
  @ds.select_order_map(:a___e).should == [1, 5]
1043
1043
  @ds.select_order_map(:b___e).should == [2, 6]
1044
- @ds.select_order_map([:a___e.desc, :b___f]).should == [[5, 6], [1, 2]]
1045
- @ds.select_order_map([:a__a___e.desc, :a__b___f]).should == [[5, 6], [1, 2]]
1046
- @ds.select_order_map([:a__a.desc, :a__b.as(:f)]).should == [[5, 6], [1, 2]]
1047
- @ds.select_order_map([:a.qualify(:a).desc, :b.qualify(:a).as(:f)]).should == [[5, 6], [1, 2]]
1048
- @ds.select_order_map([:a.identifier.qualify(:a).desc, :b.qualify(:a).as(:f)]).should == [[5, 6], [1, 2]]
1044
+ @ds.select_order_map([Sequel.desc(:a___e), :b___f]).should == [[5, 6], [1, 2]]
1045
+ @ds.select_order_map([Sequel.desc(:a__a___e), :a__b___f]).should == [[5, 6], [1, 2]]
1046
+ @ds.select_order_map([Sequel.desc(:a__a), Sequel.expr(:a__b).as(:f)]).should == [[5, 6], [1, 2]]
1047
+ @ds.select_order_map([Sequel.qualify(:a, :a).desc, Sequel.qualify(:a, :b).as(:f)]).should == [[5, 6], [1, 2]]
1048
+ @ds.select_order_map([Sequel.identifier(:a).qualify(:a).desc, Sequel.qualify(:a, :b).as(:f)]).should == [[5, 6], [1, 2]]
1049
1049
  end
1050
1050
 
1051
1051
  specify "should have working #select_hash" do
1052
1052
  @ds.select_hash(:a, :b).should == {1=>2, 5=>6}
1053
1053
  @ds.select_hash(:a__a___e, :b).should == {1=>2, 5=>6}
1054
- @ds.select_hash(:a__a.as(:e), :b).should == {1=>2, 5=>6}
1055
- @ds.select_hash(:a.qualify(:a).as(:e), :b).should == {1=>2, 5=>6}
1056
- @ds.select_hash(:a.identifier.qualify(:a).as(:e), :b).should == {1=>2, 5=>6}
1054
+ @ds.select_hash(Sequel.expr(:a__a).as(:e), :b).should == {1=>2, 5=>6}
1055
+ @ds.select_hash(Sequel.qualify(:a, :a).as(:e), :b).should == {1=>2, 5=>6}
1056
+ @ds.select_hash(Sequel.identifier(:a).qualify(:a).as(:e), :b).should == {1=>2, 5=>6}
1057
1057
  @ds.select_hash([:a, :c], :b).should == {[1, 3]=>2, [5, 7]=>6}
1058
1058
  @ds.select_hash(:a, [:b, :c]).should == {1=>[2, 3], 5=>[6, 7]}
1059
1059
  @ds.select_hash([:a, :c], [:b, :d]).should == {[1, 3]=>[2, 4], [5, 7]=>[6, 8]}
@@ -1064,9 +1064,9 @@ describe "Sequel::Dataset convenience methods" do
1064
1064
  ds.insert(1, 2, 3, 9)
1065
1065
  ds.select_hash_groups(:a, :d).should == {1=>[4, 9], 5=>[8]}
1066
1066
  ds.select_hash_groups(:a__a___e, :d).should == {1=>[4, 9], 5=>[8]}
1067
- ds.select_hash_groups(:a__a.as(:e), :d).should == {1=>[4, 9], 5=>[8]}
1068
- ds.select_hash_groups(:a.qualify(:a).as(:e), :d).should == {1=>[4, 9], 5=>[8]}
1069
- ds.select_hash_groups(:a.identifier.qualify(:a).as(:e), :d).should == {1=>[4, 9], 5=>[8]}
1067
+ ds.select_hash_groups(Sequel.expr(:a__a).as(:e), :d).should == {1=>[4, 9], 5=>[8]}
1068
+ ds.select_hash_groups(Sequel.qualify(:a, :a).as(:e), :d).should == {1=>[4, 9], 5=>[8]}
1069
+ ds.select_hash_groups(Sequel.identifier(:a).qualify(:a).as(:e), :d).should == {1=>[4, 9], 5=>[8]}
1070
1070
  ds.select_hash_groups([:a, :c], :d).should == {[1, 3]=>[4, 9], [5, 7]=>[8]}
1071
1071
  ds.select_hash_groups(:a, [:b, :d]).should == {1=>[[2, 4], [2, 9]], 5=>[[6, 8]]}
1072
1072
  ds.select_hash_groups([:a, :c], [:b, :d]).should == {[1, 3]=>[[2, 4], [2, 9]], [5, 7]=>[[6, 8]]}
@@ -1146,35 +1146,35 @@ describe "Sequel::Dataset DSL support" do
1146
1146
 
1147
1147
  specify "should work with casting and string concatentation" do
1148
1148
  @ds.insert(20, 20)
1149
- @ds.get{a.cast_string + b.cast_string}.should == '2020'
1149
+ @ds.get{Sequel.cast(a, String).sql_string + Sequel.cast(b, String)}.should == '2020'
1150
1150
  end
1151
1151
 
1152
1152
  it "should work with ordering" do
1153
1153
  @ds.insert(10, 20)
1154
1154
  @ds.insert(20, 10)
1155
1155
  @ds.order(:a, :b).all.should == [{:a=>10, :b=>20}, {:a=>20, :b=>10}]
1156
- @ds.order(:a.asc, :b.asc).all.should == [{:a=>10, :b=>20}, {:a=>20, :b=>10}]
1157
- @ds.order(:a.desc, :b.desc).all.should == [{:a=>20, :b=>10}, {:a=>10, :b=>20}]
1156
+ @ds.order(Sequel.asc(:a), Sequel.asc(:b)).all.should == [{:a=>10, :b=>20}, {:a=>20, :b=>10}]
1157
+ @ds.order(Sequel.desc(:a), Sequel.desc(:b)).all.should == [{:a=>20, :b=>10}, {:a=>10, :b=>20}]
1158
1158
  end
1159
1159
 
1160
1160
  it "should work with qualifying" do
1161
1161
  @ds.insert(10, 20)
1162
1162
  @ds.get(:a__b).should == 20
1163
1163
  @ds.get{a__b}.should == 20
1164
- @ds.get(:b.qualify(:a)).should == 20
1164
+ @ds.get(Sequel.qualify(:a, :b)).should == 20
1165
1165
  end
1166
1166
 
1167
1167
  it "should work with aliasing" do
1168
1168
  @ds.insert(10, 20)
1169
1169
  @ds.get(:a__b___c).should == 20
1170
1170
  @ds.get{a__b.as(c)}.should == 20
1171
- @ds.get(:b.qualify(:a).as(:c)).should == 20
1172
- @ds.get(:b.as(:c)).should == 20
1171
+ @ds.get(Sequel.qualify(:a, :b).as(:c)).should == 20
1172
+ @ds.get(Sequel.as(:b, :c)).should == 20
1173
1173
  end
1174
1174
 
1175
1175
  it "should work with selecting all columns of a table" do
1176
1176
  @ds.insert(20, 10)
1177
- @ds.select(:a.*).all.should == [{:a=>20, :b=>10}]
1177
+ @ds.select_all(:a).all.should == [{:a=>20, :b=>10}]
1178
1178
  end
1179
1179
 
1180
1180
  it "should work with ranges as hash values" do
@@ -1215,24 +1215,24 @@ describe "Sequel::Dataset DSL support" do
1215
1215
 
1216
1216
  it "should work with CASE statements" do
1217
1217
  @ds.insert(20, 10)
1218
- @ds.filter({{:a=>20}=>20}.case(0) > 0).all.should == [{:a=>20, :b=>10}]
1219
- @ds.filter({{:a=>15}=>20}.case(0) > 0).all.should == []
1220
- @ds.filter({20=>20}.case(0, :a) > 0).all.should == [{:a=>20, :b=>10}]
1221
- @ds.filter({15=>20}.case(0, :a) > 0).all.should == []
1218
+ @ds.filter(Sequel.case({{:a=>20}=>20}, 0) > 0).all.should == [{:a=>20, :b=>10}]
1219
+ @ds.filter(Sequel.case({{:a=>15}=>20}, 0) > 0).all.should == []
1220
+ @ds.filter(Sequel.case({20=>20}, 0, :a) > 0).all.should == [{:a=>20, :b=>10}]
1221
+ @ds.filter(Sequel.case({15=>20}, 0, :a) > 0).all.should == []
1222
1222
  end
1223
1223
 
1224
1224
  specify "should work with multiple value arrays" do
1225
1225
  @ds.insert(20, 10)
1226
1226
  @ds.quote_identifiers = false
1227
- @ds.filter([:a, :b]=>[[20, 10]].sql_array).all.should == [{:a=>20, :b=>10}]
1228
- @ds.filter([:a, :b]=>[[10, 20]].sql_array).all.should == []
1229
- @ds.filter([:a, :b]=>[[20, 10], [1, 2]].sql_array).all.should == [{:a=>20, :b=>10}]
1230
- @ds.filter([:a, :b]=>[[10, 10], [20, 20]].sql_array).all.should == []
1227
+ @ds.filter([:a, :b]=>[[20, 10]]).all.should == [{:a=>20, :b=>10}]
1228
+ @ds.filter([:a, :b]=>[[10, 20]]).all.should == []
1229
+ @ds.filter([:a, :b]=>[[20, 10], [1, 2]]).all.should == [{:a=>20, :b=>10}]
1230
+ @ds.filter([:a, :b]=>[[10, 10], [20, 20]]).all.should == []
1231
1231
 
1232
- @ds.exclude([:a, :b]=>[[20, 10]].sql_array).all.should == []
1233
- @ds.exclude([:a, :b]=>[[10, 20]].sql_array).all.should == [{:a=>20, :b=>10}]
1234
- @ds.exclude([:a, :b]=>[[20, 10], [1, 2]].sql_array).all.should == []
1235
- @ds.exclude([:a, :b]=>[[10, 10], [20, 20]].sql_array).all.should == [{:a=>20, :b=>10}]
1232
+ @ds.exclude([:a, :b]=>[[20, 10]]).all.should == []
1233
+ @ds.exclude([:a, :b]=>[[10, 20]]).all.should == [{:a=>20, :b=>10}]
1234
+ @ds.exclude([:a, :b]=>[[20, 10], [1, 2]]).all.should == []
1235
+ @ds.exclude([:a, :b]=>[[10, 10], [20, 20]]).all.should == [{:a=>20, :b=>10}]
1236
1236
  end
1237
1237
 
1238
1238
  it "should work with IN/NOT in with datasets" do
@@ -1270,12 +1270,12 @@ describe "Sequel::Dataset DSL support" do
1270
1270
  @ds.exclude([:a, :b]=>[]).all.should == []
1271
1271
 
1272
1272
  unless Sequel.guarded?(:mssql, :oracle, :db2)
1273
- # MSSQL doesn't like boolean results in the select list
1273
+ # Some databases don't like boolean results in the select list
1274
1274
  pr = proc{|r| r.is_a?(Integer) ? (r != 0) : r}
1275
- pr[@ds.get({:a=>[]}.sql_expr)].should == nil
1276
- pr[@ds.get(~({:a=>[]}).sql_expr)].should == nil
1277
- pr[@ds.get({[:a, :b]=>[]}.sql_expr)].should == nil
1278
- pr[@ds.get(~({[:a, :b]=>[]}).sql_expr)].should == nil
1275
+ pr[@ds.get(Sequel.expr(:a=>[]))].should == nil
1276
+ pr[@ds.get(~Sequel.expr(:a=>[]))].should == nil
1277
+ pr[@ds.get(Sequel.expr([:a, :b]=>[]))].should == nil
1278
+ pr[@ds.get(~Sequel.expr([:a, :b]=>[]))].should == nil
1279
1279
  end
1280
1280
  end
1281
1281
 
@@ -1289,12 +1289,12 @@ describe "Sequel::Dataset DSL support" do
1289
1289
  @ds.exclude([:a, :b]=>[]).all.should == [{:a=>nil, :b=>nil}]
1290
1290
 
1291
1291
  unless Sequel.guarded?(:mssql, :oracle, :db2)
1292
- # MSSQL doesn't like boolean results in the select list
1292
+ # Some databases don't like boolean results in the select list
1293
1293
  pr = proc{|r| r.is_a?(Integer) ? (r != 0) : r}
1294
- pr[@ds.get({:a=>[]}.sql_expr)].should == false
1295
- pr[@ds.get(~({:a=>[]}).sql_expr)].should == true
1296
- pr[@ds.get({[:a, :b]=>[]}.sql_expr)].should == false
1297
- pr[@ds.get(~({[:a, :b]=>[]}).sql_expr)].should == true
1294
+ pr[@ds.get(Sequel.expr(:a=>[]))].should == false
1295
+ pr[@ds.get(~Sequel.expr(:a=>[]))].should == true
1296
+ pr[@ds.get(Sequel.expr([:a, :b]=>[]))].should == false
1297
+ pr[@ds.get(~Sequel.expr([:a, :b]=>[]))].should == true
1298
1298
  end
1299
1299
  ensure
1300
1300
  Sequel.empty_array_handle_nulls = true
@@ -1305,9 +1305,9 @@ describe "Sequel::Dataset DSL support" do
1305
1305
  @ds.insert(20, 10)
1306
1306
  @ds.filter(:a=>20, :b=>10).all.should == [{:a=>20, :b=>10}]
1307
1307
  @ds.filter([[:a, 20], [:b, 10]]).all.should == [{:a=>20, :b=>10}]
1308
- @ds.filter({:a=>20} & {:b=>10}).all.should == [{:a=>20, :b=>10}]
1309
- @ds.filter({:a=>20} | {:b=>5}).all.should == [{:a=>20, :b=>10}]
1310
- @ds.filter(~{:a=>10}).all.should == [{:a=>20, :b=>10}]
1308
+ @ds.filter({:a=>20}, {:b=>10}).all.should == [{:a=>20, :b=>10}]
1309
+ @ds.filter(Sequel.|({:a=>20}, {:b=>5})).all.should == [{:a=>20, :b=>10}]
1310
+ @ds.filter(Sequel.~(:a=>10)).all.should == [{:a=>20, :b=>10}]
1311
1311
  end
1312
1312
  end
1313
1313
 
@@ -1385,38 +1385,38 @@ describe "Dataset string methods" do
1385
1385
 
1386
1386
  it "#like should return matching rows" do
1387
1387
  @ds.insert('foo', 'bar')
1388
- @ds.filter(:a.like('foo')).all.should == [{:a=>'foo', :b=>'bar'}]
1389
- @ds.filter(:a.like('bar')).all.should == []
1390
- @ds.filter(:a.like('foo', 'bar')).all.should == [{:a=>'foo', :b=>'bar'}]
1391
- @ds.exclude(:a.like('foo')).all.should == []
1392
- @ds.exclude(:a.like('bar')).all.should == [{:a=>'foo', :b=>'bar'}]
1393
- @ds.exclude(:a.like('foo', 'bar')).all.should == []
1388
+ @ds.filter(Sequel.expr(:a).like('foo')).all.should == [{:a=>'foo', :b=>'bar'}]
1389
+ @ds.filter(Sequel.expr(:a).like('bar')).all.should == []
1390
+ @ds.filter(Sequel.expr(:a).like('foo', 'bar')).all.should == [{:a=>'foo', :b=>'bar'}]
1391
+ @ds.exclude(Sequel.expr(:a).like('foo')).all.should == []
1392
+ @ds.exclude(Sequel.expr(:a).like('bar')).all.should == [{:a=>'foo', :b=>'bar'}]
1393
+ @ds.exclude(Sequel.expr(:a).like('foo', 'bar')).all.should == []
1394
1394
  end
1395
1395
 
1396
1396
  it "#like should be case sensitive" do
1397
1397
  @ds.insert('foo', 'bar')
1398
- @ds.filter(:a.like('Foo')).all.should == []
1399
- @ds.filter(:b.like('baR')).all.should == []
1400
- @ds.filter(:a.like('FOO', 'BAR')).all.should == []
1401
- @ds.exclude(:a.like('Foo')).all.should == [{:a=>'foo', :b=>'bar'}]
1402
- @ds.exclude(:a.like('baR')).all.should == [{:a=>'foo', :b=>'bar'}]
1403
- @ds.exclude(:a.like('FOO', 'BAR')).all.should == [{:a=>'foo', :b=>'bar'}]
1398
+ @ds.filter(Sequel.expr(:a).like('Foo')).all.should == []
1399
+ @ds.filter(Sequel.expr(:b).like('baR')).all.should == []
1400
+ @ds.filter(Sequel.expr(:a).like('FOO', 'BAR')).all.should == []
1401
+ @ds.exclude(Sequel.expr(:a).like('Foo')).all.should == [{:a=>'foo', :b=>'bar'}]
1402
+ @ds.exclude(Sequel.expr(:a).like('baR')).all.should == [{:a=>'foo', :b=>'bar'}]
1403
+ @ds.exclude(Sequel.expr(:a).like('FOO', 'BAR')).all.should == [{:a=>'foo', :b=>'bar'}]
1404
1404
  end
1405
1405
 
1406
1406
  it "#ilike should return matching rows, in a case insensitive manner" do
1407
1407
  @ds.insert('foo', 'bar')
1408
- @ds.filter(:a.ilike('Foo')).all.should == [{:a=>'foo', :b=>'bar'}]
1409
- @ds.filter(:a.ilike('baR')).all.should == []
1410
- @ds.filter(:a.ilike('FOO', 'BAR')).all.should == [{:a=>'foo', :b=>'bar'}]
1411
- @ds.exclude(:a.ilike('Foo')).all.should == []
1412
- @ds.exclude(:a.ilike('baR')).all.should == [{:a=>'foo', :b=>'bar'}]
1413
- @ds.exclude(:a.ilike('FOO', 'BAR')).all.should == []
1408
+ @ds.filter(Sequel.expr(:a).ilike('Foo')).all.should == [{:a=>'foo', :b=>'bar'}]
1409
+ @ds.filter(Sequel.expr(:a).ilike('baR')).all.should == []
1410
+ @ds.filter(Sequel.expr(:a).ilike('FOO', 'BAR')).all.should == [{:a=>'foo', :b=>'bar'}]
1411
+ @ds.exclude(Sequel.expr(:a).ilike('Foo')).all.should == []
1412
+ @ds.exclude(Sequel.expr(:a).ilike('baR')).all.should == [{:a=>'foo', :b=>'bar'}]
1413
+ @ds.exclude(Sequel.expr(:a).ilike('FOO', 'BAR')).all.should == []
1414
1414
  end
1415
1415
 
1416
- it "should work with strings created with sql_string_join" do
1416
+ it "should work with strings created with Sequel.join" do
1417
1417
  @ds.insert('foo', 'bar')
1418
- @ds.get([:a, "bar"].sql_string_join).should == 'foobar'
1419
- @ds.get(["foo", :b].sql_string_join(' ')).should == 'foo bar'
1418
+ @ds.get(Sequel.join([:a, "bar"])).should == 'foobar'
1419
+ @ds.get(Sequel.join(["foo", :b], ' ')).should == 'foo bar'
1420
1420
  end
1421
1421
  end
1422
1422
 
@@ -1438,7 +1438,7 @@ describe "Dataset identifier methods" do
1438
1438
  @db.drop_table?(:a)
1439
1439
  end
1440
1440
 
1441
- cspecify "#identifier_output_method should change how identifiers are output", [:swift] do
1441
+ specify "#identifier_output_method should change how identifiers are output" do
1442
1442
  @ds.identifier_output_method = :upcase
1443
1443
  @ds.first.should == {:AB=>1}
1444
1444
  @ds.identifier_output_method = :uprev
@@ -1491,7 +1491,7 @@ if INTEGRATION_DB.dataset.supports_modifying_joins?
1491
1491
  @db.create_table!(:a){Integer :a; Integer :d}
1492
1492
  @db.create_table!(:b){Integer :b; Integer :e}
1493
1493
  @db.create_table!(:c){Integer :c; Integer :f}
1494
- @ds = @db.from(:a, :b).join(:c, :c=>:e.identifier).where(:d=>:b, :f=>6)
1494
+ @ds = @db.from(:a, :b).join(:c, :c=>Sequel.identifier(:e)).where(:d=>:b, :f=>6)
1495
1495
  @db[:a].insert(1, 2)
1496
1496
  @db[:a].insert(3, 4)
1497
1497
  @db[:b].insert(2, 5)