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
@@ -2,7 +2,7 @@ require 'rubygems'
2
2
  require 'logger'
3
3
  unless Object.const_defined?('Sequel')
4
4
  $:.unshift(File.join(File.dirname(File.expand_path(__FILE__)), "../../lib/"))
5
- require 'sequel'
5
+ require 'sequel/no_core_ext'
6
6
  end
7
7
  begin
8
8
  require File.join(File.dirname(File.dirname(File.expand_path(__FILE__))), 'spec_config.rb')
@@ -56,12 +56,12 @@ describe "An SQLite database" do
56
56
  end
57
57
 
58
58
  specify "should support casting to Date by using the date function" do
59
- @db.get('2012-10-20 11:12:13'.cast(Date)).should == '2012-10-20'
59
+ @db.get(Sequel.cast('2012-10-20 11:12:13', Date)).should == '2012-10-20'
60
60
  end
61
61
 
62
62
  specify "should support casting to Time or DateTime by using the datetime function" do
63
- @db.get('2012-10-20'.cast(Time)).should == '2012-10-20 00:00:00'
64
- @db.get('2012-10-20'.cast(DateTime)).should == '2012-10-20 00:00:00'
63
+ @db.get(Sequel.cast('2012-10-20', Time)).should == '2012-10-20 00:00:00'
64
+ @db.get(Sequel.cast('2012-10-20', DateTime)).should == '2012-10-20 00:00:00'
65
65
  end
66
66
 
67
67
  specify "should provide the SQLite version as an integer" do
@@ -95,11 +95,11 @@ describe "An SQLite database" do
95
95
  specify "should support a use_timestamp_timezones setting" do
96
96
  @db.create_table!(:time){Time :time}
97
97
  @db[:time].insert(Time.now)
98
- @db[:time].get(:time.cast_string).should =~ /[-+]\d\d\d\d\z/
98
+ @db[:time].get(Sequel.cast(:time, String)).should =~ /[-+]\d\d\d\d\z/
99
99
  @db.use_timestamp_timezones = false
100
100
  @db[:time].delete
101
101
  @db[:time].insert(Time.now)
102
- @db[:time].get(:time.cast_string).should_not =~ /[-+]\d\d\d\d\z/
102
+ @db[:time].get(Sequel.cast(:time, String)).should_not =~ /[-+]\d\d\d\d\z/
103
103
  @db.use_timestamp_timezones = true
104
104
  end
105
105
 
@@ -183,10 +183,10 @@ describe "SQLite type conversion" do
183
183
  @db.create_table(:items){TrueClass :a}
184
184
  @db[:items].insert(false)
185
185
  @db[:items].select_map(:a).should == [false]
186
- @db[:items].select_map(:a+:a).should == [0]
186
+ @db[:items].select_map(Sequel.expr(:a)+:a).should == [0]
187
187
  @db[:items].update(:a=>true)
188
188
  @db[:items].select_map(:a).should == [true]
189
- @db[:items].select_map(:a+:a).should == [2]
189
+ @db[:items].select_map(Sequel.expr(:a)+:a).should == [2]
190
190
  end
191
191
 
192
192
  specify "should handle integers/floats/strings/decimals in numeric/decimal columns" do
@@ -258,10 +258,10 @@ describe "An SQLite dataset" do
258
258
  end
259
259
 
260
260
  specify "should raise errors if given a regexp pattern match" do
261
- proc{@d.literal(:x.like(/a/))}.should raise_error(Sequel::Error)
262
- proc{@d.literal(~:x.like(/a/))}.should raise_error(Sequel::Error)
263
- proc{@d.literal(:x.like(/a/i))}.should raise_error(Sequel::Error)
264
- proc{@d.literal(~:x.like(/a/i))}.should raise_error(Sequel::Error)
261
+ proc{@d.literal(Sequel.expr(:x).like(/a/))}.should raise_error(Sequel::Error)
262
+ proc{@d.literal(~Sequel.expr(:x).like(/a/))}.should raise_error(Sequel::Error)
263
+ proc{@d.literal(Sequel.expr(:x).like(/a/i))}.should raise_error(Sequel::Error)
264
+ proc{@d.literal(~Sequel.expr(:x).like(/a/i))}.should raise_error(Sequel::Error)
265
265
  end
266
266
  end
267
267
 
@@ -289,7 +289,7 @@ describe "An SQLite dataset AS clause" do
289
289
  end
290
290
 
291
291
  specify "should use a string literal for :column.as(:alias)" do
292
- SQLITE_DB.literal(:c.as(:a)).should == "`c` AS 'a'"
292
+ SQLITE_DB.literal(Sequel.as(:c, :a)).should == "`c` AS 'a'"
293
293
  end
294
294
 
295
295
  specify "should use a string literal in the SELECT clause" do
@@ -321,10 +321,10 @@ describe "SQLite::Dataset#delete" do
321
321
 
322
322
  specify "should return the number of records affected when filtered" do
323
323
  @d.count.should == 3
324
- @d.filter(:value.sql_number < 3).delete.should == 1
324
+ @d.filter{value < 3}.delete.should == 1
325
325
  @d.count.should == 2
326
326
 
327
- @d.filter(:value.sql_number < 3).delete.should == 0
327
+ @d.filter{value < 3}.delete.should == 0
328
328
  @d.count.should == 2
329
329
  end
330
330
 
@@ -369,7 +369,7 @@ describe "Database#dataset" do
369
369
  end
370
370
 
371
371
  specify "should provide a filtered #from dataset if a block is given" do
372
- d = @db.from(:mau) {:x.sql_number > 100}
372
+ d = @db.from(:mau){x.sql_number > 100}
373
373
  d.should be_a_kind_of(Sequel::Dataset)
374
374
  d.sql.should == 'SELECT * FROM mau WHERE (x > 100)'
375
375
  end
@@ -1360,7 +1360,7 @@ describe "Database#fetch" do
1360
1360
  ds.select_sql.should == 'select * from xyz'
1361
1361
  ds.sql.should == 'select * from xyz'
1362
1362
 
1363
- ds.filter!(:price.sql_number < 100)
1363
+ ds.filter!{price.sql_number < 100}
1364
1364
  ds.select_sql.should == 'select * from xyz'
1365
1365
  ds.sql.should == 'select * from xyz'
1366
1366
  end
@@ -1409,7 +1409,7 @@ describe "Database#get" do
1409
1409
  @db.get(1).should == 1
1410
1410
  @db.sqls.should == ['SELECT 1 LIMIT 1']
1411
1411
 
1412
- @db.get(:version.sql_function)
1412
+ @db.get(Sequel.function(:version))
1413
1413
  @db.sqls.should == ['SELECT version() LIMIT 1']
1414
1414
  end
1415
1415
 
@@ -1914,7 +1914,7 @@ describe "Database#typecast_value" do
1914
1914
  end
1915
1915
 
1916
1916
  specify "should typecast string values to String" do
1917
- [1.0, '1.0', '1.0'.to_sequel_blob].each do |i|
1917
+ [1.0, '1.0', Sequel.blob('1.0')].each do |i|
1918
1918
  v = @db.typecast_value(:string, i)
1919
1919
  v.should be_an_instance_of(String)
1920
1920
  v.should == "1.0"
@@ -2079,7 +2079,7 @@ describe "Database#column_schema_to_ruby_default" do
2079
2079
  p["'t'", :boolean].should == true
2080
2080
  p["'f'", :boolean].should == false
2081
2081
  p["'a'", :string].should == 'a'
2082
- p["'a'", :blob].should == 'a'.to_sequel_blob
2082
+ p["'a'", :blob].should == Sequel.blob('a')
2083
2083
  p["'a'", :blob].should be_a_kind_of(Sequel::SQL::Blob)
2084
2084
  p["''", :string].should == ''
2085
2085
  p["'\\a''b'", :string].should == "\\a'b"
@@ -2099,7 +2099,7 @@ describe "Database#column_schema_to_ruby_default" do
2099
2099
  p["(-1)", :integer].should == -1
2100
2100
  p["(-1.0)", :float].should == -1.0
2101
2101
  p['(-1.0)', :decimal].should == BigDecimal.new('-1.0')
2102
- p["'a'::bytea", :blob].should == 'a'.to_sequel_blob
2102
+ p["'a'::bytea", :blob].should == Sequel.blob('a')
2103
2103
  p["'a'::bytea", :blob].should be_a_kind_of(Sequel::SQL::Blob)
2104
2104
  p["'2009-10-29'::date", :date].should == Date.new(2009,10,29)
2105
2105
  p["'2009-10-29 10:20:30.241343'::timestamp without time zone", :datetime].should == DateTime.parse('2009-10-29 10:20:30.241343')
@@ -328,19 +328,19 @@ describe "Dataset#unused_table_alias" do
328
328
  @ds.unused_table_alias('test').should == :test_0
329
329
  @ds.unused_table_alias(:b__t___test).should == :test_0
330
330
  @ds.unused_table_alias(:b__test).should == :test_0
331
- @ds.unused_table_alias(:test.qualify(:b)).should == :test_0
332
- @ds.unused_table_alias(:b.as(:test)).should == :test_0
333
- @ds.unused_table_alias(:b.as(:test.identifier)).should == :test_0
334
- @ds.unused_table_alias(:b.as('test')).should == :test_0
335
- @ds.unused_table_alias(:test.identifier).should == :test_0
331
+ @ds.unused_table_alias(Sequel.qualify(:b, :test)).should == :test_0
332
+ @ds.unused_table_alias(Sequel.expr(:b).as(:test)).should == :test_0
333
+ @ds.unused_table_alias(Sequel.expr(:b).as(Sequel.identifier(:test))).should == :test_0
334
+ @ds.unused_table_alias(Sequel.expr(:b).as('test')).should == :test_0
335
+ @ds.unused_table_alias(Sequel.identifier(:test)).should == :test_0
336
336
  end
337
337
  end
338
338
 
339
339
  describe "Dataset#exists" do
340
340
  before do
341
341
  @ds1 = Sequel::Dataset.new(nil).from(:test)
342
- @ds2 = @ds1.filter(:price.sql_number < 100)
343
- @ds3 = @ds1.filter(:price.sql_number > 50)
342
+ @ds2 = @ds1.filter(Sequel.expr(:price) < 100)
343
+ @ds3 = @ds1.filter(Sequel.expr(:price) > 50)
344
344
  end
345
345
 
346
346
  specify "should work in filters" do
@@ -380,8 +380,7 @@ describe "Dataset#where" do
380
380
  end
381
381
 
382
382
  specify "should work with a string with placeholders and arguments for those placeholders" do
383
- @dataset.where('price < ? AND id in ?', 100, [1, 2, 3]).select_sql.should ==
384
- "SELECT * FROM test WHERE (price < 100 AND id in (1, 2, 3))"
383
+ @dataset.where('price < ? AND id in ?', 100, [1, 2, 3]).select_sql.should == "SELECT * FROM test WHERE (price < 100 AND id in (1, 2, 3))"
385
384
  end
386
385
 
387
386
  specify "should not modify passed array with placeholders" do
@@ -409,13 +408,11 @@ describe "Dataset#where" do
409
408
  end
410
409
 
411
410
  specify "should not replace named placeholders that don't exist in the hash" do
412
- @dataset.where('price < :price AND id in :ids', :price=>100).select_sql.should ==
413
- "SELECT * FROM test WHERE (price < 100 AND id in :ids)"
411
+ @dataset.where('price < :price AND id in :ids', :price=>100).select_sql.should == "SELECT * FROM test WHERE (price < 100 AND id in :ids)"
414
412
  end
415
413
 
416
414
  specify "should handle partial names" do
417
- @dataset.where('price < :price AND id = :p', :p=>2, :price=>100).select_sql.should ==
418
- "SELECT * FROM test WHERE (price < 100 AND id = 2)"
415
+ @dataset.where('price < :price AND id = :p', :p=>2, :price=>100).select_sql.should == "SELECT * FROM test WHERE (price < 100 AND id = 2)"
419
416
  end
420
417
 
421
418
  specify "should affect select, delete and update statements" do
@@ -435,69 +432,52 @@ describe "Dataset#where" do
435
432
 
436
433
  specify "should be composable using AND operator (for scoping)" do
437
434
  # hashes are merged, no problem
438
- @d1.where(:size => 'big').select_sql.should ==
439
- "SELECT * FROM test WHERE ((region = 'Asia') AND (size = 'big'))"
435
+ @d1.where(:size => 'big').select_sql.should == "SELECT * FROM test WHERE ((region = 'Asia') AND (size = 'big'))"
440
436
 
441
437
  # hash and string
442
- @d1.where('population > 1000').select_sql.should ==
443
- "SELECT * FROM test WHERE ((region = 'Asia') AND (population > 1000))"
444
- @d1.where('(a > 1) OR (b < 2)').select_sql.should ==
445
- "SELECT * FROM test WHERE ((region = 'Asia') AND ((a > 1) OR (b < 2)))"
438
+ @d1.where('population > 1000').select_sql.should == "SELECT * FROM test WHERE ((region = 'Asia') AND (population > 1000))"
439
+ @d1.where('(a > 1) OR (b < 2)').select_sql.should == "SELECT * FROM test WHERE ((region = 'Asia') AND ((a > 1) OR (b < 2)))"
446
440
 
447
441
  # hash and array
448
- @d1.where('GDP > ?', 1000).select_sql.should ==
449
- "SELECT * FROM test WHERE ((region = 'Asia') AND (GDP > 1000))"
442
+ @d1.where('GDP > ?', 1000).select_sql.should == "SELECT * FROM test WHERE ((region = 'Asia') AND (GDP > 1000))"
450
443
 
451
444
  # array and array
452
- @d2.where('GDP > ?', 1000).select_sql.should ==
453
- "SELECT * FROM test WHERE ((region = 'Asia') AND (GDP > 1000))"
445
+ @d2.where('GDP > ?', 1000).select_sql.should == "SELECT * FROM test WHERE ((region = 'Asia') AND (GDP > 1000))"
454
446
 
455
447
  # array and hash
456
- @d2.where(:name => ['Japan', 'China']).select_sql.should ==
457
- "SELECT * FROM test WHERE ((region = 'Asia') AND (name IN ('Japan', 'China')))"
448
+ @d2.where(:name => ['Japan', 'China']).select_sql.should == "SELECT * FROM test WHERE ((region = 'Asia') AND (name IN ('Japan', 'China')))"
458
449
 
459
450
  # array and string
460
- @d2.where('GDP > ?').select_sql.should ==
461
- "SELECT * FROM test WHERE ((region = 'Asia') AND (GDP > ?))"
451
+ @d2.where('GDP > ?').select_sql.should == "SELECT * FROM test WHERE ((region = 'Asia') AND (GDP > ?))"
462
452
 
463
453
  # string and string
464
- @d3.where('b = 2').select_sql.should ==
465
- "SELECT * FROM test WHERE ((a = 1) AND (b = 2))"
454
+ @d3.where('b = 2').select_sql.should == "SELECT * FROM test WHERE ((a = 1) AND (b = 2))"
466
455
 
467
456
  # string and hash
468
- @d3.where(:c => 3).select_sql.should ==
469
- "SELECT * FROM test WHERE ((a = 1) AND (c = 3))"
457
+ @d3.where(:c => 3).select_sql.should == "SELECT * FROM test WHERE ((a = 1) AND (c = 3))"
470
458
 
471
459
  # string and array
472
- @d3.where('d = ?', 4).select_sql.should ==
473
- "SELECT * FROM test WHERE ((a = 1) AND (d = 4))"
460
+ @d3.where('d = ?', 4).select_sql.should == "SELECT * FROM test WHERE ((a = 1) AND (d = 4))"
474
461
  end
475
462
 
476
463
  specify "should be composable using AND operator (for scoping) with block" do
477
- @d3.where{:e.sql_number < 5}.select_sql.should ==
478
- "SELECT * FROM test WHERE ((a = 1) AND (e < 5))"
464
+ @d3.where{e < 5}.select_sql.should == "SELECT * FROM test WHERE ((a = 1) AND (e < 5))"
479
465
  end
480
466
 
481
467
  specify "should accept ranges" do
482
- @dataset.filter(:id => 4..7).sql.should ==
483
- 'SELECT * FROM test WHERE ((id >= 4) AND (id <= 7))'
484
- @dataset.filter(:id => 4...7).sql.should ==
485
- 'SELECT * FROM test WHERE ((id >= 4) AND (id < 7))'
468
+ @dataset.filter(:id => 4..7).sql.should == 'SELECT * FROM test WHERE ((id >= 4) AND (id <= 7))'
469
+ @dataset.filter(:id => 4...7).sql.should == 'SELECT * FROM test WHERE ((id >= 4) AND (id < 7))'
486
470
 
487
- @dataset.filter(:table__id => 4..7).sql.should ==
488
- 'SELECT * FROM test WHERE ((table.id >= 4) AND (table.id <= 7))'
489
- @dataset.filter(:table__id => 4...7).sql.should ==
490
- 'SELECT * FROM test WHERE ((table.id >= 4) AND (table.id < 7))'
471
+ @dataset.filter(:table__id => 4..7).sql.should == 'SELECT * FROM test WHERE ((table.id >= 4) AND (table.id <= 7))'
472
+ @dataset.filter(:table__id => 4...7).sql.should == 'SELECT * FROM test WHERE ((table.id >= 4) AND (table.id < 7))'
491
473
  end
492
474
 
493
475
  specify "should accept nil" do
494
- @dataset.filter(:owner_id => nil).sql.should ==
495
- 'SELECT * FROM test WHERE (owner_id IS NULL)'
476
+ @dataset.filter(:owner_id => nil).sql.should == 'SELECT * FROM test WHERE (owner_id IS NULL)'
496
477
  end
497
478
 
498
479
  specify "should accept a subquery" do
499
- @dataset.filter('gdp > ?', @d1.select(:avg.sql_function(:gdp))).sql.should ==
500
- "SELECT * FROM test WHERE (gdp > (SELECT avg(gdp) FROM test WHERE (region = 'Asia')))"
480
+ @dataset.filter('gdp > ?', @d1.select(Sequel.function(:avg, :gdp))).sql.should == "SELECT * FROM test WHERE (gdp > (SELECT avg(gdp) FROM test WHERE (region = 'Asia')))"
501
481
  end
502
482
 
503
483
  specify "should handle all types of IN/NOT IN queries with empty arrays" do
@@ -523,20 +503,22 @@ describe "Dataset#where" do
523
503
  @dataset.filter(:id => @d1.select(:id)).sql.should == "SELECT * FROM test WHERE (id IN (SELECT id FROM test WHERE (region = 'Asia')))"
524
504
  @dataset.filter(:id => [1, 2]).sql.should == "SELECT * FROM test WHERE (id IN (1, 2))"
525
505
  @dataset.filter([:id1, :id2] => @d1.select(:id1, :id2)).sql.should == "SELECT * FROM test WHERE ((id1, id2) IN (SELECT id1, id2 FROM test WHERE (region = 'Asia')))"
526
- @dataset.filter([:id1, :id2] => [[1, 2], [3,4]].sql_array).sql.should == "SELECT * FROM test WHERE ((id1, id2) IN ((1, 2), (3, 4)))"
506
+ @dataset.filter([:id1, :id2] => Sequel.value_list([[1, 2], [3,4]])).sql.should == "SELECT * FROM test WHERE ((id1, id2) IN ((1, 2), (3, 4)))"
527
507
  @dataset.filter([:id1, :id2] => [[1, 2], [3,4]]).sql.should == "SELECT * FROM test WHERE ((id1, id2) IN ((1, 2), (3, 4)))"
528
508
 
529
509
  @dataset.exclude(:id => @d1.select(:id)).sql.should == "SELECT * FROM test WHERE (id NOT IN (SELECT id FROM test WHERE (region = 'Asia')))"
530
510
  @dataset.exclude(:id => [1, 2]).sql.should == "SELECT * FROM test WHERE (id NOT IN (1, 2))"
531
511
  @dataset.exclude([:id1, :id2] => @d1.select(:id1, :id2)).sql.should == "SELECT * FROM test WHERE ((id1, id2) NOT IN (SELECT id1, id2 FROM test WHERE (region = 'Asia')))"
532
- @dataset.exclude([:id1, :id2] => [[1, 2], [3,4]].sql_array).sql.should == "SELECT * FROM test WHERE ((id1, id2) NOT IN ((1, 2), (3, 4)))"
512
+ @dataset.exclude([:id1, :id2] => Sequel.value_list([[1, 2], [3,4]])).sql.should == "SELECT * FROM test WHERE ((id1, id2) NOT IN ((1, 2), (3, 4)))"
533
513
  @dataset.exclude([:id1, :id2] => [[1, 2], [3,4]]).sql.should == "SELECT * FROM test WHERE ((id1, id2) NOT IN ((1, 2), (3, 4)))"
534
514
  end
535
515
 
536
516
  specify "should handle IN/NOT IN queries with multiple columns and an array where the database doesn't support it" do
537
517
  @dataset.meta_def(:supports_multiple_column_in?){false}
538
- @dataset.filter([:id1, :id2] => [[1, 2], [3,4]].sql_array).sql.should == "SELECT * FROM test WHERE (((id1 = 1) AND (id2 = 2)) OR ((id1 = 3) AND (id2 = 4)))"
539
- @dataset.exclude([:id1, :id2] => [[1, 2], [3,4]].sql_array).sql.should == "SELECT * FROM test WHERE (((id1 != 1) OR (id2 != 2)) AND ((id1 != 3) OR (id2 != 4)))"
518
+ @dataset.filter([:id1, :id2] => [[1, 2], [3,4]]).sql.should == "SELECT * FROM test WHERE (((id1 = 1) AND (id2 = 2)) OR ((id1 = 3) AND (id2 = 4)))"
519
+ @dataset.exclude([:id1, :id2] => [[1, 2], [3,4]]).sql.should == "SELECT * FROM test WHERE (((id1 != 1) OR (id2 != 2)) AND ((id1 != 3) OR (id2 != 4)))"
520
+ @dataset.filter([:id1, :id2] => Sequel.value_list([[1, 2], [3,4]])).sql.should == "SELECT * FROM test WHERE (((id1 = 1) AND (id2 = 2)) OR ((id1 = 3) AND (id2 = 4)))"
521
+ @dataset.exclude([:id1, :id2] => Sequel.value_list([[1, 2], [3,4]])).sql.should == "SELECT * FROM test WHERE (((id1 != 1) OR (id2 != 2)) AND ((id1 != 3) OR (id2 != 4)))"
540
522
  end
541
523
 
542
524
  specify "should handle IN/NOT IN queries with multiple columns and a dataset where the database doesn't support it" do
@@ -586,35 +568,21 @@ describe "Dataset#where" do
586
568
  end
587
569
 
588
570
  specify "should accept a subquery for an EXISTS clause" do
589
- a = @dataset.filter(:price.sql_number < 100)
590
- @dataset.filter(a.exists).sql.should ==
591
- 'SELECT * FROM test WHERE (EXISTS (SELECT * FROM test WHERE (price < 100)))'
571
+ a = @dataset.filter(Sequel.expr(:price) < 100)
572
+ @dataset.filter(a.exists).sql.should == 'SELECT * FROM test WHERE (EXISTS (SELECT * FROM test WHERE (price < 100)))'
592
573
  end
593
574
 
594
575
  specify "should accept proc expressions" do
595
- d = @d1.select(:avg.sql_function(:gdp))
596
- @dataset.filter {:gdp.sql_number > d}.sql.should ==
597
- "SELECT * FROM test WHERE (gdp > (SELECT avg(gdp) FROM test WHERE (region = 'Asia')))"
598
-
599
- @dataset.filter {:a.sql_number < 1}.sql.should ==
600
- 'SELECT * FROM test WHERE (a < 1)'
601
-
602
- @dataset.filter {(:a.sql_number >= 1) & (:b.sql_number <= 2)}.sql.should ==
603
- 'SELECT * FROM test WHERE ((a >= 1) AND (b <= 2))'
604
-
605
- @dataset.filter {:c.like 'ABC%'}.sql.should ==
606
- "SELECT * FROM test WHERE (c LIKE 'ABC%')"
607
-
608
- @dataset.filter {:c.like 'ABC%'}.sql.should ==
609
- "SELECT * FROM test WHERE (c LIKE 'ABC%')"
610
-
611
- @dataset.filter {:c.like 'ABC%', '%XYZ'}.sql.should ==
612
- "SELECT * FROM test WHERE ((c LIKE 'ABC%') OR (c LIKE '%XYZ'))"
576
+ d = @d1.select(Sequel.function(:avg, :gdp))
577
+ @dataset.filter{gdp > d}.sql.should == "SELECT * FROM test WHERE (gdp > (SELECT avg(gdp) FROM test WHERE (region = 'Asia')))"
578
+ @dataset.filter{a < 1}.sql.should == 'SELECT * FROM test WHERE (a < 1)'
579
+ @dataset.filter{(a >= 1) & (b <= 2)}.sql.should == 'SELECT * FROM test WHERE ((a >= 1) AND (b <= 2))'
580
+ @dataset.filter{c.like 'ABC%'}.sql.should == "SELECT * FROM test WHERE (c LIKE 'ABC%')"
581
+ @dataset.filter{c.like 'ABC%', '%XYZ'}.sql.should == "SELECT * FROM test WHERE ((c LIKE 'ABC%') OR (c LIKE '%XYZ'))"
613
582
  end
614
583
 
615
584
  specify "should work for grouped datasets" do
616
- @dataset.group(:a).filter(:b => 1).sql.should ==
617
- 'SELECT * FROM test WHERE (b = 1) GROUP BY a'
585
+ @dataset.group(:a).filter(:b => 1).sql.should == 'SELECT * FROM test WHERE (b = 1) GROUP BY a'
618
586
  end
619
587
 
620
588
  specify "should accept true and false as arguments" do
@@ -633,17 +601,13 @@ describe "Dataset#where" do
633
601
  end
634
602
 
635
603
  specify "should allow the use of multiple arguments" do
636
- @dataset.filter(:a, :b).sql.should ==
637
- 'SELECT * FROM test WHERE (a AND b)'
638
- @dataset.filter(:a, :b=>1).sql.should ==
639
- 'SELECT * FROM test WHERE (a AND (b = 1))'
640
- @dataset.filter(:a, :c.sql_number > 3, :b=>1).sql.should ==
641
- 'SELECT * FROM test WHERE (a AND (c > 3) AND (b = 1))'
604
+ @dataset.filter(:a, :b).sql.should == 'SELECT * FROM test WHERE (a AND b)'
605
+ @dataset.filter(:a, :b=>1).sql.should == 'SELECT * FROM test WHERE (a AND (b = 1))'
606
+ @dataset.filter(:a, Sequel.expr(:c) > 3, :b=>1).sql.should == 'SELECT * FROM test WHERE (a AND (c > 3) AND (b = 1))'
642
607
  end
643
608
 
644
609
  specify "should allow the use of blocks and arguments simultaneously" do
645
- @dataset.filter(:zz.sql_number < 3){:yy.sql_number > 3}.sql.should ==
646
- 'SELECT * FROM test WHERE ((zz < 3) AND (yy > 3))'
610
+ @dataset.filter(Sequel.expr(:zz) < 3){yy > 3}.sql.should == 'SELECT * FROM test WHERE ((zz < 3) AND (yy > 3))'
647
611
  end
648
612
 
649
613
  specify "should yield a VirtualRow to the block" do
@@ -667,8 +631,8 @@ describe "Dataset#where" do
667
631
  end
668
632
 
669
633
  specify "should raise an error if a NumericExpression or StringExpression is used" do
670
- proc{@dataset.filter(:x + 1)}.should raise_error(Sequel::Error)
671
- proc{@dataset.filter(:x.sql_string)}.should raise_error(Sequel::Error)
634
+ proc{@dataset.filter(Sequel.expr(:x) + 1)}.should raise_error(Sequel::Error)
635
+ proc{@dataset.filter(Sequel.expr(:x).sql_string)}.should raise_error(Sequel::Error)
672
636
  end
673
637
  end
674
638
 
@@ -688,11 +652,11 @@ describe "Dataset#or" do
688
652
 
689
653
  specify "should accept all forms of filters" do
690
654
  @d1.or('y > ?', 2).sql.should == 'SELECT * FROM test WHERE ((x = 1) OR (y > 2))'
691
- @d1.or(:yy.sql_number > 3).sql.should == 'SELECT * FROM test WHERE ((x = 1) OR (yy > 3))'
655
+ @d1.or(Sequel.expr(:yy) > 3).sql.should == 'SELECT * FROM test WHERE ((x = 1) OR (yy > 3))'
692
656
  end
693
657
 
694
658
  specify "should accept blocks passed to filter" do
695
- @d1.or{:yy.sql_number > 3}.sql.should == 'SELECT * FROM test WHERE ((x = 1) OR (yy > 3))'
659
+ @d1.or{yy > 3}.sql.should == 'SELECT * FROM test WHERE ((x = 1) OR (yy > 3))'
696
660
  end
697
661
 
698
662
  specify "should correctly add parens to give predictable results" do
@@ -701,7 +665,7 @@ describe "Dataset#or" do
701
665
  end
702
666
 
703
667
  specify "should allow the use of blocks and arguments simultaneously" do
704
- @d1.or(:zz.sql_number < 3){:yy.sql_number > 3}.sql.should == 'SELECT * FROM test WHERE ((x = 1) OR ((zz < 3) AND (yy > 3)))'
668
+ @d1.or(Sequel.expr(:zz) < 3){yy > 3}.sql.should == 'SELECT * FROM test WHERE ((x = 1) OR ((zz < 3) AND (yy > 3)))'
705
669
  end
706
670
  end
707
671
 
@@ -723,11 +687,11 @@ describe "Dataset#and" do
723
687
 
724
688
  specify "should accept different types of filters" do
725
689
  @d1.and('y > ?', 2).sql.should == 'SELECT * FROM test WHERE ((x = 1) AND (y > 2))'
726
- @d1.and(:yy.sql_number > 3).sql.should == 'SELECT * FROM test WHERE ((x = 1) AND (yy > 3))'
690
+ @d1.and(Sequel.expr(:yy) > 3).sql.should == 'SELECT * FROM test WHERE ((x = 1) AND (yy > 3))'
727
691
  end
728
692
 
729
693
  specify "should accept blocks passed to filter" do
730
- @d1.and {:yy.sql_number > 3}.sql.should == 'SELECT * FROM test WHERE ((x = 1) AND (yy > 3))'
694
+ @d1.and{yy > 3}.sql.should == 'SELECT * FROM test WHERE ((x = 1) AND (yy > 3))'
731
695
  end
732
696
 
733
697
  specify "should correctly add parens to give predictable results" do
@@ -768,12 +732,12 @@ describe "Dataset#exclude" do
768
732
  end
769
733
 
770
734
  specify "should support proc expressions" do
771
- @dataset.exclude{:id.sql_number < 6}.sql.should == 'SELECT * FROM test WHERE (id >= 6)'
735
+ @dataset.exclude{id < 6}.sql.should == 'SELECT * FROM test WHERE (id >= 6)'
772
736
  end
773
737
 
774
738
  specify "should allow the use of blocks and arguments simultaneously" do
775
- @dataset.exclude(:id => (7..11)){:id.sql_number < 6}.sql.should == 'SELECT * FROM test WHERE ((id < 7) OR (id > 11) OR (id >= 6))'
776
- @dataset.exclude([:id, 1], [:x, 3]){:id.sql_number < 6}.sql.should == 'SELECT * FROM test WHERE ((id != 1) OR (x != 3) OR (id >= 6))'
739
+ @dataset.exclude(:id => (7..11)){id < 6}.sql.should == 'SELECT * FROM test WHERE ((id < 7) OR (id > 11) OR (id >= 6))'
740
+ @dataset.exclude([:id, 1], [:x, 3]){id < 6}.sql.should == 'SELECT * FROM test WHERE ((id != 1) OR (x != 3) OR (id >= 6))'
777
741
  end
778
742
  end
779
743
 
@@ -820,7 +784,7 @@ end
820
784
  describe "Dataset#having" do
821
785
  before do
822
786
  @dataset = Sequel::Dataset.new(nil).from(:test)
823
- @grouped = @dataset.group(:region).select(:region, :sum.sql_function(:population), :avg.sql_function(:gdp))
787
+ @grouped = @dataset.group(:region).select(:region, Sequel.function(:sum, :population), Sequel.function(:avg, :gdp))
824
788
  end
825
789
 
826
790
  specify "should just clone if given an empty argument" do
@@ -834,11 +798,11 @@ describe "Dataset#having" do
834
798
  end
835
799
 
836
800
  specify "should support proc expressions" do
837
- @grouped.having {:sum.sql_function(:population) > 10}.sql.should == "SELECT region, sum(population), avg(gdp) FROM test GROUP BY region HAVING (sum(population) > 10)"
801
+ @grouped.having{Sequel.function(:sum, :population) > 10}.sql.should == "SELECT region, sum(population), avg(gdp) FROM test GROUP BY region HAVING (sum(population) > 10)"
838
802
  end
839
803
 
840
804
  specify "should work with and on the having clause" do
841
- @grouped.having( :a.sql_number > 1 ).and( :b.sql_number < 2 ).sql.should == "SELECT region, sum(population), avg(gdp) FROM test GROUP BY region HAVING ((a > 1) AND (b < 2))"
805
+ @grouped.having(Sequel.expr(:a) > 1).and(Sequel.expr(:b) < 2).sql.should == "SELECT region, sum(population), avg(gdp) FROM test GROUP BY region HAVING ((a > 1) AND (b < 2))"
842
806
  end
843
807
  end
844
808
 
@@ -998,7 +962,7 @@ describe "Dataset#literal" do
998
962
  end
999
963
 
1000
964
  specify "should escape blobs as strings by default" do
1001
- @dataset.literal('abc'.to_sequel_blob).should == "'abc'"
965
+ @dataset.literal(Sequel.blob('abc')).should == "'abc'"
1002
966
  end
1003
967
 
1004
968
  specify "should literalize numbers properly" do
@@ -1141,8 +1105,8 @@ describe "Dataset#literal" do
1141
1105
 
1142
1106
  specify "should not modify literal strings" do
1143
1107
  @dataset.quote_identifiers = true
1144
- @dataset.literal('col1 + 2'.lit).should == 'col1 + 2'
1145
- @dataset.update_sql(Sequel::SQL::Identifier.new('a'.lit) => 'a + 2'.lit).should == 'UPDATE "test" SET a = a + 2'
1108
+ @dataset.literal(Sequel.lit('col1 + 2')).should == 'col1 + 2'
1109
+ @dataset.update_sql(Sequel::SQL::Identifier.new(Sequel.lit('a')) => Sequel.lit('a + 2')).should == 'UPDATE "test" SET a = a + 2'
1146
1110
  end
1147
1111
 
1148
1112
  specify "should literalize BigDecimal instances correctly" do
@@ -1206,8 +1170,8 @@ describe "Dataset#from" do
1206
1170
 
1207
1171
  specify "should not treat literal strings or blobs as identifiers" do
1208
1172
  @dataset.quote_identifiers = true
1209
- @dataset.from('a'.lit).select_sql.should == "SELECT * FROM a"
1210
- @dataset.from('a'.to_sequel_blob).select_sql.should == "SELECT * FROM 'a'"
1173
+ @dataset.from(Sequel.lit('a')).select_sql.should == "SELECT * FROM a"
1174
+ @dataset.from(Sequel.blob('a')).select_sql.should == "SELECT * FROM 'a'"
1211
1175
  end
1212
1176
 
1213
1177
  specify "should remove all FROM tables if called with no arguments" do
@@ -1215,8 +1179,8 @@ describe "Dataset#from" do
1215
1179
  end
1216
1180
 
1217
1181
  specify "should accept sql functions" do
1218
- @dataset.from(:abc.sql_function(:def)).select_sql.should == "SELECT * FROM abc(def)"
1219
- @dataset.from(:a.sql_function(:i)).select_sql.should == "SELECT * FROM a(i)"
1182
+ @dataset.from(Sequel.function(:abc, :def)).select_sql.should == "SELECT * FROM abc(def)"
1183
+ @dataset.from(Sequel.function(:a, :i)).select_sql.should == "SELECT * FROM a(i)"
1220
1184
  end
1221
1185
 
1222
1186
  specify "should accept :schema__table___alias symbol format" do
@@ -1254,19 +1218,19 @@ describe "Dataset#select" do
1254
1218
  end
1255
1219
 
1256
1220
  specify "should accept symbols and literal strings" do
1257
- @d.select('aaa'.lit).sql.should == 'SELECT aaa FROM test'
1258
- @d.select(:a, 'b'.lit).sql.should == 'SELECT a, b FROM test'
1259
- @d.select(:test__cc, 'test.d AS e'.lit).sql.should == 'SELECT test.cc, test.d AS e FROM test'
1260
- @d.select('test.d AS e'.lit, :test__cc).sql.should == 'SELECT test.d AS e, test.cc FROM test'
1221
+ @d.select(Sequel.lit('aaa')).sql.should == 'SELECT aaa FROM test'
1222
+ @d.select(:a, Sequel.lit('b')).sql.should == 'SELECT a, b FROM test'
1223
+ @d.select(:test__cc, Sequel.lit('test.d AS e')).sql.should == 'SELECT test.cc, test.d AS e FROM test'
1224
+ @d.select(Sequel.lit('test.d AS e'), :test__cc).sql.should == 'SELECT test.d AS e, test.cc FROM test'
1261
1225
  @d.select(:test__name___n).sql.should == 'SELECT test.name AS n FROM test'
1262
1226
  end
1263
1227
 
1264
1228
  specify "should accept ColumnAlls" do
1265
- @d.select(:test.*).sql.should == 'SELECT test.* FROM test'
1229
+ @d.select(Sequel::SQL::ColumnAll.new(:test)).sql.should == 'SELECT test.* FROM test'
1266
1230
  end
1267
1231
 
1268
1232
  specify "should accept QualifiedIdentifiers" do
1269
- @d.select(:test__name.as(:n)).sql.should == 'SELECT test.name AS n FROM test'
1233
+ @d.select(Sequel.expr(:test__name).as(:n)).sql.should == 'SELECT test.name AS n FROM test'
1270
1234
  end
1271
1235
 
1272
1236
  specify "should use the wildcard if no arguments are given" do
@@ -1288,7 +1252,7 @@ describe "Dataset#select" do
1288
1252
 
1289
1253
  specify "should accept arbitrary objects and literalize them correctly" do
1290
1254
  @d.select(1, :a, 't').sql.should == "SELECT 1, a, 't' FROM test"
1291
- @d.select(nil, :sum.sql_function(:t), :x___y).sql.should == "SELECT NULL, sum(t), x AS y FROM test"
1255
+ @d.select(nil, Sequel.function(:sum, :t), :x___y).sql.should == "SELECT NULL, sum(t), x AS y FROM test"
1292
1256
  @d.select(nil, 1, :x => :y).sql.should == "SELECT NULL, 1, x AS y FROM test"
1293
1257
  end
1294
1258
 
@@ -1359,15 +1323,15 @@ describe "Dataset#select_all" do
1359
1323
  end
1360
1324
 
1361
1325
  specify "should work correctly with SQL::Identifiers" do
1362
- @d.select_all(:test.identifier).sql.should == 'SELECT test.* FROM test'
1326
+ @d.select_all(Sequel.identifier(:test)).sql.should == 'SELECT test.* FROM test'
1363
1327
  end
1364
1328
 
1365
1329
  specify "should work correctly with SQL::QualifiedIdentifier" do
1366
- @d.select_all(:test.qualify(:sch)).sql.should == 'SELECT sch.test.* FROM test'
1330
+ @d.select_all(Sequel.qualify(:sch, :test)).sql.should == 'SELECT sch.test.* FROM test'
1367
1331
  end
1368
1332
 
1369
1333
  specify "should work correctly with SQL::AliasedExpressions" do
1370
- @d.select_all(:test.as(:al)).sql.should == 'SELECT al.* FROM test'
1334
+ @d.select_all(Sequel.expr(:test).as(:al)).sql.should == 'SELECT al.* FROM test'
1371
1335
  end
1372
1336
 
1373
1337
  specify "should work correctly with SQL::JoinClauses" do
@@ -1389,12 +1353,12 @@ describe "Dataset#select_more" do
1389
1353
 
1390
1354
  specify "should add to the currently selected columns" do
1391
1355
  @d.select(:a).select_more(:b).sql.should == 'SELECT a, b FROM test'
1392
- @d.select(:a.*).select_more(:b.*).sql.should == 'SELECT a.*, b.* FROM test'
1356
+ @d.select(Sequel::SQL::ColumnAll.new(:a)).select_more(Sequel::SQL::ColumnAll.new(:b)).sql.should == 'SELECT a.*, b.* FROM test'
1393
1357
  end
1394
1358
 
1395
1359
  specify "should accept a block that yields a virtual row" do
1396
1360
  @d.select(:a).select_more{|o| o.b}.sql.should == 'SELECT a, b FROM test'
1397
- @d.select(:a.*).select_more(:b.*){b(1)}.sql.should == 'SELECT a.*, b.*, b(1) FROM test'
1361
+ @d.select(Sequel::SQL::ColumnAll.new(:a)).select_more(Sequel::SQL::ColumnAll.new(:b)){b(1)}.sql.should == 'SELECT a.*, b.*, b(1) FROM test'
1398
1362
  end
1399
1363
  end
1400
1364
 
@@ -1411,12 +1375,12 @@ describe "Dataset#select_append" do
1411
1375
 
1412
1376
  specify "should add to the currently selected columns" do
1413
1377
  @d.select(:a).select_append(:b).sql.should == 'SELECT a, b FROM test'
1414
- @d.select(:a.*).select_append(:b.*).sql.should == 'SELECT a.*, b.* FROM test'
1378
+ @d.select(Sequel::SQL::ColumnAll.new(:a)).select_append(Sequel::SQL::ColumnAll.new(:b)).sql.should == 'SELECT a.*, b.* FROM test'
1415
1379
  end
1416
1380
 
1417
1381
  specify "should accept a block that yields a virtual row" do
1418
1382
  @d.select(:a).select_append{|o| o.b}.sql.should == 'SELECT a, b FROM test'
1419
- @d.select(:a.*).select_append(:b.*){b(1)}.sql.should == 'SELECT a.*, b.*, b(1) FROM test'
1383
+ @d.select(Sequel::SQL::ColumnAll.new(:a)).select_append(Sequel::SQL::ColumnAll.new(:b)){b(1)}.sql.should == 'SELECT a.*, b.*, b(1) FROM test'
1420
1384
  end
1421
1385
 
1422
1386
  specify "should select from all from and join tables if SELECT *, column not supported" do
@@ -1438,11 +1402,11 @@ describe "Dataset#order" do
1438
1402
  end
1439
1403
 
1440
1404
  specify "should accept multiple arguments" do
1441
- @dataset.order(:name, :price.desc).sql.should == 'SELECT * FROM test ORDER BY name, price DESC'
1405
+ @dataset.order(:name, Sequel.desc(:price)).sql.should == 'SELECT * FROM test ORDER BY name, price DESC'
1442
1406
  end
1443
1407
 
1444
1408
  specify "should accept :nulls options for asc and desc" do
1445
- @dataset.order(:name.asc(:nulls=>:last), :price.desc(:nulls=>:first)).sql.should == 'SELECT * FROM test ORDER BY name ASC NULLS LAST, price DESC NULLS FIRST'
1409
+ @dataset.order(Sequel.asc(:name, :nulls=>:last), Sequel.desc(:price, :nulls=>:first)).sql.should == 'SELECT * FROM test ORDER BY name ASC NULLS LAST, price DESC NULLS FIRST'
1446
1410
  end
1447
1411
 
1448
1412
  specify "should override a previous ordering" do
@@ -1450,7 +1414,7 @@ describe "Dataset#order" do
1450
1414
  end
1451
1415
 
1452
1416
  specify "should accept a literal string" do
1453
- @dataset.order('dada ASC'.lit).sql.should == 'SELECT * FROM test ORDER BY dada ASC'
1417
+ @dataset.order(Sequel.lit('dada ASC')).sql.should == 'SELECT * FROM test ORDER BY dada ASC'
1454
1418
  end
1455
1419
 
1456
1420
  specify "should accept a hash as an expression" do
@@ -1539,7 +1503,7 @@ describe "Dataset#order_by" do
1539
1503
  end
1540
1504
 
1541
1505
  specify "should accept multiple arguments" do
1542
- @dataset.order_by(:name, :price.desc).sql.should == 'SELECT * FROM test ORDER BY name, price DESC'
1506
+ @dataset.order_by(:name, Sequel.desc(:price)).sql.should == 'SELECT * FROM test ORDER BY name, price DESC'
1543
1507
  end
1544
1508
 
1545
1509
  specify "should override a previous ordering" do
@@ -1547,7 +1511,7 @@ describe "Dataset#order_by" do
1547
1511
  end
1548
1512
 
1549
1513
  specify "should accept a string" do
1550
- @dataset.order_by('dada ASC'.lit).sql.should == 'SELECT * FROM test ORDER BY dada ASC'
1514
+ @dataset.order_by(Sequel.lit('dada ASC')).sql.should == 'SELECT * FROM test ORDER BY dada ASC'
1551
1515
  end
1552
1516
 
1553
1517
  specify "should accept a nil to remove ordering" do
@@ -1566,8 +1530,8 @@ describe "Dataset#order_more and order_append" do
1566
1530
  end
1567
1531
 
1568
1532
  specify "should add to the end of a previous ordering" do
1569
- @dataset.order(:name).order_more(:stamp.desc).sql.should == 'SELECT * FROM test ORDER BY name, stamp DESC'
1570
- @dataset.order(:name).order_append(:stamp.desc).sql.should == 'SELECT * FROM test ORDER BY name, stamp DESC'
1533
+ @dataset.order(:name).order_more(Sequel.desc(:stamp)).sql.should == 'SELECT * FROM test ORDER BY name, stamp DESC'
1534
+ @dataset.order(:name).order_append(Sequel.desc(:stamp)).sql.should == 'SELECT * FROM test ORDER BY name, stamp DESC'
1571
1535
  end
1572
1536
 
1573
1537
  specify "should accept a block that yields a virtual row" do
@@ -1588,7 +1552,7 @@ describe "Dataset#order_prepend" do
1588
1552
  end
1589
1553
 
1590
1554
  specify "should add to the beginning of a previous ordering" do
1591
- @dataset.order(:name).order_prepend(:stamp.desc).sql.should == 'SELECT * FROM test ORDER BY stamp DESC, name'
1555
+ @dataset.order(:name).order_prepend(Sequel.desc(:stamp)).sql.should == 'SELECT * FROM test ORDER BY stamp DESC, name'
1592
1556
  end
1593
1557
 
1594
1558
  specify "should accept a block that yields a virtual row" do
@@ -1607,24 +1571,24 @@ describe "Dataset#reverse_order" do
1607
1571
  end
1608
1572
 
1609
1573
  specify "should invert the order given" do
1610
- @dataset.reverse_order(:name.desc).sql.should == 'SELECT * FROM test ORDER BY name ASC'
1574
+ @dataset.reverse_order(Sequel.desc(:name)).sql.should == 'SELECT * FROM test ORDER BY name ASC'
1611
1575
  end
1612
1576
 
1613
1577
  specify "should invert the order for ASC expressions" do
1614
- @dataset.reverse_order(:name.asc).sql.should == 'SELECT * FROM test ORDER BY name DESC'
1578
+ @dataset.reverse_order(Sequel.asc(:name)).sql.should == 'SELECT * FROM test ORDER BY name DESC'
1615
1579
  end
1616
1580
 
1617
1581
  specify "should accept multiple arguments" do
1618
- @dataset.reverse_order(:name, :price.desc).sql.should == 'SELECT * FROM test ORDER BY name DESC, price ASC'
1582
+ @dataset.reverse_order(:name, Sequel.desc(:price)).sql.should == 'SELECT * FROM test ORDER BY name DESC, price ASC'
1619
1583
  end
1620
1584
 
1621
1585
  specify "should handles NULLS ordering correctly when reversing" do
1622
- @dataset.reverse_order(:name.asc(:nulls=>:first), :price.desc(:nulls=>:last)).sql.should == 'SELECT * FROM test ORDER BY name DESC NULLS LAST, price ASC NULLS FIRST'
1586
+ @dataset.reverse_order(Sequel.asc(:name, :nulls=>:first), Sequel.desc(:price, :nulls=>:last)).sql.should == 'SELECT * FROM test ORDER BY name DESC NULLS LAST, price ASC NULLS FIRST'
1623
1587
  end
1624
1588
 
1625
1589
  specify "should reverse a previous ordering if no arguments are given" do
1626
1590
  @dataset.order(:name).reverse_order.sql.should == 'SELECT * FROM test ORDER BY name DESC'
1627
- @dataset.order(:clumsy.desc, :fool).reverse_order.sql.should == 'SELECT * FROM test ORDER BY clumsy ASC, fool DESC'
1591
+ @dataset.order(Sequel.desc(:clumsy), :fool).reverse_order.sql.should == 'SELECT * FROM test ORDER BY clumsy ASC, fool DESC'
1628
1592
  end
1629
1593
 
1630
1594
  specify "should return an unordered dataset for a dataset with no order" do
@@ -1659,11 +1623,11 @@ describe "Dataset#limit" do
1659
1623
  end
1660
1624
 
1661
1625
  specify "should not convert literal strings to integers" do
1662
- @dataset.limit('6'.lit, 'a() - 1'.lit).sql.should == 'SELECT * FROM test LIMIT 6 OFFSET a() - 1'
1626
+ @dataset.limit(Sequel.lit('6'), Sequel.lit('a() - 1')).sql.should == 'SELECT * FROM test LIMIT 6 OFFSET a() - 1'
1663
1627
  end
1664
1628
 
1665
1629
  specify "should not convert other objects" do
1666
- @dataset.limit(6, :a.sql_function - 1).sql.should == 'SELECT * FROM test LIMIT 6 OFFSET (a() - 1)'
1630
+ @dataset.limit(6, Sequel.function(:a) - 1).sql.should == 'SELECT * FROM test LIMIT 6 OFFSET (a() - 1)'
1667
1631
  end
1668
1632
 
1669
1633
  specify "should work with fixed sql datasets" do
@@ -1707,7 +1671,7 @@ describe "Dataset#qualified_column_name" do
1707
1671
  specify "should return the literal value if not given a symbol" do
1708
1672
  @dataset.literal(@dataset.send(:qualified_column_name, 'ccc__b', :items)).should == "'ccc__b'"
1709
1673
  @dataset.literal(@dataset.send(:qualified_column_name, 3, :items)).should == '3'
1710
- @dataset.literal(@dataset.send(:qualified_column_name, 'a'.lit, :items)).should == 'a'
1674
+ @dataset.literal(@dataset.send(:qualified_column_name, Sequel.lit('a'), :items)).should == 'a'
1711
1675
  end
1712
1676
 
1713
1677
  specify "should qualify the column with the supplied table name if given an unqualified symbol" do
@@ -1719,7 +1683,7 @@ describe "Dataset#qualified_column_name" do
1719
1683
  end
1720
1684
 
1721
1685
  specify "should handle an aliased identifier" do
1722
- @dataset.literal(@dataset.send(:qualified_column_name, :ccc, :items.as(:i))).should == 'i.ccc'
1686
+ @dataset.literal(@dataset.send(:qualified_column_name, :ccc, Sequel.expr(:items).as(:i))).should == 'i.ccc'
1723
1687
  end
1724
1688
  end
1725
1689
 
@@ -1852,7 +1816,7 @@ describe "Dataset#distinct" do
1852
1816
  specify "should use DISTINCT ON if columns are given and DISTINCT ON is supported" do
1853
1817
  @dataset.meta_def(:supports_distinct_on?){true}
1854
1818
  @dataset.distinct(:a, :b).sql.should == 'SELECT DISTINCT ON (a, b) name FROM test'
1855
- @dataset.distinct(:stamp.cast(:integer), :node_id=>nil).sql.should == 'SELECT DISTINCT ON (CAST(stamp AS integer), (node_id IS NULL)) name FROM test'
1819
+ @dataset.distinct(Sequel.cast(:stamp, :integer), :node_id=>nil).sql.should == 'SELECT DISTINCT ON (CAST(stamp AS integer), (node_id IS NULL)) name FROM test'
1856
1820
  end
1857
1821
 
1858
1822
  specify "should do a subselect for count" do
@@ -1873,7 +1837,7 @@ describe "Dataset#count" do
1873
1837
  end
1874
1838
 
1875
1839
  specify "should include the where clause if it's there" do
1876
- @dataset.filter(:abc.sql_number < 30).count.should == 1
1840
+ @dataset.filter(Sequel.expr(:abc) < 30).count.should == 1
1877
1841
  @db.sqls.should == ['SELECT COUNT(*) AS count FROM test WHERE (abc < 30) LIMIT 1']
1878
1842
  end
1879
1843
 
@@ -1931,16 +1895,16 @@ describe "Dataset#group_and_count" do
1931
1895
  end
1932
1896
 
1933
1897
  specify "should handle identifiers" do
1934
- @ds.group_and_count(:name___n.identifier).sql.should == "SELECT name___n, count(*) AS count FROM test GROUP BY name___n"
1898
+ @ds.group_and_count(Sequel.identifier(:name___n)).sql.should == "SELECT name___n, count(*) AS count FROM test GROUP BY name___n"
1935
1899
  end
1936
1900
 
1937
1901
  specify "should handle literal strings" do
1938
- @ds.group_and_count("name".lit).sql.should == "SELECT name, count(*) AS count FROM test GROUP BY name"
1902
+ @ds.group_and_count(Sequel.lit("name")).sql.should == "SELECT name, count(*) AS count FROM test GROUP BY name"
1939
1903
  end
1940
1904
 
1941
1905
  specify "should handle aliased expressions" do
1942
- @ds.group_and_count(:name.as(:n)).sql.should == "SELECT name AS n, count(*) AS count FROM test GROUP BY name"
1943
- @ds.group_and_count(:name.identifier.as(:n)).sql.should == "SELECT name AS n, count(*) AS count FROM test GROUP BY name"
1906
+ @ds.group_and_count(Sequel.expr(:name).as(:n)).sql.should == "SELECT name AS n, count(*) AS count FROM test GROUP BY name"
1907
+ @ds.group_and_count(Sequel.identifier(:name).as(:n)).sql.should == "SELECT name AS n, count(*) AS count FROM test GROUP BY name"
1944
1908
  end
1945
1909
 
1946
1910
  specify "should take a virtual row block" do
@@ -1967,22 +1931,22 @@ describe "Dataset#first_source_alias" do
1967
1931
 
1968
1932
  specify "should be the entire first source if not aliased" do
1969
1933
  @ds.from(:t).first_source_alias.should == :t
1970
- @ds.from(:t__a.identifier).first_source_alias.should == :t__a.identifier
1934
+ @ds.from(Sequel.identifier(:t__a)).first_source_alias.should == Sequel.identifier(:t__a)
1971
1935
  @ds.from(:s__t).first_source_alias.should == :s__t
1972
- @ds.from(:t.qualify(:s)).first_source_alias.should == :t.qualify(:s)
1936
+ @ds.from(Sequel.qualify(:s, :t)).first_source_alias.should == Sequel.qualify(:s, :t)
1973
1937
  end
1974
1938
 
1975
1939
  specify "should be the alias if aliased" do
1976
1940
  @ds.from(:t___a).first_source_alias.should == :a
1977
1941
  @ds.from(:s__t___a).first_source_alias.should == :a
1978
- @ds.from(:t.as(:a)).first_source_alias.should == :a
1942
+ @ds.from(Sequel.expr(:t).as(:a)).first_source_alias.should == :a
1979
1943
  end
1980
1944
 
1981
1945
  specify "should be aliased as first_source" do
1982
1946
  @ds.from(:t).first_source.should == :t
1983
- @ds.from(:t__a.identifier).first_source.should == :t__a.identifier
1947
+ @ds.from(Sequel.identifier(:t__a)).first_source.should == Sequel.identifier(:t__a)
1984
1948
  @ds.from(:s__t___a).first_source.should == :a
1985
- @ds.from(:t.as(:a)).first_source.should == :a
1949
+ @ds.from(Sequel.expr(:t).as(:a)).first_source.should == :a
1986
1950
  end
1987
1951
 
1988
1952
  specify "should raise exception if table doesn't have a source" do
@@ -1997,15 +1961,15 @@ describe "Dataset#first_source_table" do
1997
1961
 
1998
1962
  specify "should be the entire first source if not aliased" do
1999
1963
  @ds.from(:t).first_source_table.should == :t
2000
- @ds.from(:t__a.identifier).first_source_table.should == :t__a.identifier
1964
+ @ds.from(Sequel.identifier(:t__a)).first_source_table.should == Sequel.identifier(:t__a)
2001
1965
  @ds.from(:s__t).first_source_table.should == :s__t
2002
- @ds.from(:t.qualify(:s)).first_source_table.should == :t.qualify(:s)
1966
+ @ds.from(Sequel.qualify(:s, :t)).first_source_table.should == Sequel.qualify(:s, :t)
2003
1967
  end
2004
1968
 
2005
1969
  specify "should be the unaliased part if aliased" do
2006
1970
  @ds.literal(@ds.from(:t___a).first_source_table).should == "t"
2007
1971
  @ds.literal(@ds.from(:s__t___a).first_source_table).should == "s.t"
2008
- @ds.literal(@ds.from(:t.as(:a)).first_source_table).should == "t"
1972
+ @ds.literal(@ds.from(Sequel.expr(:t).as(:a)).first_source_table).should == "t"
2009
1973
  end
2010
1974
 
2011
1975
  specify "should raise exception if table doesn't have a source" do
@@ -2064,7 +2028,7 @@ describe "Dataset#join_table" do
2064
2028
  end
2065
2029
 
2066
2030
  specify "should include WHERE clause if applicable" do
2067
- @d.filter(:price.sql_number < 100).join_table(:right_outer, :categories, :category_id => :id).sql.should ==
2031
+ @d.filter(Sequel.expr(:price) < 100).join_table(:right_outer, :categories, :category_id => :id).sql.should ==
2068
2032
  'SELECT * FROM "items" RIGHT OUTER JOIN "categories" ON ("categories"."category_id" = "items"."id") WHERE ("price" < 100)'
2069
2033
  end
2070
2034
 
@@ -2128,7 +2092,7 @@ describe "Dataset#join_table" do
2128
2092
  end
2129
2093
 
2130
2094
  specify "should support aliased tables using an implicit alias" do
2131
- @d.from('stats').join(:players.as(:p), {:id => :player_id}).sql.should == 'SELECT * FROM "stats" INNER JOIN "players" AS "p" ON ("p"."id" = "stats"."player_id")'
2095
+ @d.from('stats').join(Sequel.expr(:players).as(:p), {:id => :player_id}).sql.should == 'SELECT * FROM "stats" INNER JOIN "players" AS "p" ON ("p"."id" = "stats"."player_id")'
2132
2096
  end
2133
2097
 
2134
2098
  specify "should support using an alias for the FROM when doing the first join with unqualified condition columns" do
@@ -2145,7 +2109,7 @@ describe "Dataset#join_table" do
2145
2109
  end
2146
2110
 
2147
2111
  specify "should support AliasedExpressions" do
2148
- @d.from(:s.as(:t)).join(:u.as(:v), {:id => :player_id}).sql.should == 'SELECT * FROM "s" AS "t" INNER JOIN "u" AS "v" ON ("v"."id" = "t"."player_id")'
2112
+ @d.from(Sequel.expr(:s).as(:t)).join(Sequel.expr(:u).as(:v), {:id => :player_id}).sql.should == 'SELECT * FROM "s" AS "t" INNER JOIN "u" AS "v" ON ("v"."id" = "t"."player_id")'
2149
2113
  end
2150
2114
 
2151
2115
  specify "should support the :implicit_qualifier option" do
@@ -2163,7 +2127,7 @@ describe "Dataset#join_table" do
2163
2127
  specify "should allow for arbitrary conditions in the JOIN clause" do
2164
2128
  @d.join_table(:left_outer, :categories, :status => 0).sql.should == 'SELECT * FROM "items" LEFT OUTER JOIN "categories" ON ("categories"."status" = 0)'
2165
2129
  @d.join_table(:left_outer, :categories, :categorizable_type => "Post").sql.should == 'SELECT * FROM "items" LEFT OUTER JOIN "categories" ON ("categories"."categorizable_type" = \'Post\')'
2166
- @d.join_table(:left_outer, :categories, :timestamp => "CURRENT_TIMESTAMP".lit).sql.should == 'SELECT * FROM "items" LEFT OUTER JOIN "categories" ON ("categories"."timestamp" = CURRENT_TIMESTAMP)'
2130
+ @d.join_table(:left_outer, :categories, :timestamp => Sequel::CURRENT_TIMESTAMP).sql.should == 'SELECT * FROM "items" LEFT OUTER JOIN "categories" ON ("categories"."timestamp" = CURRENT_TIMESTAMP)'
2167
2131
  @d.join_table(:left_outer, :categories, :status => [1, 2, 3]).sql.should == 'SELECT * FROM "items" LEFT OUTER JOIN "categories" ON ("categories"."status" IN (1, 2, 3))'
2168
2132
  end
2169
2133
 
@@ -2210,7 +2174,7 @@ describe "Dataset#join_table" do
2210
2174
  end
2211
2175
 
2212
2176
  specify "should support using an expression as the join condition" do
2213
- @d.join(:categories, :number.sql_number > 10).sql.should == 'SELECT * FROM "items" INNER JOIN "categories" ON ("number" > 10)'
2177
+ @d.join(:categories, Sequel.expr(:number) > 10).sql.should == 'SELECT * FROM "items" INNER JOIN "categories" ON ("number" > 10)'
2214
2178
  end
2215
2179
 
2216
2180
  specify "should support natural and cross joins" do
@@ -2289,18 +2253,18 @@ describe "Dataset#join_table" do
2289
2253
  end
2290
2254
 
2291
2255
  specify "should use the block result as the only condition if no condition is given" do
2292
- @d.join(:categories){|j,lj,js| {:b.qualify(j)=>:c.qualify(lj)}}.sql.should == 'SELECT * FROM "items" INNER JOIN "categories" ON ("categories"."b" = "items"."c")'
2293
- @d.join(:categories){|j,lj,js| :b.qualify(j) > :c.qualify(lj)}.sql.should == 'SELECT * FROM "items" INNER JOIN "categories" ON ("categories"."b" > "items"."c")'
2256
+ @d.join(:categories){|j,lj,js| {Sequel.qualify(j, :b)=>Sequel.qualify(lj, :c)}}.sql.should == 'SELECT * FROM "items" INNER JOIN "categories" ON ("categories"."b" = "items"."c")'
2257
+ @d.join(:categories){|j,lj,js| Sequel.qualify(j, :b) > Sequel.qualify(lj, :c)}.sql.should == 'SELECT * FROM "items" INNER JOIN "categories" ON ("categories"."b" > "items"."c")'
2294
2258
  end
2295
2259
 
2296
2260
  specify "should combine the block conditions and argument conditions if both given" do
2297
- @d.join(:categories, :a=>:d){|j,lj,js| {:b.qualify(j)=>:c.qualify(lj)}}.sql.should == 'SELECT * FROM "items" INNER JOIN "categories" ON (("categories"."a" = "items"."d") AND ("categories"."b" = "items"."c"))'
2298
- @d.join(:categories, :a=>:d){|j,lj,js| :b.qualify(j) > :c.qualify(lj)}.sql.should == 'SELECT * FROM "items" INNER JOIN "categories" ON (("categories"."a" = "items"."d") AND ("categories"."b" > "items"."c"))'
2261
+ @d.join(:categories, :a=>:d){|j,lj,js| {Sequel.qualify(j, :b)=>Sequel.qualify(lj, :c)}}.sql.should == 'SELECT * FROM "items" INNER JOIN "categories" ON (("categories"."a" = "items"."d") AND ("categories"."b" = "items"."c"))'
2262
+ @d.join(:categories, :a=>:d){|j,lj,js| Sequel.qualify(j, :b) > Sequel.qualify(lj, :c)}.sql.should == 'SELECT * FROM "items" INNER JOIN "categories" ON (("categories"."a" = "items"."d") AND ("categories"."b" > "items"."c"))'
2299
2263
  end
2300
2264
 
2301
2265
  specify "should prefer explicit aliases over implicit" do
2302
2266
  @d.from(:items___i).join(:categories___c, {:category_id => :id}, {:table_alias=>:c2, :implicit_qualifier=>:i2}).sql.should == 'SELECT * FROM "items" AS "i" INNER JOIN "categories" AS "c2" ON ("c2"."category_id" = "i2"."id")'
2303
- @d.from(:items.as(:i)).join(:categories.as(:c), {:category_id => :id}, {:table_alias=>:c2, :implicit_qualifier=>:i2}).sql.should ==
2267
+ @d.from(Sequel.expr(:items).as(:i)).join(Sequel.expr(:categories).as(:c), {:category_id => :id}, {:table_alias=>:c2, :implicit_qualifier=>:i2}).sql.should ==
2304
2268
  'SELECT * FROM "items" AS "i" INNER JOIN "categories" AS "c2" ON ("c2"."category_id" = "i2"."id")'
2305
2269
  end
2306
2270
 
@@ -2313,7 +2277,7 @@ describe "Dataset#join_table" do
2313
2277
 
2314
2278
  specify "should raise an error if an invalid option is passed" do
2315
2279
  proc{@d.join(:c, [:id], nil)}.should raise_error(Sequel::Error)
2316
- proc{@d.join(:c, [:id], :c.qualify(:d))}.should raise_error(Sequel::Error)
2280
+ proc{@d.join(:c, [:id], Sequel.qualify(:d, :c))}.should raise_error(Sequel::Error)
2317
2281
  end
2318
2282
  end
2319
2283
 
@@ -2405,7 +2369,7 @@ describe "Dataset#range" do
2405
2369
  @ds.range(:stamp)
2406
2370
  @db.sqls.should == ["SELECT min(stamp) AS v1, max(stamp) AS v2 FROM test LIMIT 1"]
2407
2371
 
2408
- @ds.filter(:price.sql_number > 100).range(:stamp)
2372
+ @ds.filter(Sequel.expr(:price) > 100).range(:stamp)
2409
2373
  @db.sqls.should == ["SELECT min(stamp) AS v1, max(stamp) AS v2 FROM test WHERE (price > 100) LIMIT 1"]
2410
2374
  end
2411
2375
 
@@ -2429,7 +2393,7 @@ describe "Dataset#interval" do
2429
2393
  @ds.interval(:stamp)
2430
2394
  @db.sqls.should == ["SELECT (max(stamp) - min(stamp)) FROM test LIMIT 1"]
2431
2395
 
2432
- @ds.filter(:price.sql_number > 100).interval(:stamp)
2396
+ @ds.filter(Sequel.expr(:price) > 100).interval(:stamp)
2433
2397
  @db.sqls.should == ["SELECT (max(stamp) - min(stamp)) FROM test WHERE (price > 100) LIMIT 1"]
2434
2398
  end
2435
2399
 
@@ -2465,20 +2429,20 @@ describe "Dataset #first and #last" do
2465
2429
  end
2466
2430
 
2467
2431
  specify "should return the first matching record if a block is given without an argument" do
2468
- @d.first{:z.sql_number > 26}.should == {:s=>'SELECT * FROM test WHERE (z > 26) LIMIT 1'}
2469
- @d.order(:name).last{:z.sql_number > 26}.should == {:s=>'SELECT * FROM test WHERE (z > 26) ORDER BY name DESC LIMIT 1'}
2432
+ @d.first{z > 26}.should == {:s=>'SELECT * FROM test WHERE (z > 26) LIMIT 1'}
2433
+ @d.order(:name).last{z > 26}.should == {:s=>'SELECT * FROM test WHERE (z > 26) ORDER BY name DESC LIMIT 1'}
2470
2434
  end
2471
2435
 
2472
2436
  specify "should combine block and standard argument filters if argument is not an Integer" do
2473
- @d.first(:y=>25){:z.sql_number > 26}.should == {:s=>'SELECT * FROM test WHERE ((z > 26) AND (y = 25)) LIMIT 1'}
2474
- @d.order(:name).last('y = ?', 16){:z.sql_number > 26}.should == {:s=>'SELECT * FROM test WHERE ((z > 26) AND (y = 16)) ORDER BY name DESC LIMIT 1'}
2437
+ @d.first(:y=>25){z > 26}.should == {:s=>'SELECT * FROM test WHERE ((z > 26) AND (y = 25)) LIMIT 1'}
2438
+ @d.order(:name).last('y = ?', 16){z > 26}.should == {:s=>'SELECT * FROM test WHERE ((z > 26) AND (y = 16)) ORDER BY name DESC LIMIT 1'}
2475
2439
  end
2476
2440
 
2477
2441
  specify "should filter and return an array of records if an Integer argument is provided and a block is given" do
2478
2442
  i = rand(10) + 10
2479
- r = @d.order(:a).first(i){:z.sql_number > 26}.should == [{:s=>"SELECT * FROM test WHERE (z > 26) ORDER BY a LIMIT #{i}"}]
2443
+ r = @d.order(:a).first(i){z > 26}.should == [{:s=>"SELECT * FROM test WHERE (z > 26) ORDER BY a LIMIT #{i}"}]
2480
2444
  i = rand(10) + 10
2481
- r = @d.order(:a).last(i){:z.sql_number > 26}.should == [{:s=>"SELECT * FROM test WHERE (z > 26) ORDER BY a DESC LIMIT #{i}"}]
2445
+ r = @d.order(:a).last(i){z > 26}.should == [{:s=>"SELECT * FROM test WHERE (z > 26) ORDER BY a DESC LIMIT #{i}"}]
2482
2446
  end
2483
2447
 
2484
2448
  specify "#last should raise if no order is given" do
@@ -2490,9 +2454,9 @@ describe "Dataset #first and #last" do
2490
2454
 
2491
2455
  specify "#last should invert the order" do
2492
2456
  @d.order(:a).last.should == {:s=>'SELECT * FROM test ORDER BY a DESC LIMIT 1'}
2493
- @d.order(:b.desc).last.should == {:s=>'SELECT * FROM test ORDER BY b ASC LIMIT 1'}
2457
+ @d.order(Sequel.desc(:b)).last.should == {:s=>'SELECT * FROM test ORDER BY b ASC LIMIT 1'}
2494
2458
  @d.order(:c, :d).last.should == {:s=>'SELECT * FROM test ORDER BY c DESC, d DESC LIMIT 1'}
2495
- @d.order(:e.desc, :f).last.should == {:s=>'SELECT * FROM test ORDER BY e ASC, f DESC LIMIT 1'}
2459
+ @d.order(Sequel.desc(:e), :f).last.should == {:s=>'SELECT * FROM test ORDER BY e ASC, f DESC LIMIT 1'}
2496
2460
  end
2497
2461
  end
2498
2462
 
@@ -2659,7 +2623,7 @@ describe "Dataset#get" do
2659
2623
  end
2660
2624
 
2661
2625
  specify "should work with aliased fields" do
2662
- @d.get(:x__b.as(:name)).should == "SELECT x.b AS name FROM test LIMIT 1"
2626
+ @d.get(Sequel.expr(:x__b).as(:name)).should == "SELECT x.b AS name FROM test LIMIT 1"
2663
2627
  end
2664
2628
 
2665
2629
  specify "should accept a block that yields a virtual row" do
@@ -2897,7 +2861,7 @@ describe "Dataset#multi_insert" do
2897
2861
  "INSERT INTO sch.tab (name) VALUES ('ghi')",
2898
2862
  'COMMIT']
2899
2863
 
2900
- @ds = @ds.from(:tab.qualify(:sch))
2864
+ @ds = @ds.from(Sequel.qualify(:sch, :tab))
2901
2865
  @ds.multi_insert(@list)
2902
2866
  @db.sqls.should == ['BEGIN',
2903
2867
  "INSERT INTO sch.tab (name) VALUES ('abc')",
@@ -2905,7 +2869,7 @@ describe "Dataset#multi_insert" do
2905
2869
  "INSERT INTO sch.tab (name) VALUES ('ghi')",
2906
2870
  'COMMIT']
2907
2871
 
2908
- @ds = @ds.from(:sch__tab.identifier)
2872
+ @ds = @ds.from(Sequel.identifier(:sch__tab))
2909
2873
  @ds.multi_insert(@list)
2910
2874
  @db.sqls.should == ['BEGIN',
2911
2875
  "INSERT INTO sch__tab (name) VALUES ('abc')",
@@ -2978,7 +2942,7 @@ describe "Dataset" do
2978
2942
  end
2979
2943
 
2980
2944
  specify "should support self-changing filter! with block" do
2981
- @d.filter!{:y.sql_number < 2}
2945
+ @d.filter!{y < 2}
2982
2946
  @d.sql.should == "SELECT * FROM x WHERE (y < 2)"
2983
2947
  end
2984
2948
 
@@ -3029,7 +2993,7 @@ describe "Dataset#update_sql" do
3029
2993
  end
3030
2994
 
3031
2995
  specify "should accept array subscript references" do
3032
- @ds.update_sql((:day.sql_subscript(1)) => 'd').should == "UPDATE items SET day[1] = 'd'"
2996
+ @ds.update_sql((Sequel.subscript(:day, 1)) => 'd').should == "UPDATE items SET day[1] = 'd'"
3033
2997
  end
3034
2998
  end
3035
2999
 
@@ -3047,7 +3011,7 @@ describe "Dataset#insert_sql" do
3047
3011
  end
3048
3012
 
3049
3013
  specify "should accept array subscript references" do
3050
- @ds.insert_sql((:day.sql_subscript(1)) => 'd').should == "INSERT INTO items (day[1]) VALUES ('d')"
3014
+ @ds.insert_sql((Sequel.subscript(:day, 1)) => 'd').should == "INSERT INTO items (day[1]) VALUES ('d')"
3051
3015
  end
3052
3016
 
3053
3017
  specify "should raise an Error if the dataset has no sources" do
@@ -3085,11 +3049,11 @@ describe "Dataset#insert_sql" do
3085
3049
  end
3086
3050
 
3087
3051
  specify "should accept a single LiteralString" do
3088
- @ds.insert_sql('VALUES (1, 2, 3)'.lit).should == "INSERT INTO items VALUES (1, 2, 3)"
3052
+ @ds.insert_sql(Sequel.lit('VALUES (1, 2, 3)')).should == "INSERT INTO items VALUES (1, 2, 3)"
3089
3053
  end
3090
3054
 
3091
3055
  specify "should accept an array of columns and an LiteralString" do
3092
- @ds.insert_sql([:a, :b, :c], 'VALUES (1, 2, 3)'.lit).should == "INSERT INTO items (a, b, c) VALUES (1, 2, 3)"
3056
+ @ds.insert_sql([:a, :b, :c], Sequel.lit('VALUES (1, 2, 3)')).should == "INSERT INTO items (a, b, c) VALUES (1, 2, 3)"
3093
3057
  end
3094
3058
 
3095
3059
  specify "should accept an object that responds to values and returns a hash by using that hash as the columns and values" do
@@ -3427,7 +3391,7 @@ describe "Sequel::Dataset#server" do
3427
3391
  @ds.all
3428
3392
  @ds.server(:i).insert(:a=>1)
3429
3393
  @ds.server(:d).delete
3430
- @ds.server(:u).update(:a=>:a+1)
3394
+ @ds.server(:u).update(:a=>Sequel.expr(:a)+1)
3431
3395
  @db.sqls.should == ['SELECT * FROM items -- s', 'INSERT INTO items (a) VALUES (1) -- i', 'DELETE FROM items -- d', 'UPDATE items SET a = (a + 1) -- u']
3432
3396
  end
3433
3397
  end
@@ -3538,7 +3502,7 @@ describe "Sequel::Dataset#qualify_to_first_source" do
3538
3502
  end
3539
3503
 
3540
3504
  specify "should handle hashes" do
3541
- @ds.select({:b=>{:c=>1}}.case(false)).qualify_to_first_source.sql.should == "SELECT (CASE WHEN t.b THEN (t.c = 1) ELSE 'f' END) FROM t"
3505
+ @ds.select(Sequel.case({:b=>{:c=>1}}, false)).qualify_to_first_source.sql.should == "SELECT (CASE WHEN t.b THEN (t.c = 1) ELSE 'f' END) FROM t"
3542
3506
  end
3543
3507
 
3544
3508
  specify "should handle SQL::Identifiers" do
@@ -3546,15 +3510,15 @@ describe "Sequel::Dataset#qualify_to_first_source" do
3546
3510
  end
3547
3511
 
3548
3512
  specify "should handle SQL::OrderedExpressions" do
3549
- @ds.order(:a.desc, :b.asc).qualify_to_first_source.sql.should == 'SELECT t.* FROM t ORDER BY t.a DESC, t.b ASC'
3513
+ @ds.order(Sequel.desc(:a), Sequel.asc(:b)).qualify_to_first_source.sql.should == 'SELECT t.* FROM t ORDER BY t.a DESC, t.b ASC'
3550
3514
  end
3551
3515
 
3552
3516
  specify "should handle SQL::AliasedExpressions" do
3553
- @ds.select(:a.as(:b)).qualify_to_first_source.sql.should == 'SELECT t.a AS b FROM t'
3517
+ @ds.select(Sequel.expr(:a).as(:b)).qualify_to_first_source.sql.should == 'SELECT t.a AS b FROM t'
3554
3518
  end
3555
3519
 
3556
3520
  specify "should handle SQL::CaseExpressions" do
3557
- @ds.filter{{a=>b}.case(c, d)}.qualify_to_first_source.sql.should == 'SELECT t.* FROM t WHERE (CASE t.d WHEN t.a THEN t.b ELSE t.c END)'
3521
+ @ds.filter{Sequel.case({a=>b}, c, d)}.qualify_to_first_source.sql.should == 'SELECT t.* FROM t WHERE (CASE t.d WHEN t.a THEN t.b ELSE t.c END)'
3558
3522
  end
3559
3523
 
3560
3524
  specify "should handle SQL:Casts" do
@@ -3570,7 +3534,7 @@ describe "Sequel::Dataset#qualify_to_first_source" do
3570
3534
  end
3571
3535
 
3572
3536
  specify "should handle SQL::ValueLists" do
3573
- @ds.filter(:a=>[:b, :c].sql_value_list).qualify_to_first_source.sql.should == 'SELECT t.* FROM t WHERE (t.a IN (t.b, t.c))'
3537
+ @ds.filter(:a=>Sequel.value_list([:b, :c])).qualify_to_first_source.sql.should == 'SELECT t.* FROM t WHERE (t.a IN (t.b, t.c))'
3574
3538
  end
3575
3539
 
3576
3540
  specify "should handle SQL::Subscripts" do
@@ -3595,7 +3559,7 @@ describe "Sequel::Dataset#qualify_to_first_source" do
3595
3559
  end
3596
3560
 
3597
3561
  specify "should handle all other objects by returning them unchanged" do
3598
- @ds.select("a").filter{a(3)}.filter('blah').order('true'.lit).group('a > ?'.lit(1)).having(false).qualify_to_first_source.sql.should == "SELECT 'a' FROM t WHERE (a(3) AND (blah)) GROUP BY a > 1 HAVING 'f' ORDER BY true"
3562
+ @ds.select("a").filter{a(3)}.filter('blah').order(Sequel.lit('true')).group(Sequel.lit('a > ?', 1)).having(false).qualify_to_first_source.sql.should == "SELECT 'a' FROM t WHERE (a(3) AND (blah)) GROUP BY a > 1 HAVING 'f' ORDER BY true"
3599
3563
  end
3600
3564
  end
3601
3565
 
@@ -3632,7 +3596,7 @@ describe "Sequel::Dataset#unbind" do
3632
3596
  end
3633
3597
 
3634
3598
  specify "should not unbind literal strings" do
3635
- @u[@ds.filter(:foo=>'a'.lit)].should == ["SELECT * FROM t WHERE (foo = a)", {}]
3599
+ @u[@ds.filter(:foo=>Sequel.lit('a'))].should == ["SELECT * FROM t WHERE (foo = a)", {}]
3636
3600
  end
3637
3601
 
3638
3602
  specify "should not unbind Identifiers, QualifiedIdentifiers, or Symbols used as booleans" do
@@ -3652,7 +3616,7 @@ describe "Sequel::Dataset#unbind" do
3652
3616
  end
3653
3617
 
3654
3618
  specify "should handle deep nesting" do
3655
- @u[@ds.filter{foo > 1}.and{bar < 2}.or(:baz=>3).and({~{:x=>4}=>true}.case(false))].should == ["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}]
3619
+ @u[@ds.filter{foo > 1}.and{bar < 2}.or(:baz=>3).and(Sequel.case({~Sequel.expr(:x=>4)=>true}, false))].should == ["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}]
3656
3620
  end
3657
3621
 
3658
3622
  specify "should handle JOIN ON" do
@@ -3955,8 +3919,8 @@ describe "Sequel::Dataset#select_map" do
3955
3919
  end
3956
3920
 
3957
3921
  specify "should raise if multiple arguments and can't determine alias" do
3958
- proc{@ds.select_map([:a.sql_function, :b])}.should raise_error(Sequel::Error)
3959
- proc{@ds.select_map(:a.sql_function){b}}.should raise_error(Sequel::Error)
3922
+ proc{@ds.select_map([Sequel.function(:a), :b])}.should raise_error(Sequel::Error)
3923
+ proc{@ds.select_map(Sequel.function(:a)){b}}.should raise_error(Sequel::Error)
3960
3924
  proc{@ds.select_map{[a{}, b]}}.should raise_error(Sequel::Error)
3961
3925
  end
3962
3926
 
@@ -3966,7 +3930,7 @@ describe "Sequel::Dataset#select_map" do
3966
3930
  end
3967
3931
 
3968
3932
  specify "should handle other objects" do
3969
- @ds.select_map("a".lit.as(:b)).should == [1, 2]
3933
+ @ds.select_map(Sequel.lit("a").as(:b)).should == [1, 2]
3970
3934
  @ds.db.sqls.should == ['SELECT a AS b FROM t']
3971
3935
  end
3972
3936
 
@@ -3998,7 +3962,7 @@ describe "Sequel::Dataset#select_map" do
3998
3962
  specify "should handle an array of columns" do
3999
3963
  @ds.select_map([:c, :c]).should == [[1, 1], [2, 2]]
4000
3964
  @ds.db.sqls.should == ['SELECT c, c FROM t']
4001
- @ds.select_map([:d.as(:c), :c.qualify(:b), :c.identifier, :c.identifier.qualify(:b), :a__c, :a__d___c]).should == [[1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2]]
3965
+ @ds.select_map([Sequel.expr(:d).as(:c), Sequel.qualify(:b, :c), Sequel.identifier(:c), Sequel.identifier(:c).qualify(:b), :a__c, :a__d___c]).should == [[1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2]]
4002
3966
  @ds.db.sqls.should == ['SELECT d AS c, b.c, c, b.c, a.c, a.d AS c FROM t']
4003
3967
  end
4004
3968
 
@@ -4024,8 +3988,8 @@ describe "Sequel::Dataset#select_order_map" do
4024
3988
  end
4025
3989
 
4026
3990
  specify "should raise if multiple arguments and can't determine alias" do
4027
- proc{@ds.select_order_map([:a.sql_function, :b])}.should raise_error(Sequel::Error)
4028
- proc{@ds.select_order_map(:a.sql_function){b}}.should raise_error(Sequel::Error)
3991
+ proc{@ds.select_order_map([Sequel.function(:a), :b])}.should raise_error(Sequel::Error)
3992
+ proc{@ds.select_order_map(Sequel.function(:a)){b}}.should raise_error(Sequel::Error)
4029
3993
  proc{@ds.select_order_map{[a{}, b]}}.should raise_error(Sequel::Error)
4030
3994
  end
4031
3995
 
@@ -4040,12 +4004,12 @@ describe "Sequel::Dataset#select_order_map" do
4040
4004
  end
4041
4005
 
4042
4006
  specify "should handle AliasedExpressions" do
4043
- @ds.select_order_map("a".lit.as(:b)).should == [1, 2]
4007
+ @ds.select_order_map(Sequel.lit("a").as(:b)).should == [1, 2]
4044
4008
  @ds.db.sqls.should == ['SELECT a AS b FROM t ORDER BY a']
4045
4009
  end
4046
4010
 
4047
4011
  specify "should handle OrderedExpressions" do
4048
- @ds.select_order_map(:a.desc).should == [1, 2]
4012
+ @ds.select_order_map(Sequel.desc(:a)).should == [1, 2]
4049
4013
  @ds.db.sqls.should == ['SELECT a FROM t ORDER BY a DESC']
4050
4014
  end
4051
4015
 
@@ -4072,8 +4036,8 @@ describe "Sequel::Dataset#select_order_map" do
4072
4036
  specify "should handle an array of columns" do
4073
4037
  @ds.select_order_map([:c, :c]).should == [[1, 1], [2, 2]]
4074
4038
  @ds.db.sqls.should == ['SELECT c, c FROM t ORDER BY c, c']
4075
- @ds.select_order_map([:d.as(:c), :c.qualify(:b), :c.identifier, :c.identifier.qualify(:b), :c.identifier.qualify(:b).desc, :a__c, :a__d___c.desc]).should == [[1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2]]
4076
- @ds.db.sqls.should == ['SELECT d AS c, b.c, c, b.c, b.c, a.c, a.d AS c FROM t ORDER BY d, b.c, c, b.c, b.c DESC, a.c, a.d DESC']
4039
+ @ds.select_order_map([Sequel.expr(:d).as(:c), Sequel.qualify(:b, :c), Sequel.identifier(:c), Sequel.identifier(:c).qualify(:b), Sequel.identifier(:c).qualify(:b).desc, :a__c, Sequel.desc(:a__d___c), Sequel.desc(Sequel.expr(:a__d___c))]).should == [[1, 1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2, 2]]
4040
+ @ds.db.sqls.should == ['SELECT d AS c, b.c, c, b.c, b.c, a.c, a.d AS c, a.d AS c FROM t ORDER BY d, b.c, c, b.c, b.c DESC, a.c, a.d DESC, a.d DESC']
4077
4041
  end
4078
4042
 
4079
4043
  specify "should handle an array with a single element" do
@@ -4109,17 +4073,17 @@ describe "Sequel::Dataset#select_hash" do
4109
4073
  end
4110
4074
 
4111
4075
  specify "should handle SQL::Identifiers in arguments" do
4112
- @ds.select_hash(:a.identifier, :b.identifier).should == {1=>2, 3=>4}
4076
+ @ds.select_hash(Sequel.identifier(:a), Sequel.identifier(:b)).should == {1=>2, 3=>4}
4113
4077
  @ds.db.sqls.should == ['SELECT a, b FROM t']
4114
4078
  end
4115
4079
 
4116
4080
  specify "should handle SQL::QualifiedIdentifiers in arguments" do
4117
- @ds.select_hash(:a.qualify(:t), :b.identifier.qualify(:t)).should == {1=>2, 3=>4}
4081
+ @ds.select_hash(Sequel.qualify(:t, :a), Sequel.identifier(:b).qualify(:t)).should == {1=>2, 3=>4}
4118
4082
  @ds.db.sqls.should == ['SELECT t.a, t.b FROM t']
4119
4083
  end
4120
4084
 
4121
4085
  specify "should handle SQL::AliasedExpressions in arguments" do
4122
- @ds.select_hash(:c.as(:a), :t.as(:b)).should == {1=>2, 3=>4}
4086
+ @ds.select_hash(Sequel.expr(:c).as(:a), Sequel.expr(:t).as(:b)).should == {1=>2, 3=>4}
4123
4087
  @ds.db.sqls.should == ['SELECT c AS a, t AS b FROM t']
4124
4088
  end
4125
4089
 
@@ -4134,7 +4098,7 @@ describe "Sequel::Dataset#select_hash" do
4134
4098
  end
4135
4099
 
4136
4100
  specify "should raise an error if the resulting symbol cannot be determined" do
4137
- proc{@ds.select_hash(:c.as(:a), :b.sql_function)}.should raise_error(Sequel::Error)
4101
+ proc{@ds.select_hash(Sequel.expr(:c).as(:a), Sequel.function(:b))}.should raise_error(Sequel::Error)
4138
4102
  end
4139
4103
  end
4140
4104
 
@@ -4165,17 +4129,17 @@ describe "Sequel::Dataset#select_hash_groups" do
4165
4129
  end
4166
4130
 
4167
4131
  specify "should handle SQL::Identifiers in arguments" do
4168
- @ds.select_hash_groups(:a.identifier, :b.identifier).should == {1=>[2], 3=>[4]}
4132
+ @ds.select_hash_groups(Sequel.identifier(:a), Sequel.identifier(:b)).should == {1=>[2], 3=>[4]}
4169
4133
  @ds.db.sqls.should == ['SELECT a, b FROM t']
4170
4134
  end
4171
4135
 
4172
4136
  specify "should handle SQL::QualifiedIdentifiers in arguments" do
4173
- @ds.select_hash_groups(:a.qualify(:t), :b.identifier.qualify(:t)).should == {1=>[2], 3=>[4]}
4137
+ @ds.select_hash_groups(Sequel.qualify(:t, :a), Sequel.identifier(:b).qualify(:t)).should == {1=>[2], 3=>[4]}
4174
4138
  @ds.db.sqls.should == ['SELECT t.a, t.b FROM t']
4175
4139
  end
4176
4140
 
4177
4141
  specify "should handle SQL::AliasedExpressions in arguments" do
4178
- @ds.select_hash_groups(:c.as(:a), :t.as(:b)).should == {1=>[2], 3=>[4]}
4142
+ @ds.select_hash_groups(Sequel.expr(:c).as(:a), Sequel.expr(:t).as(:b)).should == {1=>[2], 3=>[4]}
4179
4143
  @ds.db.sqls.should == ['SELECT c AS a, t AS b FROM t']
4180
4144
  end
4181
4145
 
@@ -4190,7 +4154,7 @@ describe "Sequel::Dataset#select_hash_groups" do
4190
4154
  end
4191
4155
 
4192
4156
  specify "should raise an error if the resulting symbol cannot be determined" do
4193
- proc{@ds.select_hash_groups(:c.as(:a), :b.sql_function)}.should raise_error(Sequel::Error)
4157
+ proc{@ds.select_hash_groups(Sequel.expr(:c).as(:a), Sequel.function(:b))}.should raise_error(Sequel::Error)
4194
4158
  end
4195
4159
  end
4196
4160
 
@@ -4296,8 +4260,8 @@ describe "Dataset emulating bitwise operator support" do
4296
4260
 
4297
4261
  it "should work with any numbers of arguments for operators" do
4298
4262
  @ds.select(Sequel::SQL::ComplexExpression.new(:&, :x)).sql.should == 'SELECT "x"'
4299
- @ds.select(:x & 1).sql.should == 'SELECT bitand("x", 1)'
4300
- @ds.select(:x & 1 & 2).sql.should == 'SELECT bitand(bitand("x", 1), 2)'
4263
+ @ds.select(Sequel.expr(:x) & 1).sql.should == 'SELECT bitand("x", 1)'
4264
+ @ds.select(Sequel.expr(:x) & 1 & 2).sql.should == 'SELECT bitand(bitand("x", 1), 2)'
4301
4265
  end
4302
4266
  end
4303
4267