sequel 3.48.0 → 4.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +114 -0
- data/Rakefile +10 -7
- data/doc/association_basics.rdoc +25 -23
- data/doc/code_order.rdoc +7 -0
- data/doc/core_extensions.rdoc +0 -10
- data/doc/object_model.rdoc +4 -1
- data/doc/querying.rdoc +3 -3
- data/doc/release_notes/4.0.0.txt +262 -0
- data/doc/security.rdoc +0 -28
- data/doc/testing.rdoc +8 -14
- data/lib/sequel/adapters/ado.rb +7 -11
- data/lib/sequel/adapters/ado/access.rb +8 -8
- data/lib/sequel/adapters/ado/mssql.rb +4 -4
- data/lib/sequel/adapters/amalgalite.rb +6 -6
- data/lib/sequel/adapters/cubrid.rb +7 -7
- data/lib/sequel/adapters/db2.rb +5 -9
- data/lib/sequel/adapters/dbi.rb +2 -6
- data/lib/sequel/adapters/do.rb +4 -4
- data/lib/sequel/adapters/firebird.rb +4 -4
- data/lib/sequel/adapters/ibmdb.rb +8 -8
- data/lib/sequel/adapters/informix.rb +2 -10
- data/lib/sequel/adapters/jdbc.rb +17 -17
- data/lib/sequel/adapters/jdbc/as400.rb +2 -2
- data/lib/sequel/adapters/jdbc/cubrid.rb +1 -1
- data/lib/sequel/adapters/jdbc/db2.rb +1 -1
- data/lib/sequel/adapters/jdbc/derby.rb +1 -1
- data/lib/sequel/adapters/jdbc/h2.rb +2 -2
- data/lib/sequel/adapters/jdbc/hsqldb.rb +1 -1
- data/lib/sequel/adapters/jdbc/informix.rb +1 -1
- data/lib/sequel/adapters/jdbc/mssql.rb +2 -2
- data/lib/sequel/adapters/jdbc/mysql.rb +1 -1
- data/lib/sequel/adapters/jdbc/oracle.rb +5 -1
- data/lib/sequel/adapters/jdbc/postgresql.rb +3 -3
- data/lib/sequel/adapters/jdbc/sqlite.rb +3 -3
- data/lib/sequel/adapters/jdbc/transactions.rb +3 -3
- data/lib/sequel/adapters/mock.rb +7 -7
- data/lib/sequel/adapters/mysql.rb +3 -3
- data/lib/sequel/adapters/mysql2.rb +4 -4
- data/lib/sequel/adapters/odbc.rb +2 -6
- data/lib/sequel/adapters/odbc/mssql.rb +1 -1
- data/lib/sequel/adapters/openbase.rb +1 -5
- data/lib/sequel/adapters/oracle.rb +13 -17
- data/lib/sequel/adapters/postgres.rb +20 -25
- data/lib/sequel/adapters/shared/cubrid.rb +3 -3
- data/lib/sequel/adapters/shared/db2.rb +2 -2
- data/lib/sequel/adapters/shared/firebird.rb +7 -7
- data/lib/sequel/adapters/shared/mssql.rb +9 -9
- data/lib/sequel/adapters/shared/mysql.rb +29 -13
- data/lib/sequel/adapters/shared/mysql_prepared_statements.rb +7 -7
- data/lib/sequel/adapters/shared/oracle.rb +22 -13
- data/lib/sequel/adapters/shared/postgres.rb +61 -46
- data/lib/sequel/adapters/shared/sqlite.rb +9 -9
- data/lib/sequel/adapters/sqlite.rb +17 -11
- data/lib/sequel/adapters/swift.rb +3 -3
- data/lib/sequel/adapters/swift/mysql.rb +1 -1
- data/lib/sequel/adapters/swift/sqlite.rb +1 -1
- data/lib/sequel/adapters/tinytds.rb +8 -8
- data/lib/sequel/ast_transformer.rb +3 -1
- data/lib/sequel/connection_pool.rb +4 -2
- data/lib/sequel/connection_pool/sharded_single.rb +2 -2
- data/lib/sequel/connection_pool/sharded_threaded.rb +5 -5
- data/lib/sequel/connection_pool/threaded.rb +7 -7
- data/lib/sequel/core.rb +4 -67
- data/lib/sequel/database.rb +1 -0
- data/lib/sequel/database/connecting.rb +2 -8
- data/lib/sequel/database/dataset.rb +2 -7
- data/lib/sequel/database/dataset_defaults.rb +0 -18
- data/lib/sequel/database/features.rb +4 -4
- data/lib/sequel/database/misc.rb +6 -8
- data/lib/sequel/database/query.rb +5 -61
- data/lib/sequel/database/schema_generator.rb +22 -20
- data/lib/sequel/database/schema_methods.rb +48 -20
- data/lib/sequel/database/transactions.rb +7 -17
- data/lib/sequel/dataset.rb +2 -0
- data/lib/sequel/dataset/actions.rb +23 -91
- data/lib/sequel/dataset/features.rb +1 -4
- data/lib/sequel/dataset/graph.rb +3 -47
- data/lib/sequel/dataset/misc.rb +4 -33
- data/lib/sequel/dataset/prepared_statements.rb +3 -1
- data/lib/sequel/dataset/query.rb +116 -240
- data/lib/sequel/dataset/sql.rb +19 -97
- data/lib/sequel/deprecated.rb +0 -16
- data/lib/sequel/exceptions.rb +0 -3
- data/lib/sequel/extensions/_pretty_table.rb +1 -1
- data/lib/sequel/extensions/columns_introspection.rb +1 -12
- data/lib/sequel/extensions/constraint_validations.rb +3 -3
- data/lib/sequel/extensions/core_extensions.rb +0 -9
- data/lib/sequel/extensions/date_arithmetic.rb +1 -2
- data/lib/sequel/extensions/graph_each.rb +11 -0
- data/lib/sequel/extensions/migration.rb +5 -5
- data/lib/sequel/extensions/null_dataset.rb +11 -13
- data/lib/sequel/extensions/pagination.rb +3 -6
- data/lib/sequel/extensions/pg_array.rb +6 -4
- data/lib/sequel/extensions/pg_array_ops.rb +35 -1
- data/lib/sequel/extensions/pg_json.rb +12 -2
- data/lib/sequel/extensions/pg_json_ops.rb +266 -0
- data/lib/sequel/extensions/pg_range.rb +2 -2
- data/lib/sequel/extensions/pg_range_ops.rb +0 -8
- data/lib/sequel/extensions/pg_row.rb +2 -2
- data/lib/sequel/extensions/pretty_table.rb +0 -4
- data/lib/sequel/extensions/query.rb +3 -8
- data/lib/sequel/extensions/schema_caching.rb +0 -7
- data/lib/sequel/extensions/schema_dumper.rb +10 -17
- data/lib/sequel/extensions/select_remove.rb +0 -4
- data/lib/sequel/extensions/set_overrides.rb +28 -0
- data/lib/sequel/extensions/to_dot.rb +6 -10
- data/lib/sequel/model.rb +6 -7
- data/lib/sequel/model/associations.rb +127 -182
- data/lib/sequel/model/base.rb +88 -211
- data/lib/sequel/model/errors.rb +0 -13
- data/lib/sequel/model/plugins.rb +2 -2
- data/lib/sequel/no_core_ext.rb +0 -1
- data/lib/sequel/plugins/after_initialize.rb +11 -17
- data/lib/sequel/plugins/association_autoreloading.rb +1 -47
- data/lib/sequel/plugins/association_dependencies.rb +2 -2
- data/lib/sequel/plugins/auto_validations.rb +2 -8
- data/lib/sequel/plugins/blacklist_security.rb +32 -2
- data/lib/sequel/plugins/caching.rb +1 -1
- data/lib/sequel/plugins/class_table_inheritance.rb +2 -2
- data/lib/sequel/plugins/composition.rb +10 -8
- data/lib/sequel/plugins/constraint_validations.rb +2 -2
- data/lib/sequel/plugins/dataset_associations.rb +4 -0
- data/lib/sequel/plugins/defaults_setter.rb +8 -6
- data/lib/sequel/plugins/dirty.rb +6 -6
- data/lib/sequel/plugins/force_encoding.rb +13 -8
- data/lib/sequel/plugins/hook_class_methods.rb +1 -7
- data/lib/sequel/plugins/json_serializer.rb +13 -74
- data/lib/sequel/plugins/lazy_attributes.rb +2 -4
- data/lib/sequel/plugins/list.rb +1 -1
- data/lib/sequel/plugins/many_through_many.rb +4 -11
- data/lib/sequel/plugins/many_to_one_pk_lookup.rb +1 -49
- data/lib/sequel/plugins/nested_attributes.rb +1 -1
- data/lib/sequel/plugins/optimistic_locking.rb +3 -5
- data/lib/sequel/plugins/pg_array_associations.rb +453 -0
- data/lib/sequel/plugins/pg_typecast_on_load.rb +23 -7
- data/lib/sequel/plugins/prepared_statements.rb +1 -1
- data/lib/sequel/plugins/prepared_statements_associations.rb +20 -14
- data/lib/sequel/plugins/prepared_statements_safe.rb +2 -2
- data/lib/sequel/plugins/rcte_tree.rb +1 -1
- data/lib/sequel/plugins/serialization.rb +5 -4
- data/lib/sequel/plugins/serialization_modification_detection.rb +1 -1
- data/lib/sequel/plugins/sharding.rb +7 -1
- data/lib/sequel/plugins/single_table_inheritance.rb +1 -1
- data/lib/sequel/plugins/timestamps.rb +1 -1
- data/lib/sequel/plugins/touch.rb +2 -2
- data/lib/sequel/plugins/tree.rb +1 -1
- data/lib/sequel/plugins/typecast_on_load.rb +19 -4
- data/lib/sequel/plugins/validation_class_methods.rb +0 -30
- data/lib/sequel/plugins/validation_helpers.rb +13 -31
- data/lib/sequel/plugins/xml_serializer.rb +18 -57
- data/lib/sequel/sql.rb +20 -22
- data/lib/sequel/version.rb +2 -2
- data/spec/adapters/db2_spec.rb +14 -23
- data/spec/adapters/firebird_spec.rb +25 -29
- data/spec/adapters/informix_spec.rb +11 -14
- data/spec/adapters/mssql_spec.rb +71 -77
- data/spec/adapters/mysql_spec.rb +165 -172
- data/spec/adapters/oracle_spec.rb +36 -39
- data/spec/adapters/postgres_spec.rb +175 -100
- data/spec/adapters/spec_helper.rb +13 -11
- data/spec/adapters/sqlite_spec.rb +36 -44
- data/spec/core/connection_pool_spec.rb +2 -1
- data/spec/core/database_spec.rb +55 -55
- data/spec/core/dataset_spec.rb +45 -249
- data/spec/core/deprecated_spec.rb +0 -8
- data/spec/core/expression_filters_spec.rb +23 -5
- data/spec/core/object_graph_spec.rb +4 -66
- data/spec/core/schema_spec.rb +35 -12
- data/spec/core/spec_helper.rb +3 -2
- data/spec/core_extensions_spec.rb +17 -19
- data/spec/extensions/arbitrary_servers_spec.rb +2 -3
- data/spec/extensions/association_dependencies_spec.rb +14 -14
- data/spec/extensions/auto_validations_spec.rb +7 -0
- data/spec/extensions/blacklist_security_spec.rb +5 -5
- data/spec/extensions/blank_spec.rb +2 -0
- data/spec/extensions/class_table_inheritance_spec.rb +2 -2
- data/spec/extensions/columns_introspection_spec.rb +2 -29
- data/spec/extensions/composition_spec.rb +10 -17
- data/spec/extensions/core_refinements_spec.rb +5 -1
- data/spec/extensions/dataset_associations_spec.rb +18 -0
- data/spec/extensions/date_arithmetic_spec.rb +2 -2
- data/spec/extensions/defaults_setter_spec.rb +9 -9
- data/spec/extensions/dirty_spec.rb +0 -5
- data/spec/extensions/eval_inspect_spec.rb +2 -0
- data/spec/extensions/force_encoding_spec.rb +2 -18
- data/spec/extensions/hash_aliases_spec.rb +8 -0
- data/spec/extensions/hook_class_methods_spec.rb +39 -58
- data/spec/extensions/inflector_spec.rb +2 -0
- data/spec/extensions/instance_filters_spec.rb +8 -8
- data/spec/extensions/json_serializer_spec.rb +1 -41
- data/spec/extensions/list_spec.rb +1 -1
- data/spec/extensions/many_through_many_spec.rb +106 -109
- data/spec/extensions/migration_spec.rb +2 -0
- data/spec/extensions/named_timezones_spec.rb +1 -0
- data/spec/extensions/pg_array_associations_spec.rb +603 -0
- data/spec/extensions/pg_array_ops_spec.rb +25 -0
- data/spec/extensions/pg_array_spec.rb +9 -1
- data/spec/extensions/pg_hstore_ops_spec.rb +13 -0
- data/spec/extensions/pg_hstore_spec.rb +1 -0
- data/spec/extensions/pg_json_ops_spec.rb +131 -0
- data/spec/extensions/pg_json_spec.rb +10 -4
- data/spec/extensions/pg_range_ops_spec.rb +2 -5
- data/spec/extensions/pg_range_spec.rb +6 -2
- data/spec/extensions/pg_row_ops_spec.rb +2 -0
- data/spec/extensions/prepared_statements_associations_spec.rb +26 -5
- data/spec/extensions/rcte_tree_spec.rb +15 -15
- data/spec/extensions/schema_dumper_spec.rb +0 -1
- data/spec/extensions/schema_spec.rb +9 -9
- data/spec/extensions/serialization_modification_detection_spec.rb +1 -1
- data/spec/extensions/serialization_spec.rb +18 -29
- data/spec/extensions/set_overrides_spec.rb +4 -0
- data/spec/extensions/{many_to_one_pk_lookup_spec.rb → shared_caching_spec.rb} +1 -4
- data/spec/extensions/single_table_inheritance_spec.rb +4 -4
- data/spec/extensions/spec_helper.rb +8 -9
- data/spec/extensions/sql_expr_spec.rb +2 -0
- data/spec/extensions/string_date_time_spec.rb +2 -0
- data/spec/extensions/string_stripper_spec.rb +2 -0
- data/spec/extensions/tactical_eager_loading_spec.rb +12 -12
- data/spec/extensions/thread_local_timezones_spec.rb +2 -0
- data/spec/extensions/timestamps_spec.rb +1 -1
- data/spec/extensions/to_dot_spec.rb +1 -1
- data/spec/extensions/touch_spec.rb +24 -24
- data/spec/extensions/tree_spec.rb +7 -7
- data/spec/extensions/typecast_on_load_spec.rb +8 -1
- data/spec/extensions/update_primary_key_spec.rb +10 -10
- data/spec/extensions/validation_class_methods_spec.rb +10 -39
- data/spec/extensions/validation_helpers_spec.rb +29 -47
- data/spec/extensions/xml_serializer_spec.rb +1 -23
- data/spec/integration/associations_test.rb +231 -40
- data/spec/integration/database_test.rb +1 -1
- data/spec/integration/dataset_test.rb +64 -64
- data/spec/integration/eager_loader_test.rb +28 -28
- data/spec/integration/migrator_test.rb +1 -1
- data/spec/integration/model_test.rb +2 -2
- data/spec/integration/plugin_test.rb +21 -21
- data/spec/integration/prepared_statement_test.rb +7 -7
- data/spec/integration/schema_test.rb +115 -110
- data/spec/integration/spec_helper.rb +17 -27
- data/spec/integration/timezone_test.rb +1 -1
- data/spec/integration/transaction_test.rb +10 -10
- data/spec/integration/type_test.rb +2 -2
- data/spec/model/association_reflection_spec.rb +2 -28
- data/spec/model/associations_spec.rb +239 -188
- data/spec/model/base_spec.rb +27 -68
- data/spec/model/dataset_methods_spec.rb +4 -4
- data/spec/model/eager_loading_spec.rb +160 -172
- data/spec/model/hooks_spec.rb +62 -79
- data/spec/model/model_spec.rb +36 -51
- data/spec/model/plugins_spec.rb +5 -19
- data/spec/model/record_spec.rb +125 -151
- data/spec/model/spec_helper.rb +8 -6
- data/spec/model/validations_spec.rb +4 -17
- data/spec/spec_config.rb +2 -10
- metadata +50 -56
- data/lib/sequel/deprecated_core_extensions.rb +0 -135
- data/lib/sequel/extensions/pg_auto_parameterize.rb +0 -185
- data/lib/sequel/extensions/pg_statement_cache.rb +0 -318
- data/lib/sequel/plugins/identity_map.rb +0 -260
- data/lib/sequel_core.rb +0 -2
- data/lib/sequel_model.rb +0 -2
- data/spec/extensions/association_autoreloading_spec.rb +0 -102
- data/spec/extensions/identity_map_spec.rb +0 -337
- data/spec/extensions/pg_auto_parameterize_spec.rb +0 -70
- data/spec/extensions/pg_statement_cache_spec.rb +0 -208
- data/spec/rcov.opts +0 -8
- data/spec/spec_config.rb.example +0 -10
data/spec/core/dataset_spec.rb
CHANGED
@@ -5,19 +5,10 @@ describe "Dataset" do
|
|
5
5
|
@dataset = Sequel.mock.dataset
|
6
6
|
end
|
7
7
|
|
8
|
-
qspecify "should accept database and opts in initialize" do
|
9
|
-
db = "db"
|
10
|
-
opts = {:from => :test}
|
11
|
-
d = Sequel::Dataset.new(db, opts)
|
12
|
-
d.db.should be(db)
|
13
|
-
d.opts.should be(opts)
|
14
|
-
end
|
15
|
-
|
16
8
|
specify "should accept database in initialize" do
|
17
9
|
db = "db"
|
18
10
|
d = Sequel::Dataset.new(db)
|
19
11
|
d.db.should be(db)
|
20
|
-
d.opts.should be_a_kind_of(Hash)
|
21
12
|
d.opts.should == {}
|
22
13
|
end
|
23
14
|
|
@@ -411,20 +402,20 @@ describe "Dataset#where" do
|
|
411
402
|
specify "should not replace named placeholders that don't exist in the hash" do
|
412
403
|
@dataset.where('price < :price AND id in :ids', :price=>100).select_sql.should == "SELECT * FROM test WHERE (price < 100 AND id in :ids)"
|
413
404
|
end
|
414
|
-
|
415
|
-
qspecify "should handle a mismatched number of placeholders" do
|
416
|
-
@dataset.where('price < ? AND id in ?', 100).select_sql.should == "SELECT * FROM test WHERE (price < 100 AND id in NULL)"
|
417
|
-
@dataset.where('price < ? AND id in ?', 100, [1, 2, 3], 4).select_sql.should == "SELECT * FROM test WHERE (price < 100 AND id in (1, 2, 3))"
|
418
|
-
end
|
419
405
|
|
406
|
+
specify "should raise an error for a mismatched number of placeholders" do
|
407
|
+
proc{@dataset.where('price < ? AND id in ?', 100).select_sql}.should raise_error(Sequel::Error)
|
408
|
+
proc{@dataset.where('price < ? AND id in ?', 100, [1, 2, 3], 4).select_sql}.should raise_error(Sequel::Error)
|
409
|
+
end
|
410
|
+
|
420
411
|
specify "should handle placeholders when using an array" do
|
421
412
|
@dataset.where(Sequel.lit(['price < ', ' AND id in '], 100, [1, 2, 3])).select_sql.should == "SELECT * FROM test WHERE price < 100 AND id in (1, 2, 3)"
|
422
413
|
@dataset.where(Sequel.lit(['price < ', ' AND id in '], 100)).select_sql.should == "SELECT * FROM test WHERE price < 100 AND id in "
|
423
414
|
end
|
424
|
-
|
425
|
-
|
426
|
-
@dataset.where(Sequel.lit(['a = ', ' AND price < ', ' AND id in '], 100)).select_sql.should
|
427
|
-
@dataset.where(Sequel.lit(['price < ', ' AND id in '], 100, [1, 2, 3], 4)).select_sql.should
|
415
|
+
|
416
|
+
specify "should handle a mismatched number of placeholders when using an array" do
|
417
|
+
proc{@dataset.where(Sequel.lit(['a = ', ' AND price < ', ' AND id in '], 100)).select_sql}.should raise_error(Sequel::Error)
|
418
|
+
proc{@dataset.where(Sequel.lit(['price < ', ' AND id in '], 100, [1, 2, 3], 4)).select_sql}.should raise_error(Sequel::Error)
|
428
419
|
end
|
429
420
|
|
430
421
|
specify "should handle partial names" do
|
@@ -485,18 +476,6 @@ describe "Dataset#where" do
|
|
485
476
|
@dataset.exclude([:id1, :id2] => []).sql.should == "SELECT * FROM test WHERE ((id1 = id1) AND (id2 = id2))"
|
486
477
|
end
|
487
478
|
|
488
|
-
qspecify "should handle all types of IN/NOT IN queries with empty arrays when empty_array_handle_nulls is false" do
|
489
|
-
begin
|
490
|
-
Sequel.empty_array_handle_nulls = false
|
491
|
-
@dataset.filter(:id => []).sql.should == "SELECT * FROM test WHERE (1 = 0)"
|
492
|
-
@dataset.filter([:id1, :id2] => []).sql.should == "SELECT * FROM test WHERE (1 = 0)"
|
493
|
-
@dataset.exclude(:id => []).sql.should == "SELECT * FROM test WHERE (1 = 1)"
|
494
|
-
@dataset.exclude([:id1, :id2] => []).sql.should == "SELECT * FROM test WHERE (1 = 1)"
|
495
|
-
ensure
|
496
|
-
Sequel.empty_array_handle_nulls = true
|
497
|
-
end
|
498
|
-
end
|
499
|
-
|
500
479
|
specify "should handle all types of IN/NOT IN queries" do
|
501
480
|
@dataset.filter(:id => @d1.select(:id)).sql.should == "SELECT * FROM test WHERE (id IN (SELECT id FROM test WHERE (region = 'Asia')))"
|
502
481
|
@dataset.filter(:id => [1, 2]).sql.should == "SELECT * FROM test WHERE (id IN (1, 2))"
|
@@ -539,21 +518,6 @@ describe "Dataset#where" do
|
|
539
518
|
db.sqls.should == ["SELECT id1, id2 FROM test WHERE (region = 'Asia')"]
|
540
519
|
end
|
541
520
|
|
542
|
-
qspecify "should handle IN/NOT IN queries with multiple columns and an empty dataset where the database doesn't support it when empty_array_handle nulls is true" do
|
543
|
-
begin
|
544
|
-
Sequel.empty_array_handle_nulls = false
|
545
|
-
meta_def(@dataset, :supports_multiple_column_in?){false}
|
546
|
-
db = Sequel.mock
|
547
|
-
d1 = db[:test].select(:id1, :id2).filter(:region=>'Asia').columns(:id1, :id2)
|
548
|
-
@dataset.filter([:id1, :id2] => d1).sql.should == "SELECT * FROM test WHERE (1 = 0)"
|
549
|
-
db.sqls.should == ["SELECT id1, id2 FROM test WHERE (region = 'Asia')"]
|
550
|
-
@dataset.exclude([:id1, :id2] => d1).sql.should == "SELECT * FROM test WHERE (1 = 1)"
|
551
|
-
db.sqls.should == ["SELECT id1, id2 FROM test WHERE (region = 'Asia')"]
|
552
|
-
ensure
|
553
|
-
Sequel.empty_array_handle_nulls = true
|
554
|
-
end
|
555
|
-
end
|
556
|
-
|
557
521
|
specify "should handle IN/NOT IN queries for datasets with row_procs" do
|
558
522
|
meta_def(@dataset, :supports_multiple_column_in?){false}
|
559
523
|
db = Sequel.mock(:fetch=>[{:id1=>1, :id2=>2}, {:id1=>3, :id2=>4}])
|
@@ -640,8 +604,8 @@ describe "Dataset#or" do
|
|
640
604
|
@d1 = @dataset.where(:x => 1)
|
641
605
|
end
|
642
606
|
|
643
|
-
|
644
|
-
|
607
|
+
specify "should just clone if no where clause exists" do
|
608
|
+
@dataset.or(:a => 1).sql.should == 'SELECT * FROM test'
|
645
609
|
end
|
646
610
|
|
647
611
|
specify "should just clone if given an empty argument" do
|
@@ -671,10 +635,6 @@ describe "Dataset#or" do
|
|
671
635
|
specify "should allow the use of blocks and arguments simultaneously" do
|
672
636
|
@d1.or(Sequel.expr(:zz) < 3){yy > 3}.sql.should == 'SELECT * FROM test WHERE ((x = 1) OR ((zz < 3) AND (yy > 3)))'
|
673
637
|
end
|
674
|
-
|
675
|
-
qspecify "should modify the having clause if there is already a having clause" do
|
676
|
-
@dataset.having(:x => 1).or(:y => 2).sql.should == 'SELECT * FROM test HAVING ((x = 1) OR (y = 2))'
|
677
|
-
end
|
678
638
|
end
|
679
639
|
|
680
640
|
describe "Dataset#and" do
|
@@ -683,13 +643,11 @@ describe "Dataset#and" do
|
|
683
643
|
@d1 = @dataset.where(:x => 1)
|
684
644
|
end
|
685
645
|
|
686
|
-
|
687
|
-
|
688
|
-
proc {@dataset.where(:a => 1).group(:t).and(:b => 2)}.should_not raise_error(Sequel::Error)
|
689
|
-
@dataset.where(:a => 1).group(:t).and(:b => 2).sql.should == "SELECT * FROM test WHERE ((a = 1) AND (b = 2)) GROUP BY t"
|
646
|
+
specify "should add a WHERE filter if none exists" do
|
647
|
+
@dataset.and(:a => 1).sql.should == 'SELECT * FROM test WHERE (a = 1)'
|
690
648
|
end
|
691
649
|
|
692
|
-
specify "should add an
|
650
|
+
specify "should add an expression to the where clause" do
|
693
651
|
@d1.and(:y => 2).sql.should == 'SELECT * FROM test WHERE ((x = 1) AND (y = 2))'
|
694
652
|
end
|
695
653
|
|
@@ -717,10 +675,6 @@ describe "Dataset#exclude" do
|
|
717
675
|
@dataset.exclude(:region=>'Asia').select_sql.should == "SELECT * FROM test WHERE (region != 'Asia')"
|
718
676
|
end
|
719
677
|
|
720
|
-
qspecify "should affect the having clause if having clause is already used" do
|
721
|
-
@dataset.group_and_count(:name).having{count > 2}.exclude{count > 5}.sql.should == "SELECT name, count(*) AS count FROM test GROUP BY name HAVING ((count > 2) AND (count <= 5))"
|
722
|
-
end
|
723
|
-
|
724
678
|
specify "should take multiple conditions as a hash and express the logic correctly in SQL" do
|
725
679
|
@dataset.exclude(:region => 'Asia', :name => 'Japan').select_sql.
|
726
680
|
should match(Regexp.union(/WHERE \(\(region != 'Asia'\) OR \(name != 'Japan'\)\)/,
|
@@ -776,8 +730,8 @@ describe "Dataset#invert" do
|
|
776
730
|
@d = Sequel.mock.dataset.from(:test)
|
777
731
|
end
|
778
732
|
|
779
|
-
|
780
|
-
|
733
|
+
specify "should return a dataset that selects no rows if dataset is not filtered" do
|
734
|
+
@d.invert.sql.should == "SELECT * FROM test WHERE 'f'"
|
781
735
|
end
|
782
736
|
|
783
737
|
specify "should invert current filter if dataset is filtered" do
|
@@ -808,14 +762,6 @@ describe "Dataset#having" do
|
|
808
762
|
specify "should support proc expressions" do
|
809
763
|
@grouped.having{Sequel.function(:sum, :population) > 10}.sql.should == "SELECT region, sum(population), avg(gdp) FROM test GROUP BY region HAVING (sum(population) > 10)"
|
810
764
|
end
|
811
|
-
|
812
|
-
qspecify "should work with and on the having clause" do
|
813
|
-
@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))"
|
814
|
-
end
|
815
|
-
|
816
|
-
qspecify "should work with filter on the having clause" do
|
817
|
-
@grouped.having(Sequel.expr(:a) > 1).filter(Sequel.expr(:b) < 2).sql.should == "SELECT region, sum(population), avg(gdp) FROM test GROUP BY region HAVING ((a > 1) AND (b < 2))"
|
818
|
-
end
|
819
765
|
end
|
820
766
|
|
821
767
|
describe "a grouped dataset" do
|
@@ -1161,12 +1107,6 @@ describe "Dataset#from" do
|
|
1161
1107
|
@dataset.from(d1, d2).sql.should == "SELECT * FROM (SELECT * FROM a GROUP BY b) AS t1, (SELECT * FROM c GROUP BY d) AS t2"
|
1162
1108
|
end
|
1163
1109
|
|
1164
|
-
qspecify "should accept a hash for aliasing" do
|
1165
|
-
@dataset.from(:a => :b).sql.should == "SELECT * FROM a AS b"
|
1166
|
-
@dataset.from(:a => 'b').sql.should == "SELECT * FROM a AS b"
|
1167
|
-
@dataset.from(@dataset.from(:a).group(:b) => :c).sql.should == "SELECT * FROM (SELECT * FROM a GROUP BY b) AS c"
|
1168
|
-
end
|
1169
|
-
|
1170
1110
|
specify "should always use a subquery if given a dataset" do
|
1171
1111
|
@dataset.from(@dataset.from(:a)).select_sql.should == "SELECT * FROM (SELECT * FROM a) AS t1"
|
1172
1112
|
end
|
@@ -1191,6 +1131,14 @@ describe "Dataset#from" do
|
|
1191
1131
|
@dataset.from(Sequel.function(:a, :i)).select_sql.should == "SELECT * FROM a(i)"
|
1192
1132
|
end
|
1193
1133
|
|
1134
|
+
specify "should accept virtual row blocks" do
|
1135
|
+
@dataset.from{abc(de)}.select_sql.should == "SELECT * FROM abc(de)"
|
1136
|
+
@dataset.from{[i, abc(de)]}.select_sql.should == "SELECT * FROM i, abc(de)"
|
1137
|
+
@dataset.from(:a){i}.select_sql.should == "SELECT * FROM a, i"
|
1138
|
+
@dataset.from(:a, :b){i}.select_sql.should == "SELECT * FROM a, b, i"
|
1139
|
+
@dataset.from(:a, :b){[i, abc(de)]}.select_sql.should == "SELECT * FROM a, b, i, abc(de)"
|
1140
|
+
end
|
1141
|
+
|
1194
1142
|
specify "should accept :schema__table___alias symbol format" do
|
1195
1143
|
@dataset.from(:abc__def).select_sql.should == "SELECT * FROM abc.def"
|
1196
1144
|
@dataset.from(:a_b__c).select_sql.should == "SELECT * FROM a_b.c"
|
@@ -1249,12 +1197,8 @@ describe "Dataset#select" do
|
|
1249
1197
|
@d.select(Sequel.as([[:b, :c]], :n)).sql.should == 'SELECT (b = c) AS n FROM test'
|
1250
1198
|
end
|
1251
1199
|
|
1252
|
-
|
1253
|
-
@d.select{{:b=>:c}}.sql.should == 'SELECT b
|
1254
|
-
end
|
1255
|
-
|
1256
|
-
qspecify "should accept a hash for AS values" do
|
1257
|
-
@d.select(:name => 'n', :__ggh => 'age').sql.should =~ /SELECT ((name AS n, __ggh AS age)|(__ggh AS age, name AS n)) FROM test/
|
1200
|
+
specify "should handle hashes returned from virtual row blocks" do
|
1201
|
+
@d.select{{:b=>:c}}.sql.should == 'SELECT (b = c) FROM test'
|
1258
1202
|
end
|
1259
1203
|
|
1260
1204
|
specify "should override the previous select option" do
|
@@ -1357,10 +1301,10 @@ describe "Dataset#select_more" do
|
|
1357
1301
|
@d = Sequel.mock.dataset.from(:test)
|
1358
1302
|
end
|
1359
1303
|
|
1360
|
-
|
1361
|
-
@d.select_more(:a, :b).sql.should == 'SELECT a, b FROM test'
|
1362
|
-
@d.select_all.select_more(:a, :b).sql.should == 'SELECT a, b FROM test'
|
1363
|
-
@d.select(:blah).select_all.select_more(:a, :b).sql.should == 'SELECT a, b FROM test'
|
1304
|
+
specify "should act like #select_append for datasets with no selection" do
|
1305
|
+
@d.select_more(:a, :b).sql.should == 'SELECT *, a, b FROM test'
|
1306
|
+
@d.select_all.select_more(:a, :b).sql.should == 'SELECT *, a, b FROM test'
|
1307
|
+
@d.select(:blah).select_all.select_more(:a, :b).sql.should == 'SELECT *, a, b FROM test'
|
1364
1308
|
end
|
1365
1309
|
|
1366
1310
|
specify "should add to the currently selected columns" do
|
@@ -2139,10 +2083,6 @@ describe "Dataset#join_table" do
|
|
2139
2083
|
@d.join(:categories, :category_id=>:id).sql.should == 'SELECT * FROM "items" INNER JOIN "categories" ON ("categories"."category_id" = "items"."id")'
|
2140
2084
|
end
|
2141
2085
|
|
2142
|
-
qspecify "should support aliased tables using the deprecated argument" do
|
2143
|
-
@d.from('stats').join('players', {:id => :player_id}, 'p').sql.should == 'SELECT * FROM "stats" INNER JOIN "players" AS "p" ON ("p"."id" = "stats"."player_id")'
|
2144
|
-
end
|
2145
|
-
|
2146
2086
|
specify "should support aliased tables using the :table_alias option" do
|
2147
2087
|
@d.from('stats').join('players', {:id => :player_id}, :table_alias=>:p).sql.should == 'SELECT * FROM "stats" INNER JOIN "players" AS "p" ON ("p"."id" = "stats"."player_id")'
|
2148
2088
|
end
|
@@ -2185,6 +2125,10 @@ describe "Dataset#join_table" do
|
|
2185
2125
|
@d.from('stats').join(:players, {Sequel.function(:f, :id) => Sequel.subscript(:player_id, 0)}, :qualify=>:deep).sql.should == 'SELECT * FROM "stats" INNER JOIN "players" ON (f("players"."id") = "stats"."player_id"[0])'
|
2186
2126
|
end
|
2187
2127
|
|
2128
|
+
specify "should do only qualification if :qualify=>:symbol option is given" do
|
2129
|
+
@d.from('stats').join(:players, {Sequel.function(:f, :id) => :player_id}, :qualify=>:symbol).sql.should == 'SELECT * FROM "stats" INNER JOIN "players" ON (f("id") = "stats"."player_id")'
|
2130
|
+
end
|
2131
|
+
|
2188
2132
|
specify "should allow for arbitrary conditions in the JOIN clause" do
|
2189
2133
|
@d.join_table(:left_outer, :categories, :status => 0).sql.should == 'SELECT * FROM "items" LEFT OUTER JOIN "categories" ON ("categories"."status" = 0)'
|
2190
2134
|
@d.join_table(:left_outer, :categories, :categorizable_type => "Post").sql.should == 'SELECT * FROM "items" LEFT OUTER JOIN "categories" ON ("categories"."categorizable_type" = \'Post\')'
|
@@ -2329,62 +2273,6 @@ describe "Dataset#join_table" do
|
|
2329
2273
|
proc{@d.join(:categories, :a=>:d).delete_sql}.should raise_error(Sequel::InvalidOperation)
|
2330
2274
|
proc{@d.join(:categories, :a=>:d).truncate_sql}.should raise_error(Sequel::InvalidOperation)
|
2331
2275
|
end
|
2332
|
-
|
2333
|
-
specify "should raise an error if an invalid option is passed" do
|
2334
|
-
proc{@d.join(:c, [:id], nil)}.should raise_error(Sequel::Error)
|
2335
|
-
proc{@d.join(:c, [:id], Sequel.qualify(:d, :c))}.should raise_error(Sequel::Error)
|
2336
|
-
end
|
2337
|
-
end
|
2338
|
-
|
2339
|
-
describe "Dataset#[]=" do
|
2340
|
-
qspecify "should perform an update on the specified filter" do
|
2341
|
-
db = Sequel.mock
|
2342
|
-
ds = db[:items]
|
2343
|
-
ds[:a => 1] = {:x => 3}
|
2344
|
-
db.sqls.should == ['UPDATE items SET x = 3 WHERE (a = 1)']
|
2345
|
-
end
|
2346
|
-
end
|
2347
|
-
|
2348
|
-
describe "Dataset#set" do
|
2349
|
-
qspecify "should act as alias to #update" do
|
2350
|
-
db = Sequel.mock
|
2351
|
-
ds = db[:items]
|
2352
|
-
ds.set({:x => 3})
|
2353
|
-
db.sqls.should == ['UPDATE items SET x = 3']
|
2354
|
-
end
|
2355
|
-
end
|
2356
|
-
|
2357
|
-
describe "Dataset#insert_multiple" do
|
2358
|
-
before do
|
2359
|
-
@db = Sequel.mock(:autoid=>2)
|
2360
|
-
@ds = @db[:items]
|
2361
|
-
end
|
2362
|
-
|
2363
|
-
qspecify "should insert all items in the supplied array" do
|
2364
|
-
@ds.insert_multiple(['aa', 5, 3, {:a => 2}])
|
2365
|
-
@db.sqls.should == ["INSERT INTO items VALUES ('aa')",
|
2366
|
-
"INSERT INTO items VALUES (5)",
|
2367
|
-
"INSERT INTO items VALUES (3)",
|
2368
|
-
"INSERT INTO items (a) VALUES (2)"]
|
2369
|
-
end
|
2370
|
-
|
2371
|
-
qspecify "should pass array items through the supplied block if given" do
|
2372
|
-
@ds.insert_multiple(["inevitable", "hello", "the ticking clock"]){|i| i.gsub('l', 'r')}
|
2373
|
-
@db.sqls.should == ["INSERT INTO items VALUES ('inevitabre')",
|
2374
|
-
"INSERT INTO items VALUES ('herro')",
|
2375
|
-
"INSERT INTO items VALUES ('the ticking crock')"]
|
2376
|
-
end
|
2377
|
-
|
2378
|
-
qspecify "should return array of inserted ids" do
|
2379
|
-
@ds.insert_multiple(['aa', 5, 3, {:a => 2}]).should == [2, 3, 4, 5]
|
2380
|
-
end
|
2381
|
-
|
2382
|
-
qspecify "should work exactly like in metioned in the example" do
|
2383
|
-
@ds.insert_multiple([{:x=>1}, {:x=>2}]){|row| row[:y] = row[:x] * 2 ; row }
|
2384
|
-
sqls = @db.sqls
|
2385
|
-
["INSERT INTO items (x, y) VALUES (1, 2)", "INSERT INTO items (y, x) VALUES (2, 1)"].should include(sqls[0])
|
2386
|
-
["INSERT INTO items (x, y) VALUES (2, 4)", "INSERT INTO items (y, x) VALUES (4, 2)"].should include(sqls[1])
|
2387
|
-
end
|
2388
2276
|
end
|
2389
2277
|
|
2390
2278
|
describe "Dataset aggregate methods" do
|
@@ -2586,12 +2474,6 @@ describe "Dataset compound operations" do
|
|
2586
2474
|
@b = Sequel.mock.dataset.from(:b).filter(:z => 2)
|
2587
2475
|
end
|
2588
2476
|
|
2589
|
-
qspecify "should support ALL with deprecated 2nd argument" do
|
2590
|
-
@b.union(@a, true).sql.should == "SELECT * FROM (SELECT * FROM b WHERE (z = 2) UNION ALL SELECT * FROM a WHERE (z = 1)) AS t1"
|
2591
|
-
@b.intersect(@a, true).sql.should == "SELECT * FROM (SELECT * FROM b WHERE (z = 2) INTERSECT ALL SELECT * FROM a WHERE (z = 1)) AS t1"
|
2592
|
-
@b.except(@a, true).sql.should == "SELECT * FROM (SELECT * FROM b WHERE (z = 2) EXCEPT ALL SELECT * FROM a WHERE (z = 1)) AS t1"
|
2593
|
-
end
|
2594
|
-
|
2595
2477
|
specify "should support UNION and UNION ALL" do
|
2596
2478
|
@a.union(@b).sql.should == "SELECT * FROM (SELECT * FROM a WHERE (z = 1) UNION SELECT * FROM b WHERE (z = 2)) AS t1"
|
2597
2479
|
@b.union(@a, :all=>true).sql.should == "SELECT * FROM (SELECT * FROM b WHERE (z = 2) UNION ALL SELECT * FROM a WHERE (z = 1)) AS t1"
|
@@ -2759,8 +2641,8 @@ describe "Dataset#get" do
|
|
2759
2641
|
end
|
2760
2642
|
|
2761
2643
|
specify "should support false and nil values" do
|
2762
|
-
@d.get(false).should == "SELECT 'f' FROM test LIMIT 1"
|
2763
|
-
@d.get(nil).should == "SELECT NULL FROM test LIMIT 1"
|
2644
|
+
@d.get(false).should == "SELECT 'f' AS v FROM test LIMIT 1"
|
2645
|
+
@d.get(nil).should == "SELECT NULL AS v FROM test LIMIT 1"
|
2764
2646
|
end
|
2765
2647
|
|
2766
2648
|
specify "should support an array of expressions to get an array of results" do
|
@@ -3125,20 +3007,6 @@ describe "Dataset" do
|
|
3125
3007
|
end
|
3126
3008
|
end
|
3127
3009
|
|
3128
|
-
describe "Dataset#to_csv" do
|
3129
|
-
before do
|
3130
|
-
@ds = Sequel.mock(:fetch=>[{:a=>1, :b=>2, :c=>3}, {:a=>4, :b=>5, :c=>6}, {:a=>7, :b=>8, :c=>9}])[:items].columns(:a, :b, :c)
|
3131
|
-
end
|
3132
|
-
|
3133
|
-
qspecify "should format a CSV representation of the records" do
|
3134
|
-
@ds.to_csv.should == "a, b, c\r\n1, 2, 3\r\n4, 5, 6\r\n7, 8, 9\r\n"
|
3135
|
-
end
|
3136
|
-
|
3137
|
-
qspecify "should exclude column titles if so specified" do
|
3138
|
-
@ds.to_csv(false).should == "1, 2, 3\r\n4, 5, 6\r\n7, 8, 9\r\n"
|
3139
|
-
end
|
3140
|
-
end
|
3141
|
-
|
3142
3010
|
describe "Dataset#update_sql" do
|
3143
3011
|
before do
|
3144
3012
|
@ds = Sequel.mock.dataset.from(:items)
|
@@ -3334,10 +3202,6 @@ describe "Dataset default #fetch_rows, #insert, #update, #delete, #with_sql_dele
|
|
3334
3202
|
@ds = @db[:items]
|
3335
3203
|
end
|
3336
3204
|
|
3337
|
-
qspecify "#fetch_rows should raise a Sequel::NotImplemented" do
|
3338
|
-
proc{@ds.fetch_rows(''){}}.should raise_error(Sequel::NotImplemented)
|
3339
|
-
end
|
3340
|
-
|
3341
3205
|
specify "#delete should execute delete SQL" do
|
3342
3206
|
@db.should_receive(:execute).once.with('DELETE FROM items', :server=>:default)
|
3343
3207
|
@ds.delete
|
@@ -3577,66 +3441,6 @@ describe "Sequel::Dataset#each_server" do
|
|
3577
3441
|
end
|
3578
3442
|
end
|
3579
3443
|
|
3580
|
-
describe "Sequel::Dataset #set_defaults" do
|
3581
|
-
before do
|
3582
|
-
@ds = Sequel.mock.dataset.from(:items)
|
3583
|
-
end
|
3584
|
-
|
3585
|
-
qspecify "should set the default values for inserts" do
|
3586
|
-
@ds = @ds.set_defaults(:x=>1)
|
3587
|
-
@ds.insert_sql.should == "INSERT INTO items (x) VALUES (1)"
|
3588
|
-
@ds.insert_sql(:x=>2).should == "INSERT INTO items (x) VALUES (2)"
|
3589
|
-
@ds.insert_sql(:y=>2).should =~ /INSERT INTO items \([xy], [xy]\) VALUES \([21], [21]\)/
|
3590
|
-
@ds.set_defaults(:y=>2).insert_sql.should =~ /INSERT INTO items \([xy], [xy]\) VALUES \([21], [21]\)/
|
3591
|
-
@ds.set_defaults(:x=>2).insert_sql.should == "INSERT INTO items (x) VALUES (2)"
|
3592
|
-
end
|
3593
|
-
|
3594
|
-
qspecify "should set the default values for updates" do
|
3595
|
-
@ds = @ds.set_defaults(:x=>1)
|
3596
|
-
@ds.update_sql.should == "UPDATE items SET x = 1"
|
3597
|
-
@ds.update_sql(:x=>2).should == "UPDATE items SET x = 2"
|
3598
|
-
@ds.update_sql(:y=>2).should =~ /UPDATE items SET (x = 1|y = 2), (x = 1|y = 2)/
|
3599
|
-
@ds.set_defaults(:y=>2).update_sql.should =~ /UPDATE items SET (x = 1|y = 2), (x = 1|y = 2)/
|
3600
|
-
@ds.set_defaults(:x=>2).update_sql.should == "UPDATE items SET x = 2"
|
3601
|
-
end
|
3602
|
-
end
|
3603
|
-
|
3604
|
-
describe "Sequel::Dataset #set_overrides" do
|
3605
|
-
before do
|
3606
|
-
@ds = Sequel.mock.dataset.from(:items)
|
3607
|
-
end
|
3608
|
-
|
3609
|
-
qspecify "should override the given values for inserts" do
|
3610
|
-
@ds = @ds.set_overrides(:x=>1)
|
3611
|
-
@ds.insert_sql.should == "INSERT INTO items (x) VALUES (1)"
|
3612
|
-
@ds.insert_sql(:x=>2).should == "INSERT INTO items (x) VALUES (1)"
|
3613
|
-
@ds.insert_sql(:y=>2).should =~ /INSERT INTO items \([xy], [xy]\) VALUES \([21], [21]\)/
|
3614
|
-
@ds.set_overrides(:y=>2).insert_sql.should =~ /INSERT INTO items \([xy], [xy]\) VALUES \([21], [21]\)/
|
3615
|
-
@ds.set_overrides(:x=>2).insert_sql.should == "INSERT INTO items (x) VALUES (1)"
|
3616
|
-
end
|
3617
|
-
|
3618
|
-
qspecify "should override the given values for updates" do
|
3619
|
-
@ds = @ds.set_overrides(:x=>1)
|
3620
|
-
@ds.update_sql.should == "UPDATE items SET x = 1"
|
3621
|
-
@ds.update_sql(:x=>2).should == "UPDATE items SET x = 1"
|
3622
|
-
@ds.update_sql(:y=>2).should =~ /UPDATE items SET (x = 1|y = 2), (x = 1|y = 2)/
|
3623
|
-
@ds.set_overrides(:y=>2).update_sql.should =~ /UPDATE items SET (x = 1|y = 2), (x = 1|y = 2)/
|
3624
|
-
@ds.set_overrides(:x=>2).update_sql.should == "UPDATE items SET x = 1"
|
3625
|
-
end
|
3626
|
-
end
|
3627
|
-
|
3628
|
-
describe "Sequel::Dataset#qualify_to_first_source" do
|
3629
|
-
qspecify "should qualify to the first source" do
|
3630
|
-
Sequel.mock.dataset.from(:t).filter{a<b}.qualify_to_first_source.sql.should == 'SELECT t.* FROM t WHERE (t.a < t.b)'
|
3631
|
-
end
|
3632
|
-
end
|
3633
|
-
|
3634
|
-
describe "Sequel::Dataset#qualify_to" do
|
3635
|
-
qspecify "should qualify to the given table" do
|
3636
|
-
Sequel.mock.dataset.from(:t).filter{a<b}.qualify_to(:e).sql.should == 'SELECT e.* FROM t WHERE (e.a < e.b)'
|
3637
|
-
end
|
3638
|
-
end
|
3639
|
-
|
3640
3444
|
describe "Sequel::Dataset#qualify" do
|
3641
3445
|
before do
|
3642
3446
|
@ds = Sequel::Database.new[:t]
|
@@ -3654,8 +3458,8 @@ describe "Sequel::Dataset#qualify" do
|
|
3654
3458
|
@ds.filter(:a=>1).order(:a).group(:a).having(:a).qualify.sql.should == 'SELECT t.* FROM t WHERE (t.a = 1) GROUP BY t.a HAVING t.a ORDER BY t.a'
|
3655
3459
|
end
|
3656
3460
|
|
3657
|
-
|
3658
|
-
@ds.select(:a=>:b).qualify.sql.should == 'SELECT t.a
|
3461
|
+
specify "should handle hashes in select option" do
|
3462
|
+
@ds.select(:a=>:b).qualify.sql.should == 'SELECT (t.a = t.b) FROM t'
|
3659
3463
|
end
|
3660
3464
|
|
3661
3465
|
specify "should handle symbols" do
|
@@ -3748,6 +3552,11 @@ describe "Sequel::Dataset#unbind" do
|
|
3748
3552
|
@ds.exclude(:foo=>1).unbind.last.should == {:foo=>1}
|
3749
3553
|
end
|
3750
3554
|
|
3555
|
+
specify "should return variables as symbols" do
|
3556
|
+
@ds.filter(Sequel.expr(:foo)=>1).unbind.last.should == {:foo=>1}
|
3557
|
+
@ds.exclude(Sequel.expr(:foo__bar)=>1).unbind.last.should == {:"foo.bar"=>1}
|
3558
|
+
end
|
3559
|
+
|
3751
3560
|
specify "should handle numerics, strings, dates, times, and datetimes" do
|
3752
3561
|
@u[@ds.filter(:foo=>1)].should == ["SELECT * FROM t WHERE (foo = $foo)", {:foo=>1}]
|
3753
3562
|
@u[@ds.filter(:foo=>1.0)].should == ["SELECT * FROM t WHERE (foo = $foo)", {:foo=>1.0}]
|
@@ -4117,7 +3926,7 @@ describe "Sequel::Dataset#select_map" do
|
|
4117
3926
|
|
4118
3927
|
specify "should handle an expression without a determinable alias" do
|
4119
3928
|
@ds.select_map{a(t__c)}.should == [1, 2]
|
4120
|
-
@ds.db.sqls.should == ['SELECT a(t.c) FROM t']
|
3929
|
+
@ds.db.sqls.should == ['SELECT a(t.c) AS v FROM t']
|
4121
3930
|
end
|
4122
3931
|
|
4123
3932
|
specify "should accept a block" do
|
@@ -4196,7 +4005,7 @@ describe "Sequel::Dataset#select_order_map" do
|
|
4196
4005
|
|
4197
4006
|
specify "should handle an expression without a determinable alias" do
|
4198
4007
|
@ds.select_order_map{a(t__c)}.should == [1, 2]
|
4199
|
-
@ds.db.sqls.should == ['SELECT a(t.c) FROM t ORDER BY a(t.c)']
|
4008
|
+
@ds.db.sqls.should == ['SELECT a(t.c) AS v FROM t ORDER BY a(t.c)']
|
4200
4009
|
end
|
4201
4010
|
|
4202
4011
|
specify "should accept a block" do
|
@@ -4575,12 +4384,6 @@ describe "Dataset#schema_and_table" do
|
|
4575
4384
|
it "should correctly handle qualified identifiers" do
|
4576
4385
|
@ds.schema_and_table(Sequel.qualify(:t, :s)).should == ['t', 's']
|
4577
4386
|
end
|
4578
|
-
|
4579
|
-
qspecify "should respect default_schema" do
|
4580
|
-
@ds.db.default_schema = :foo
|
4581
|
-
@ds.schema_and_table(:s).should == ['foo', 's']
|
4582
|
-
@ds.schema_and_table(:s, nil).should == [nil, 's']
|
4583
|
-
end
|
4584
4387
|
end
|
4585
4388
|
|
4586
4389
|
describe "Dataset#split_qualifiers" do
|
@@ -4615,13 +4418,6 @@ describe "Dataset#split_qualifiers" do
|
|
4615
4418
|
@ds.split_qualifiers(Sequel.qualify(:d__t, :s__s2)).should == ['d', 't', 's', 's2']
|
4616
4419
|
@ds.split_qualifiers(Sequel.qualify(Sequel.qualify(:d, :t), Sequel.qualify(:s, :s2))).should == ['d', 't', 's', 's2']
|
4617
4420
|
end
|
4618
|
-
|
4619
|
-
qspecify "should respect default_schema" do
|
4620
|
-
@ds.db.default_schema = :foo
|
4621
|
-
@ds.split_qualifiers(:s).should == ['foo', 's']
|
4622
|
-
@ds.split_qualifiers(:s, nil).should == ['s']
|
4623
|
-
@ds.split_qualifiers(Sequel.qualify(:d__t, :s)).should == ['d', 't', 's']
|
4624
|
-
end
|
4625
4421
|
end
|
4626
4422
|
|
4627
4423
|
describe "Dataset#paged_each" do
|