sequel 3.37.0 → 3.38.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +56 -0
- data/README.rdoc +82 -58
- data/Rakefile +6 -5
- data/bin/sequel +1 -1
- data/doc/active_record.rdoc +67 -52
- data/doc/advanced_associations.rdoc +33 -48
- data/doc/association_basics.rdoc +41 -51
- data/doc/cheat_sheet.rdoc +21 -21
- data/doc/core_extensions.rdoc +374 -0
- data/doc/dataset_basics.rdoc +5 -5
- data/doc/dataset_filtering.rdoc +47 -43
- data/doc/mass_assignment.rdoc +1 -1
- data/doc/migration.rdoc +4 -5
- data/doc/model_hooks.rdoc +3 -3
- data/doc/object_model.rdoc +31 -25
- data/doc/opening_databases.rdoc +19 -5
- data/doc/prepared_statements.rdoc +2 -2
- data/doc/querying.rdoc +109 -52
- data/doc/reflection.rdoc +6 -6
- data/doc/release_notes/3.38.0.txt +234 -0
- data/doc/schema_modification.rdoc +22 -13
- data/doc/sharding.rdoc +8 -9
- data/doc/sql.rdoc +154 -112
- data/doc/testing.rdoc +47 -7
- data/doc/thread_safety.rdoc +1 -1
- data/doc/transactions.rdoc +1 -1
- data/doc/validations.rdoc +1 -1
- data/doc/virtual_rows.rdoc +29 -43
- data/lib/sequel/adapters/do/postgres.rb +1 -4
- data/lib/sequel/adapters/jdbc.rb +14 -3
- data/lib/sequel/adapters/jdbc/db2.rb +9 -0
- data/lib/sequel/adapters/jdbc/derby.rb +41 -4
- data/lib/sequel/adapters/jdbc/jtds.rb +11 -0
- data/lib/sequel/adapters/jdbc/postgresql.rb +3 -6
- data/lib/sequel/adapters/mock.rb +10 -4
- data/lib/sequel/adapters/postgres.rb +1 -28
- data/lib/sequel/adapters/shared/mssql.rb +23 -13
- data/lib/sequel/adapters/shared/postgres.rb +46 -0
- data/lib/sequel/adapters/swift.rb +21 -13
- data/lib/sequel/adapters/swift/mysql.rb +1 -0
- data/lib/sequel/adapters/swift/postgres.rb +4 -5
- data/lib/sequel/adapters/swift/sqlite.rb +2 -1
- data/lib/sequel/adapters/tinytds.rb +14 -2
- data/lib/sequel/adapters/utils/pg_types.rb +5 -0
- data/lib/sequel/core.rb +29 -17
- data/lib/sequel/database/query.rb +1 -1
- data/lib/sequel/database/schema_generator.rb +3 -0
- data/lib/sequel/dataset/actions.rb +5 -6
- data/lib/sequel/dataset/query.rb +7 -7
- data/lib/sequel/dataset/sql.rb +5 -18
- data/lib/sequel/extensions/core_extensions.rb +8 -12
- data/lib/sequel/extensions/pg_array.rb +59 -33
- data/lib/sequel/extensions/pg_array_ops.rb +32 -4
- data/lib/sequel/extensions/pg_auto_parameterize.rb +1 -1
- data/lib/sequel/extensions/pg_hstore.rb +32 -17
- data/lib/sequel/extensions/pg_hstore_ops.rb +32 -3
- data/lib/sequel/extensions/pg_inet.rb +1 -2
- data/lib/sequel/extensions/pg_interval.rb +0 -1
- data/lib/sequel/extensions/pg_json.rb +41 -23
- data/lib/sequel/extensions/pg_range.rb +36 -11
- data/lib/sequel/extensions/pg_range_ops.rb +32 -4
- data/lib/sequel/extensions/pg_row.rb +572 -0
- data/lib/sequel/extensions/pg_row_ops.rb +164 -0
- data/lib/sequel/extensions/query.rb +3 -3
- data/lib/sequel/extensions/schema_dumper.rb +7 -8
- data/lib/sequel/extensions/select_remove.rb +1 -1
- data/lib/sequel/model/base.rb +1 -0
- data/lib/sequel/no_core_ext.rb +1 -1
- data/lib/sequel/plugins/pg_row.rb +121 -0
- data/lib/sequel/plugins/pg_typecast_on_load.rb +65 -0
- data/lib/sequel/plugins/validation_helpers.rb +31 -0
- data/lib/sequel/sql.rb +64 -44
- data/lib/sequel/version.rb +1 -1
- data/spec/adapters/mssql_spec.rb +37 -12
- data/spec/adapters/mysql_spec.rb +39 -75
- data/spec/adapters/oracle_spec.rb +11 -11
- data/spec/adapters/postgres_spec.rb +414 -237
- data/spec/adapters/spec_helper.rb +1 -1
- data/spec/adapters/sqlite_spec.rb +14 -14
- data/spec/core/database_spec.rb +6 -6
- data/spec/core/dataset_spec.rb +169 -205
- data/spec/core/expression_filters_spec.rb +182 -295
- data/spec/core/object_graph_spec.rb +6 -6
- data/spec/core/schema_spec.rb +14 -14
- data/spec/core/spec_helper.rb +1 -0
- data/spec/{extensions/core_extensions_spec.rb → core_extensions_spec.rb} +208 -14
- data/spec/extensions/columns_introspection_spec.rb +5 -5
- data/spec/extensions/hook_class_methods_spec.rb +28 -36
- data/spec/extensions/many_through_many_spec.rb +4 -4
- data/spec/extensions/pg_array_ops_spec.rb +15 -7
- data/spec/extensions/pg_array_spec.rb +81 -48
- data/spec/extensions/pg_auto_parameterize_spec.rb +2 -2
- data/spec/extensions/pg_hstore_ops_spec.rb +13 -9
- data/spec/extensions/pg_hstore_spec.rb +66 -65
- data/spec/extensions/pg_inet_spec.rb +2 -4
- data/spec/extensions/pg_interval_spec.rb +2 -3
- data/spec/extensions/pg_json_spec.rb +20 -18
- data/spec/extensions/pg_range_ops_spec.rb +11 -4
- data/spec/extensions/pg_range_spec.rb +30 -7
- data/spec/extensions/pg_row_ops_spec.rb +48 -0
- data/spec/extensions/pg_row_plugin_spec.rb +45 -0
- data/spec/extensions/pg_row_spec.rb +323 -0
- data/spec/extensions/pg_typecast_on_load_spec.rb +58 -0
- data/spec/extensions/query_literals_spec.rb +11 -11
- data/spec/extensions/query_spec.rb +3 -3
- data/spec/extensions/schema_dumper_spec.rb +20 -4
- data/spec/extensions/schema_spec.rb +18 -41
- data/spec/extensions/select_remove_spec.rb +4 -4
- data/spec/extensions/spec_helper.rb +4 -8
- data/spec/extensions/to_dot_spec.rb +5 -5
- data/spec/extensions/validation_class_methods_spec.rb +28 -16
- data/spec/integration/associations_test.rb +20 -20
- data/spec/integration/dataset_test.rb +98 -98
- data/spec/integration/eager_loader_test.rb +13 -27
- data/spec/integration/plugin_test.rb +5 -5
- data/spec/integration/prepared_statement_test.rb +22 -13
- data/spec/integration/schema_test.rb +28 -18
- data/spec/integration/spec_helper.rb +1 -1
- data/spec/integration/timezone_test.rb +2 -2
- data/spec/integration/type_test.rb +15 -6
- data/spec/model/association_reflection_spec.rb +1 -1
- data/spec/model/associations_spec.rb +4 -4
- data/spec/model/base_spec.rb +5 -5
- data/spec/model/eager_loading_spec.rb +15 -15
- data/spec/model/model_spec.rb +32 -32
- data/spec/model/record_spec.rb +16 -0
- data/spec/model/spec_helper.rb +2 -6
- data/spec/model/validations_spec.rb +1 -1
- 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|
|
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|
|
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|
|
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|
|
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|
|
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|
|
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|
|
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|
|
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|
|
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|
|
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|
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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,
|
64
|
-
@ds.join(@ds.as(:a), :id=>:id).select(:a__id,
|
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
|
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(
|
304
|
+
INTEGRATION_DB.get(Sequel.cast(str, String)).should == str
|
305
305
|
str = "1#{str}1"
|
306
|
-
INTEGRATION_DB.get(
|
306
|
+
INTEGRATION_DB.get(Sequel.cast(str, String)).should == str
|
307
307
|
str = "#{str}#{str}"
|
308
|
-
INTEGRATION_DB.get(
|
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],
|
313
|
-
INTEGRATION_DB.get("\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.
|
447
|
-
@ds1.union(@ds2.
|
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.
|
450
|
-
@ds2.
|
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).
|
456
|
+
@ds2.union(@ds1).reverse_order(:number).limit(2).map{|x| x[:number].to_s}.should == %w'39 38'
|
457
457
|
|
458
|
-
@ds1.
|
459
|
-
@ds2.order(:number).limit(2).union(@ds1.order(:number).limit(2)).
|
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
|
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
|
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
|
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
|
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
|
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
|
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,
|
816
|
-
@ds.group_by(:a, :b).group_rollup.select_map([:a, :b,
|
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,
|
821
|
-
@ds.group_by(:a, :b).group_cube.select_map([:a, :b,
|
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([
|
1031
|
-
@ds.select_map([:a.
|
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
|
1037
|
-
@ds.select_order_map(:a__b___e
|
1038
|
-
@ds.select_order_map(
|
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
|
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
|
1045
|
-
@ds.select_order_map([:a__a___e
|
1046
|
-
@ds.select_order_map([:a__a
|
1047
|
-
@ds.select_order_map([
|
1048
|
-
@ds.select_order_map([:a.
|
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(
|
1056
|
-
@ds.select_hash(:a.
|
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(
|
1069
|
-
ds.select_hash_groups(:a.
|
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.
|
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
|
1157
|
-
@ds.order(:a.desc
|
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(
|
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(
|
1172
|
-
@ds.get(
|
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.
|
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}
|
1219
|
-
@ds.filter({{:a=>15}=>20}
|
1220
|
-
@ds.filter({20=>20}
|
1221
|
-
@ds.filter({15=>20}
|
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]]
|
1228
|
-
@ds.filter([:a, :b]=>[[10, 20]]
|
1229
|
-
@ds.filter([:a, :b]=>[[20, 10], [1, 2]]
|
1230
|
-
@ds.filter([:a, :b]=>[[10, 10], [20, 20]]
|
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]]
|
1233
|
-
@ds.exclude([:a, :b]=>[[10, 20]]
|
1234
|
-
@ds.exclude([:a, :b]=>[[20, 10], [1, 2]]
|
1235
|
-
@ds.exclude([:a, :b]=>[[10, 10], [20, 20]]
|
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
|
-
#
|
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(
|
1276
|
-
pr[@ds.get(~(
|
1277
|
-
pr[@ds.get(
|
1278
|
-
pr[@ds.get(~(
|
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
|
-
#
|
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(
|
1295
|
-
pr[@ds.get(~(
|
1296
|
-
pr[@ds.get(
|
1297
|
-
pr[@ds.get(~(
|
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}
|
1309
|
-
@ds.filter({:a=>20}
|
1310
|
-
@ds.filter(
|
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
|
1416
|
+
it "should work with strings created with Sequel.join" do
|
1417
1417
|
@ds.insert('foo', 'bar')
|
1418
|
-
@ds.get([:a, "bar"]
|
1419
|
-
@ds.get(["foo", :b]
|
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
|
-
|
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
|
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)
|