sequel 4.41.0 → 4.42.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG +98 -0
- data/README.rdoc +23 -10
- data/doc/active_record.rdoc +4 -4
- data/doc/advanced_associations.rdoc +2 -2
- data/doc/association_basics.rdoc +5 -2
- data/doc/cheat_sheet.rdoc +3 -3
- data/doc/core_extensions.rdoc +2 -2
- data/doc/dataset_basics.rdoc +4 -4
- data/doc/dataset_filtering.rdoc +1 -1
- data/doc/migration.rdoc +19 -1
- data/doc/prepared_statements.rdoc +2 -2
- data/doc/release_notes/4.42.0.txt +221 -0
- data/doc/testing.rdoc +3 -1
- data/lib/sequel/adapters/ado/access.rb +0 -1
- data/lib/sequel/adapters/ado/mssql.rb +0 -1
- data/lib/sequel/adapters/do/mysql.rb +0 -1
- data/lib/sequel/adapters/do/postgres.rb +0 -1
- data/lib/sequel/adapters/do/sqlite3.rb +0 -1
- data/lib/sequel/adapters/ibmdb.rb +21 -25
- data/lib/sequel/adapters/jdbc.rb +8 -16
- data/lib/sequel/adapters/jdbc/as400.rb +0 -1
- data/lib/sequel/adapters/jdbc/cubrid.rb +0 -1
- data/lib/sequel/adapters/jdbc/db2.rb +0 -1
- data/lib/sequel/adapters/jdbc/derby.rb +0 -1
- data/lib/sequel/adapters/jdbc/firebirdsql.rb +0 -1
- data/lib/sequel/adapters/jdbc/h2.rb +0 -1
- data/lib/sequel/adapters/jdbc/hsqldb.rb +0 -1
- data/lib/sequel/adapters/jdbc/informix-sqli.rb +0 -1
- data/lib/sequel/adapters/jdbc/jdbcprogress.rb +0 -1
- data/lib/sequel/adapters/jdbc/jtds.rb +0 -1
- data/lib/sequel/adapters/jdbc/mssql.rb +0 -1
- data/lib/sequel/adapters/jdbc/mysql.rb +0 -1
- data/lib/sequel/adapters/jdbc/oracle.rb +0 -1
- data/lib/sequel/adapters/jdbc/postgresql.rb +0 -13
- data/lib/sequel/adapters/jdbc/sqlanywhere.rb +0 -1
- data/lib/sequel/adapters/jdbc/sqlite.rb +0 -1
- data/lib/sequel/adapters/jdbc/sqlserver.rb +3 -4
- data/lib/sequel/adapters/mock.rb +54 -12
- data/lib/sequel/adapters/mysql.rb +1 -1
- data/lib/sequel/adapters/mysql2.rb +11 -17
- data/lib/sequel/adapters/odbc/mssql.rb +0 -1
- data/lib/sequel/adapters/oracle.rb +8 -20
- data/lib/sequel/adapters/postgres.rb +11 -29
- data/lib/sequel/adapters/shared/access.rb +5 -12
- data/lib/sequel/adapters/shared/cubrid.rb +4 -13
- data/lib/sequel/adapters/shared/db2.rb +4 -2
- data/lib/sequel/adapters/shared/firebird.rb +2 -4
- data/lib/sequel/adapters/shared/informix.rb +4 -2
- data/lib/sequel/adapters/shared/mssql.rb +3 -5
- data/lib/sequel/adapters/shared/mysql.rb +4 -14
- data/lib/sequel/adapters/shared/oracle.rb +1 -3
- data/lib/sequel/adapters/shared/postgres.rb +16 -38
- data/lib/sequel/adapters/shared/progress.rb +0 -2
- data/lib/sequel/adapters/shared/sqlanywhere.rb +0 -2
- data/lib/sequel/adapters/shared/sqlite.rb +20 -16
- data/lib/sequel/adapters/sqlite.rb +8 -20
- data/lib/sequel/adapters/swift/mysql.rb +0 -1
- data/lib/sequel/adapters/swift/postgres.rb +0 -1
- data/lib/sequel/adapters/swift/sqlite.rb +0 -1
- data/lib/sequel/adapters/tinytds.rb +4 -12
- data/lib/sequel/adapters/utils/emulate_offset_with_reverse_and_count.rb +1 -1
- data/lib/sequel/adapters/utils/mysql_mysql2.rb +2 -2
- data/lib/sequel/adapters/utils/mysql_prepared_statements.rb +11 -34
- data/lib/sequel/adapters/utils/stored_procedures.rb +9 -22
- data/lib/sequel/adapters/utils/unmodified_identifiers.rb +26 -0
- data/lib/sequel/ast_transformer.rb +2 -2
- data/lib/sequel/database/dataset.rb +1 -1
- data/lib/sequel/database/dataset_defaults.rb +0 -66
- data/lib/sequel/database/features.rb +6 -0
- data/lib/sequel/database/misc.rb +31 -17
- data/lib/sequel/database/query.rb +7 -4
- data/lib/sequel/database/schema_methods.rb +1 -1
- data/lib/sequel/dataset.rb +8 -8
- data/lib/sequel/dataset/actions.rb +140 -46
- data/lib/sequel/dataset/features.rb +1 -5
- data/lib/sequel/dataset/graph.rb +7 -8
- data/lib/sequel/dataset/misc.rb +127 -56
- data/lib/sequel/dataset/mutation.rb +9 -20
- data/lib/sequel/dataset/placeholder_literalizer.rb +10 -1
- data/lib/sequel/dataset/prepared_statements.rb +102 -46
- data/lib/sequel/dataset/query.rb +155 -72
- data/lib/sequel/dataset/sql.rb +26 -9
- data/lib/sequel/extensions/columns_introspection.rb +3 -1
- data/lib/sequel/extensions/core_extensions.rb +5 -5
- data/lib/sequel/extensions/core_refinements.rb +5 -5
- data/lib/sequel/extensions/duplicate_columns_handler.rb +4 -2
- data/lib/sequel/extensions/freeze_datasets.rb +69 -0
- data/lib/sequel/extensions/identifier_mangling.rb +196 -0
- data/lib/sequel/extensions/looser_typecasting.rb +11 -7
- data/lib/sequel/extensions/migration.rb +1 -1
- data/lib/sequel/extensions/null_dataset.rb +5 -2
- data/lib/sequel/extensions/pagination.rb +42 -23
- data/lib/sequel/extensions/pg_enum.rb +3 -3
- data/lib/sequel/extensions/query.rb +3 -3
- data/lib/sequel/extensions/sequel_3_dataset_methods.rb +15 -8
- data/lib/sequel/model/associations.rb +25 -8
- data/lib/sequel/model/base.rb +88 -29
- data/lib/sequel/model/dataset_module.rb +37 -0
- data/lib/sequel/plugins/association_pks.rb +4 -4
- data/lib/sequel/plugins/class_table_inheritance.rb +2 -2
- data/lib/sequel/plugins/constraint_validations.rb +1 -2
- data/lib/sequel/plugins/csv_serializer.rb +2 -2
- data/lib/sequel/plugins/dataset_associations.rb +8 -8
- data/lib/sequel/plugins/eager_each.rb +2 -2
- data/lib/sequel/plugins/instance_filters.rb +1 -1
- data/lib/sequel/plugins/json_serializer.rb +2 -2
- data/lib/sequel/plugins/lazy_attributes.rb +1 -1
- data/lib/sequel/plugins/list.rb +4 -4
- data/lib/sequel/plugins/prepared_statements.rb +2 -4
- data/lib/sequel/plugins/prepared_statements_associations.rb +1 -3
- data/lib/sequel/plugins/prepared_statements_with_pk.rb +1 -1
- data/lib/sequel/plugins/rcte_tree.rb +13 -13
- data/lib/sequel/plugins/sharding.rb +1 -1
- data/lib/sequel/plugins/single_table_inheritance.rb +9 -4
- data/lib/sequel/plugins/tactical_eager_loading.rb +4 -4
- data/lib/sequel/plugins/validation_class_methods.rb +1 -1
- data/lib/sequel/plugins/validation_helpers.rb +1 -1
- data/lib/sequel/plugins/xml_serializer.rb +2 -2
- data/lib/sequel/sql.rb +69 -36
- data/lib/sequel/version.rb +1 -1
- data/spec/adapters/db2_spec.rb +10 -0
- data/spec/adapters/firebird_spec.rb +1 -1
- data/spec/adapters/mssql_spec.rb +4 -5
- data/spec/adapters/mysql_spec.rb +9 -9
- data/spec/adapters/postgres_spec.rb +67 -68
- data/spec/adapters/spec_helper.rb +6 -1
- data/spec/adapters/sqlite_spec.rb +29 -15
- data/spec/core/connection_pool_spec.rb +14 -14
- data/spec/core/database_spec.rb +38 -180
- data/spec/core/dataset_mutation_spec.rb +253 -0
- data/spec/core/dataset_spec.rb +394 -537
- data/spec/core/expression_filters_spec.rb +34 -32
- data/spec/core/mock_adapter_spec.rb +27 -35
- data/spec/core/placeholder_literalizer_spec.rb +2 -4
- data/spec/core/schema_generator_spec.rb +4 -4
- data/spec/core/schema_spec.rb +1 -2
- data/spec/core_extensions_spec.rb +22 -29
- data/spec/extensions/active_model_spec.rb +6 -6
- data/spec/extensions/association_dependencies_spec.rb +2 -2
- data/spec/extensions/blacklist_security_spec.rb +3 -3
- data/spec/extensions/boolean_readers_spec.rb +12 -12
- data/spec/extensions/caching_spec.rb +13 -10
- data/spec/extensions/class_table_inheritance_spec.rb +38 -43
- data/spec/extensions/column_conflicts_spec.rb +1 -3
- data/spec/extensions/columns_introspection_spec.rb +2 -3
- data/spec/extensions/composition_spec.rb +5 -3
- data/spec/extensions/constraint_validations_plugin_spec.rb +5 -5
- data/spec/extensions/constraint_validations_spec.rb +14 -8
- data/spec/extensions/core_refinements_spec.rb +22 -29
- data/spec/extensions/csv_serializer_spec.rb +7 -6
- data/spec/extensions/date_arithmetic_spec.rb +15 -15
- data/spec/extensions/defaults_setter_spec.rb +2 -2
- data/spec/extensions/delay_add_association_spec.rb +1 -1
- data/spec/extensions/dirty_spec.rb +19 -10
- data/spec/extensions/duplicate_columns_handler_spec.rb +12 -18
- data/spec/extensions/eager_each_spec.rb +12 -16
- data/spec/extensions/empty_array_consider_nulls_spec.rb +1 -1
- data/spec/extensions/eval_inspect_spec.rb +4 -3
- data/spec/extensions/force_encoding_spec.rb +12 -12
- data/spec/extensions/freeze_datasets_spec.rb +31 -0
- data/spec/extensions/graph_each_spec.rb +6 -18
- data/spec/extensions/hook_class_methods_spec.rb +7 -7
- data/spec/extensions/identifier_mangling_spec.rb +307 -0
- data/spec/extensions/instance_filters_spec.rb +5 -6
- data/spec/extensions/instance_hooks_spec.rb +12 -12
- data/spec/extensions/json_serializer_spec.rb +12 -15
- data/spec/extensions/lazy_attributes_spec.rb +4 -4
- data/spec/extensions/list_spec.rb +19 -21
- data/spec/extensions/many_through_many_spec.rb +108 -163
- data/spec/extensions/meta_def_spec.rb +7 -2
- data/spec/extensions/migration_spec.rb +10 -12
- data/spec/extensions/mssql_optimistic_locking_spec.rb +4 -3
- data/spec/extensions/named_timezones_spec.rb +4 -3
- data/spec/extensions/nested_attributes_spec.rb +2 -2
- data/spec/extensions/null_dataset_spec.rb +17 -12
- data/spec/extensions/optimistic_locking_spec.rb +4 -5
- data/spec/extensions/pagination_spec.rb +8 -10
- data/spec/extensions/pg_array_associations_spec.rb +28 -27
- data/spec/extensions/pg_array_ops_spec.rb +2 -1
- data/spec/extensions/pg_array_spec.rb +6 -2
- data/spec/extensions/pg_enum_spec.rb +5 -3
- data/spec/extensions/pg_hstore_ops_spec.rb +3 -1
- data/spec/extensions/pg_hstore_spec.rb +7 -6
- data/spec/extensions/pg_inet_ops_spec.rb +2 -1
- data/spec/extensions/pg_inet_spec.rb +2 -1
- data/spec/extensions/pg_interval_spec.rb +2 -1
- data/spec/extensions/pg_json_ops_spec.rb +2 -1
- data/spec/extensions/pg_json_spec.rb +6 -3
- data/spec/extensions/pg_loose_count_spec.rb +1 -0
- data/spec/extensions/pg_range_ops_spec.rb +3 -1
- data/spec/extensions/pg_range_spec.rb +9 -5
- data/spec/extensions/pg_row_ops_spec.rb +2 -1
- data/spec/extensions/pg_row_plugin_spec.rb +4 -6
- data/spec/extensions/pg_row_spec.rb +5 -3
- data/spec/extensions/pg_static_cache_updater_spec.rb +2 -1
- data/spec/extensions/pg_typecast_on_load_spec.rb +1 -1
- data/spec/extensions/prepared_statements_associations_spec.rb +1 -1
- data/spec/extensions/prepared_statements_spec.rb +12 -11
- data/spec/extensions/pretty_table_spec.rb +1 -1
- data/spec/extensions/query_spec.rb +8 -5
- data/spec/extensions/rcte_tree_spec.rb +39 -39
- data/spec/extensions/round_timestamps_spec.rb +2 -2
- data/spec/extensions/schema_dumper_spec.rb +3 -2
- data/spec/extensions/schema_spec.rb +2 -2
- data/spec/extensions/scissors_spec.rb +1 -2
- data/spec/extensions/sequel_3_dataset_methods_spec.rb +30 -17
- data/spec/extensions/serialization_modification_detection_spec.rb +2 -2
- data/spec/extensions/serialization_spec.rb +15 -13
- data/spec/extensions/set_overrides_spec.rb +14 -8
- data/spec/extensions/sharding_spec.rb +9 -18
- data/spec/extensions/shared_caching_spec.rb +3 -4
- data/spec/extensions/single_table_inheritance_spec.rb +11 -11
- data/spec/extensions/skip_create_refresh_spec.rb +2 -1
- data/spec/extensions/spec_helper.rb +1 -1
- data/spec/extensions/split_values_spec.rb +2 -2
- data/spec/extensions/sql_comments_spec.rb +6 -0
- data/spec/extensions/static_cache_spec.rb +7 -9
- data/spec/extensions/string_agg_spec.rb +30 -29
- data/spec/extensions/tactical_eager_loading_spec.rb +4 -5
- data/spec/extensions/thread_local_timezones_spec.rb +2 -2
- data/spec/extensions/timestamps_spec.rb +28 -3
- data/spec/extensions/to_dot_spec.rb +1 -2
- data/spec/extensions/tree_spec.rb +33 -29
- data/spec/extensions/typecast_on_load_spec.rb +1 -1
- data/spec/extensions/unlimited_update_spec.rb +1 -0
- data/spec/extensions/update_primary_key_spec.rb +11 -7
- data/spec/extensions/update_refresh_spec.rb +1 -1
- data/spec/extensions/uuid_spec.rb +0 -1
- data/spec/extensions/validate_associated_spec.rb +1 -1
- data/spec/extensions/validation_class_methods_spec.rb +10 -10
- data/spec/extensions/validation_helpers_spec.rb +10 -10
- data/spec/extensions/xml_serializer_spec.rb +7 -3
- data/spec/integration/associations_test.rb +31 -31
- data/spec/integration/dataset_test.rb +17 -19
- data/spec/integration/eager_loader_test.rb +24 -24
- data/spec/integration/model_test.rb +6 -6
- data/spec/integration/plugin_test.rb +43 -43
- data/spec/integration/prepared_statement_test.rb +6 -6
- data/spec/integration/schema_test.rb +63 -52
- data/spec/integration/spec_helper.rb +6 -1
- data/spec/integration/transaction_test.rb +13 -13
- data/spec/model/association_reflection_spec.rb +17 -17
- data/spec/model/associations_spec.rb +101 -96
- data/spec/model/base_spec.rb +175 -49
- data/spec/model/class_dataset_methods_spec.rb +5 -9
- data/spec/model/dataset_methods_spec.rb +5 -5
- data/spec/model/eager_loading_spec.rb +209 -235
- data/spec/model/hooks_spec.rb +15 -15
- data/spec/model/model_spec.rb +28 -21
- data/spec/model/plugins_spec.rb +4 -5
- data/spec/model/record_spec.rb +59 -57
- data/spec/model/spec_helper.rb +1 -1
- data/spec/model/validations_spec.rb +6 -6
- data/spec/spec_config.rb +1 -1
- metadata +10 -2
|
@@ -39,10 +39,15 @@ class Minitest::HooksSpec
|
|
|
39
39
|
end
|
|
40
40
|
end
|
|
41
41
|
|
|
42
|
+
IDENTIFIER_MANGLING = !ENV['SEQUEL_NO_MANGLE'] unless defined?(IDENTIFIER_MANGLING)
|
|
43
|
+
|
|
42
44
|
unless defined?(DB)
|
|
43
45
|
env_var = "SEQUEL_#{SEQUEL_ADAPTER_TEST.to_s.upcase}_URL"
|
|
44
46
|
env_var = ENV.has_key?(env_var) ? env_var : 'SEQUEL_INTEGRATION_URL'
|
|
45
|
-
|
|
47
|
+
opts = {}
|
|
48
|
+
opts[:identifier_mangling] = false unless IDENTIFIER_MANGLING
|
|
49
|
+
DB = Sequel.connect(ENV[env_var], opts)
|
|
50
|
+
DB.extension(:freeze_datasets) if ENV['SEQUEL_FREEZE_DATASETS']
|
|
46
51
|
end
|
|
47
52
|
|
|
48
53
|
if dch = ENV['SEQUEL_DUPLICATE_COLUMNS_HANDLER']
|
|
@@ -297,7 +297,7 @@ end if DB.adapter_scheme == :sqlite
|
|
|
297
297
|
|
|
298
298
|
describe "An SQLite dataset" do
|
|
299
299
|
before do
|
|
300
|
-
@d = DB
|
|
300
|
+
@d = DB.dataset
|
|
301
301
|
end
|
|
302
302
|
|
|
303
303
|
it "should raise errors if given a regexp pattern match" do
|
|
@@ -347,6 +347,9 @@ describe "SQLite::Dataset#delete" do
|
|
|
347
347
|
@d << {:name => 'def', :value => 4.56}
|
|
348
348
|
@d << {:name => 'ghi', :value => 7.89}
|
|
349
349
|
end
|
|
350
|
+
after do
|
|
351
|
+
DB.drop_table?(:items)
|
|
352
|
+
end
|
|
350
353
|
|
|
351
354
|
it "should return the number of records affected when filtered" do
|
|
352
355
|
@d.count.must_equal 3
|
|
@@ -458,7 +461,7 @@ describe "SQLite dataset" do
|
|
|
458
461
|
|
|
459
462
|
it "should have #explain work when identifier_output_method is modified" do
|
|
460
463
|
DB[:test].with_identifier_output_method(:upcase).explain.must_be_kind_of(String)
|
|
461
|
-
end
|
|
464
|
+
end if IDENTIFIER_MANGLING
|
|
462
465
|
end
|
|
463
466
|
|
|
464
467
|
describe "A SQLite database" do
|
|
@@ -470,7 +473,7 @@ describe "A SQLite database" do
|
|
|
470
473
|
end
|
|
471
474
|
end
|
|
472
475
|
after do
|
|
473
|
-
@db.drop_table?(:test2)
|
|
476
|
+
@db.drop_table?(:test, :test2, :test3, :test3_backup0, :test3_backup1, :test3_backup2)
|
|
474
477
|
end
|
|
475
478
|
|
|
476
479
|
it "should support add_column operations" do
|
|
@@ -543,12 +546,10 @@ describe "A SQLite database" do
|
|
|
543
546
|
@db.drop_column :test3, :value
|
|
544
547
|
|
|
545
548
|
@db[:test].filter(:name => 'bar').delete
|
|
546
|
-
@db[:test3][:name => 'def'][:test_id].
|
|
549
|
+
@db[:test3][:name => 'def'][:test_id].must_be_nil
|
|
547
550
|
|
|
548
551
|
@db[:test].filter(:name => 'foo').update(:id=>100)
|
|
549
552
|
@db[:test3][:name => 'abc'][:test_id].must_equal 100
|
|
550
|
-
|
|
551
|
-
@db.drop_table? :test, :test3
|
|
552
553
|
end
|
|
553
554
|
end
|
|
554
555
|
|
|
@@ -582,9 +583,23 @@ describe "A SQLite database" do
|
|
|
582
583
|
@db[:test3].first[:t].must_equal 'a'
|
|
583
584
|
@db[:test3].delete
|
|
584
585
|
end
|
|
586
|
+
|
|
587
|
+
|
|
588
|
+
it "should preserve autoincrement after table modification" do
|
|
589
|
+
@db.create_table!(:test2) do
|
|
590
|
+
primary_key :id
|
|
591
|
+
Integer :val, :null => false
|
|
592
|
+
end
|
|
593
|
+
@db.rename_column(:test2, :val, :value)
|
|
594
|
+
|
|
595
|
+
t = @db[:test2]
|
|
596
|
+
id1 = t.insert(:value=>1)
|
|
597
|
+
t.delete
|
|
598
|
+
id2 = t.insert(:value=>1)
|
|
599
|
+
id2.must_be :>, id1
|
|
600
|
+
end
|
|
585
601
|
|
|
586
602
|
it "should handle quoted tables when dropping or renaming columns" do
|
|
587
|
-
@db.quote_identifiers = true
|
|
588
603
|
table_name = "T T"
|
|
589
604
|
@db.drop_table?(table_name)
|
|
590
605
|
@db.create_table! table_name do
|
|
@@ -640,7 +655,6 @@ describe "A SQLite database" do
|
|
|
640
655
|
@db[:test3_backup1].columns.must_equal [:k]
|
|
641
656
|
@db[:test3_backup2].columns.must_equal [:l]
|
|
642
657
|
@db.loggers.delete(l)
|
|
643
|
-
@db.drop_table?(:test3, :test3_backup0, :test3_backup1, :test3_backup2)
|
|
644
658
|
end
|
|
645
659
|
|
|
646
660
|
it "should support add_index" do
|
|
@@ -654,12 +668,12 @@ describe "A SQLite database" do
|
|
|
654
668
|
end
|
|
655
669
|
|
|
656
670
|
it "should keep applicable indexes when emulating schema methods" do
|
|
657
|
-
@db.create_table!(:
|
|
658
|
-
@db.add_index :
|
|
659
|
-
@db.add_index :
|
|
660
|
-
@db.add_index :
|
|
661
|
-
@db.drop_column :
|
|
662
|
-
@db.indexes(:
|
|
671
|
+
@db.create_table!(:test3){Integer :a; Integer :b}
|
|
672
|
+
@db.add_index :test3, :a
|
|
673
|
+
@db.add_index :test3, :b
|
|
674
|
+
@db.add_index :test3, [:b, :a]
|
|
675
|
+
@db.drop_column :test3, :b
|
|
676
|
+
@db.indexes(:test3).must_equal(:test3_a_index=>{:unique=>false, :columns=>[:a]})
|
|
663
677
|
end
|
|
664
678
|
|
|
665
679
|
it "should have support for various #transaction modes" do
|
|
@@ -679,7 +693,7 @@ describe "A SQLite database" do
|
|
|
679
693
|
sqls.last.must_equal Sequel::Database::SQL_BEGIN
|
|
680
694
|
end
|
|
681
695
|
|
|
682
|
-
@db.transaction_mode.
|
|
696
|
+
@db.transaction_mode.must_be_nil
|
|
683
697
|
@db.transaction_mode = :immediate
|
|
684
698
|
@db.transaction_mode.must_equal :immediate
|
|
685
699
|
@db.transaction do
|
|
@@ -192,7 +192,7 @@ describe "A connection pool with a max size of 1" do
|
|
|
192
192
|
|
|
193
193
|
cc.must_equal 'herro'
|
|
194
194
|
c1.must_equal 'herro'
|
|
195
|
-
c2.
|
|
195
|
+
c2.must_be_nil
|
|
196
196
|
|
|
197
197
|
@pool.available_connections.must_be :empty?
|
|
198
198
|
@pool.allocated.must_equal(t1=>cc)
|
|
@@ -357,9 +357,9 @@ ThreadedConnectionPoolSpecs = shared_description do
|
|
|
357
357
|
threads[6].must_be :alive?
|
|
358
358
|
threads[7].must_be :alive?
|
|
359
359
|
cc.size.must_equal 5
|
|
360
|
-
cc[5].
|
|
361
|
-
cc[6].
|
|
362
|
-
cc[7].
|
|
360
|
+
cc[5].must_be_nil
|
|
361
|
+
cc[6].must_be_nil
|
|
362
|
+
cc[7].must_be_nil
|
|
363
363
|
|
|
364
364
|
5.times{q.push nil}
|
|
365
365
|
5.times{|i| threads[i].join}
|
|
@@ -614,12 +614,12 @@ describe "A connection pool with multiple servers" do
|
|
|
614
614
|
pool.hold(:server1) do
|
|
615
615
|
pool.allocated.length.must_equal 0
|
|
616
616
|
pool.allocated(:server1).length.must_equal 1
|
|
617
|
-
pool.allocated(:server2).
|
|
618
|
-
pool.allocated(:server3).
|
|
617
|
+
pool.allocated(:server2).must_be_nil
|
|
618
|
+
pool.allocated(:server3).must_be_nil
|
|
619
619
|
pool.available_connections.length.must_equal 1
|
|
620
620
|
pool.available_connections(:server1).length.must_equal 0
|
|
621
|
-
pool.available_connections(:server2).
|
|
622
|
-
pool.available_connections(:server3).
|
|
621
|
+
pool.available_connections(:server2).must_be_nil
|
|
622
|
+
pool.available_connections(:server3).must_be_nil
|
|
623
623
|
|
|
624
624
|
pool.add_servers([:server2, :server3])
|
|
625
625
|
pool.hold(:server2){}
|
|
@@ -717,8 +717,8 @@ describe "A connection pool with multiple servers" do
|
|
|
717
717
|
pool.available_connections(:server1).must_equal []
|
|
718
718
|
pool.allocated(:server1).must_equal({})
|
|
719
719
|
pool.remove_servers([:server1])
|
|
720
|
-
pool.available_connections(:server1).
|
|
721
|
-
pool.allocated(:server1).
|
|
720
|
+
pool.available_connections(:server1).must_be_nil
|
|
721
|
+
pool.allocated(:server1).must_be_nil
|
|
722
722
|
end
|
|
723
723
|
|
|
724
724
|
it "#remove_servers should not allow the removal of the default server" do
|
|
@@ -832,7 +832,7 @@ describe "A single threaded pool with multiple servers" do
|
|
|
832
832
|
@pool.hold(:read_only){|c| c.must_equal :read_only}
|
|
833
833
|
@pool.conn(:read_only).must_equal :read_only
|
|
834
834
|
@pool.remove_servers([:read_only])
|
|
835
|
-
@pool.conn(:read_only).
|
|
835
|
+
@pool.conn(:read_only).must_be_nil
|
|
836
836
|
@pool.hold{}
|
|
837
837
|
@pool.conn(:read_only).must_equal :default
|
|
838
838
|
end
|
|
@@ -885,8 +885,8 @@ describe "A single threaded pool with multiple servers" do
|
|
|
885
885
|
@pool.conn(:read_only).must_equal :read_only
|
|
886
886
|
@pool.disconnect
|
|
887
887
|
@max_size.must_equal 4
|
|
888
|
-
@pool.conn.
|
|
889
|
-
@pool.conn(:read_only).
|
|
888
|
+
@pool.conn.must_be_nil
|
|
889
|
+
@pool.conn(:read_only).must_be_nil
|
|
890
890
|
end
|
|
891
891
|
|
|
892
892
|
it ":disconnection_proc option should set the disconnection proc to use" do
|
|
@@ -1041,7 +1041,7 @@ AllConnectionPoolClassesSpecs = shared_description do
|
|
|
1041
1041
|
x = nil
|
|
1042
1042
|
c = @class.new(mock_db.call(proc{|c1| x = c1}){123})
|
|
1043
1043
|
c.hold{}
|
|
1044
|
-
x.
|
|
1044
|
+
x.must_be_nil
|
|
1045
1045
|
c.disconnect
|
|
1046
1046
|
x.must_equal 123
|
|
1047
1047
|
end
|
data/spec/core/database_spec.rb
CHANGED
|
@@ -79,127 +79,6 @@ describe "A new Database" do
|
|
|
79
79
|
db.pool.must_be_kind_of(Sequel::ConnectionPool)
|
|
80
80
|
end
|
|
81
81
|
|
|
82
|
-
it "should respect the :quote_identifiers option" do
|
|
83
|
-
db = Sequel::Database.new(:quote_identifiers=>false)
|
|
84
|
-
db.quote_identifiers?.must_equal false
|
|
85
|
-
db = Sequel::Database.new(:quote_identifiers=>true)
|
|
86
|
-
db.quote_identifiers?.must_equal true
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
it "should upcase on input and downcase on output by default" do
|
|
90
|
-
db = Sequel::Database.new
|
|
91
|
-
db.send(:identifier_input_method_default).must_equal :upcase
|
|
92
|
-
db.send(:identifier_output_method_default).must_equal :downcase
|
|
93
|
-
end
|
|
94
|
-
|
|
95
|
-
it "should respect the :identifier_input_method option" do
|
|
96
|
-
Sequel.identifier_input_method = nil
|
|
97
|
-
Sequel::Database.identifier_input_method.must_equal false
|
|
98
|
-
db = Sequel::Database.new(:identifier_input_method=>nil)
|
|
99
|
-
db.identifier_input_method.must_equal nil
|
|
100
|
-
db.identifier_input_method = :downcase
|
|
101
|
-
db.identifier_input_method.must_equal :downcase
|
|
102
|
-
db = Sequel::Database.new(:identifier_input_method=>:upcase)
|
|
103
|
-
db.identifier_input_method.must_equal :upcase
|
|
104
|
-
db.identifier_input_method = nil
|
|
105
|
-
db.identifier_input_method.must_equal nil
|
|
106
|
-
Sequel.identifier_input_method = :downcase
|
|
107
|
-
Sequel::Database.identifier_input_method.must_equal :downcase
|
|
108
|
-
db = Sequel::Database.new(:identifier_input_method=>nil)
|
|
109
|
-
db.identifier_input_method.must_equal nil
|
|
110
|
-
db.identifier_input_method = :upcase
|
|
111
|
-
db.identifier_input_method.must_equal :upcase
|
|
112
|
-
db = Sequel::Database.new(:identifier_input_method=>:upcase)
|
|
113
|
-
db.identifier_input_method.must_equal :upcase
|
|
114
|
-
db.identifier_input_method = nil
|
|
115
|
-
db.identifier_input_method.must_equal nil
|
|
116
|
-
end
|
|
117
|
-
|
|
118
|
-
it "should respect the :identifier_output_method option" do
|
|
119
|
-
Sequel.identifier_output_method = nil
|
|
120
|
-
Sequel::Database.identifier_output_method.must_equal false
|
|
121
|
-
db = Sequel::Database.new(:identifier_output_method=>nil)
|
|
122
|
-
db.identifier_output_method.must_equal nil
|
|
123
|
-
db.identifier_output_method = :downcase
|
|
124
|
-
db.identifier_output_method.must_equal :downcase
|
|
125
|
-
db = Sequel::Database.new(:identifier_output_method=>:upcase)
|
|
126
|
-
db.identifier_output_method.must_equal :upcase
|
|
127
|
-
db.identifier_output_method = nil
|
|
128
|
-
db.identifier_output_method.must_equal nil
|
|
129
|
-
Sequel.identifier_output_method = :downcase
|
|
130
|
-
Sequel::Database.identifier_output_method.must_equal :downcase
|
|
131
|
-
db = Sequel::Database.new(:identifier_output_method=>nil)
|
|
132
|
-
db.identifier_output_method.must_equal nil
|
|
133
|
-
db.identifier_output_method = :upcase
|
|
134
|
-
db.identifier_output_method.must_equal :upcase
|
|
135
|
-
db = Sequel::Database.new(:identifier_output_method=>:upcase)
|
|
136
|
-
db.identifier_output_method.must_equal :upcase
|
|
137
|
-
db.identifier_output_method = nil
|
|
138
|
-
db.identifier_output_method.must_equal nil
|
|
139
|
-
end
|
|
140
|
-
|
|
141
|
-
it "should use the default Sequel.quote_identifiers value" do
|
|
142
|
-
Sequel.quote_identifiers = true
|
|
143
|
-
Sequel::Database.new({}).quote_identifiers?.must_equal true
|
|
144
|
-
Sequel.quote_identifiers = false
|
|
145
|
-
Sequel::Database.new({}).quote_identifiers?.must_equal false
|
|
146
|
-
Sequel::Database.quote_identifiers = true
|
|
147
|
-
Sequel::Database.new({}).quote_identifiers?.must_equal true
|
|
148
|
-
Sequel::Database.quote_identifiers = false
|
|
149
|
-
Sequel::Database.new({}).quote_identifiers?.must_equal false
|
|
150
|
-
end
|
|
151
|
-
|
|
152
|
-
it "should use the default Sequel.identifier_input_method value" do
|
|
153
|
-
Sequel.identifier_input_method = :downcase
|
|
154
|
-
Sequel::Database.new({}).identifier_input_method.must_equal :downcase
|
|
155
|
-
Sequel.identifier_input_method = :upcase
|
|
156
|
-
Sequel::Database.new({}).identifier_input_method.must_equal :upcase
|
|
157
|
-
Sequel::Database.identifier_input_method = :downcase
|
|
158
|
-
Sequel::Database.new({}).identifier_input_method.must_equal :downcase
|
|
159
|
-
Sequel::Database.identifier_input_method = :upcase
|
|
160
|
-
Sequel::Database.new({}).identifier_input_method.must_equal :upcase
|
|
161
|
-
end
|
|
162
|
-
|
|
163
|
-
it "should use the default Sequel.identifier_output_method value" do
|
|
164
|
-
Sequel.identifier_output_method = :downcase
|
|
165
|
-
Sequel::Database.new({}).identifier_output_method.must_equal :downcase
|
|
166
|
-
Sequel.identifier_output_method = :upcase
|
|
167
|
-
Sequel::Database.new({}).identifier_output_method.must_equal :upcase
|
|
168
|
-
Sequel::Database.identifier_output_method = :downcase
|
|
169
|
-
Sequel::Database.new({}).identifier_output_method.must_equal :downcase
|
|
170
|
-
Sequel::Database.identifier_output_method = :upcase
|
|
171
|
-
Sequel::Database.new({}).identifier_output_method.must_equal :upcase
|
|
172
|
-
end
|
|
173
|
-
|
|
174
|
-
it "should respect the quote_indentifiers_default method if Sequel.quote_identifiers = nil" do
|
|
175
|
-
Sequel.quote_identifiers = nil
|
|
176
|
-
Sequel::Database.new({}).quote_identifiers?.must_equal true
|
|
177
|
-
x = Class.new(Sequel::Database){def quote_identifiers_default; false end}
|
|
178
|
-
x.new({}).quote_identifiers?.must_equal false
|
|
179
|
-
y = Class.new(Sequel::Database){def quote_identifiers_default; true end}
|
|
180
|
-
y.new({}).quote_identifiers?.must_equal true
|
|
181
|
-
end
|
|
182
|
-
|
|
183
|
-
it "should respect the identifier_input_method_default method" do
|
|
184
|
-
class Sequel::Database
|
|
185
|
-
@identifier_input_method = nil
|
|
186
|
-
end
|
|
187
|
-
x = Class.new(Sequel::Database){def identifier_input_method_default; :downcase end}
|
|
188
|
-
x.new({}).identifier_input_method.must_equal :downcase
|
|
189
|
-
y = Class.new(Sequel::Database){def identifier_input_method_default; :camelize end}
|
|
190
|
-
y.new({}).identifier_input_method.must_equal :camelize
|
|
191
|
-
end
|
|
192
|
-
|
|
193
|
-
it "should respect the identifier_output_method_default method if Sequel.identifier_output_method is not called" do
|
|
194
|
-
class Sequel::Database
|
|
195
|
-
@identifier_output_method = nil
|
|
196
|
-
end
|
|
197
|
-
x = Class.new(Sequel::Database){def identifier_output_method_default; :upcase end}
|
|
198
|
-
x.new({}).identifier_output_method.must_equal :upcase
|
|
199
|
-
y = Class.new(Sequel::Database){def identifier_output_method_default; :underscore end}
|
|
200
|
-
y.new({}).identifier_output_method.must_equal :underscore
|
|
201
|
-
end
|
|
202
|
-
|
|
203
82
|
it "should just use a :uri option for jdbc with the full connection string" do
|
|
204
83
|
db = Sequel::Database.stub(:adapter_class, Sequel::Database) do
|
|
205
84
|
Sequel.connect('jdbc:test://host/db_name')
|
|
@@ -384,7 +263,7 @@ describe "Database#uri" do
|
|
|
384
263
|
end
|
|
385
264
|
|
|
386
265
|
it "should return nil if a connection uri was not used" do
|
|
387
|
-
Sequel.mock.uri.
|
|
266
|
+
Sequel.mock.uri.must_be_nil
|
|
388
267
|
end
|
|
389
268
|
|
|
390
269
|
it "should be aliased as #url" do
|
|
@@ -394,7 +273,7 @@ end
|
|
|
394
273
|
|
|
395
274
|
describe "Database.adapter_scheme and #adapter_scheme" do
|
|
396
275
|
it "should return the database scheme" do
|
|
397
|
-
Sequel::Database.adapter_scheme.
|
|
276
|
+
Sequel::Database.adapter_scheme.must_be_nil
|
|
398
277
|
|
|
399
278
|
@c = Class.new(Sequel::Database) do
|
|
400
279
|
set_adapter_scheme :mau
|
|
@@ -407,7 +286,7 @@ end
|
|
|
407
286
|
|
|
408
287
|
describe "Database#dataset" do
|
|
409
288
|
before do
|
|
410
|
-
@db = Sequel
|
|
289
|
+
@db = Sequel.mock
|
|
411
290
|
@ds = @db.dataset
|
|
412
291
|
end
|
|
413
292
|
|
|
@@ -516,8 +395,11 @@ describe "Database#extend_datasets" do
|
|
|
516
395
|
end
|
|
517
396
|
|
|
518
397
|
it "should be able to override methods defined in the original Dataset class" do
|
|
519
|
-
@db.extend_datasets
|
|
520
|
-
|
|
398
|
+
@db.extend_datasets do
|
|
399
|
+
def select(*a, &block) super.order(*a, &block) end
|
|
400
|
+
def input_identifier(v) v.to_s end
|
|
401
|
+
end
|
|
402
|
+
@db[:t].with_quote_identifiers(false).select(:a, :b).sql.must_equal 'SELECT a, b FROM t ORDER BY a, b'
|
|
521
403
|
end
|
|
522
404
|
|
|
523
405
|
it "should reapply settings if dataset_class is changed" do
|
|
@@ -565,7 +447,7 @@ describe "Database#run" do
|
|
|
565
447
|
end
|
|
566
448
|
|
|
567
449
|
it "should return nil" do
|
|
568
|
-
@db.run("DELETE FROM items").
|
|
450
|
+
@db.run("DELETE FROM items").must_be_nil
|
|
569
451
|
end
|
|
570
452
|
|
|
571
453
|
it "should accept options passed to execute_ddl" do
|
|
@@ -609,7 +491,7 @@ describe "Database#synchronize" do
|
|
|
609
491
|
c1.must_equal 12345
|
|
610
492
|
t2 = Thread.new{@db.synchronize{|c| c2 = c; q2.push nil}}
|
|
611
493
|
@db.pool.available_connections.must_be :empty?
|
|
612
|
-
c2.
|
|
494
|
+
c2.must_be_nil
|
|
613
495
|
q1.push nil
|
|
614
496
|
q.pop
|
|
615
497
|
q2.pop
|
|
@@ -841,13 +723,13 @@ DatabaseTransactionSpecs = shared_description do
|
|
|
841
723
|
rbc = nil
|
|
842
724
|
@db.transaction do
|
|
843
725
|
rbc = @db.rollback_checker
|
|
844
|
-
rbc.call.
|
|
726
|
+
rbc.call.must_be_nil
|
|
845
727
|
end
|
|
846
728
|
rbc.call.must_equal false
|
|
847
729
|
|
|
848
730
|
@db.transaction(:rollback=>:always) do
|
|
849
731
|
rbc = @db.rollback_checker
|
|
850
|
-
rbc.call.
|
|
732
|
+
rbc.call.must_be_nil
|
|
851
733
|
end
|
|
852
734
|
rbc.call.must_equal true
|
|
853
735
|
|
|
@@ -864,7 +746,7 @@ DatabaseTransactionSpecs = shared_description do
|
|
|
864
746
|
end
|
|
865
747
|
|
|
866
748
|
it "should return nil if Sequel::Rollback is called in the transaction" do
|
|
867
|
-
@db.transaction{raise Sequel::Rollback}.
|
|
749
|
+
@db.transaction{raise Sequel::Rollback}.must_be_nil
|
|
868
750
|
end
|
|
869
751
|
|
|
870
752
|
it "should reraise Sequel::Rollback errors when using :rollback=>:reraise option is given" do
|
|
@@ -879,7 +761,7 @@ DatabaseTransactionSpecs = shared_description do
|
|
|
879
761
|
it "should always rollback if :rollback=>:always option is given" do
|
|
880
762
|
proc {@db.transaction(:rollback=>:always){raise ArgumentError}}.must_raise(ArgumentError)
|
|
881
763
|
@db.sqls.must_equal ['BEGIN', 'ROLLBACK']
|
|
882
|
-
@db.transaction(:rollback=>:always){raise Sequel::Rollback}.
|
|
764
|
+
@db.transaction(:rollback=>:always){raise Sequel::Rollback}.must_be_nil
|
|
883
765
|
@db.sqls.must_equal ['BEGIN', 'ROLLBACK']
|
|
884
766
|
@db.transaction(:rollback=>:always){1}.must_equal 1
|
|
885
767
|
@db.sqls.must_equal ['BEGIN', 'ROLLBACK']
|
|
@@ -1158,7 +1040,7 @@ describe "Sequel.transaction" do
|
|
|
1158
1040
|
end
|
|
1159
1041
|
|
|
1160
1042
|
it "should handle Sequel::Rollback exceptions raised by the block to rollback on all databases" do
|
|
1161
|
-
Sequel.transaction([@db1, @db2, @db3]){raise Sequel::Rollback}.
|
|
1043
|
+
Sequel.transaction([@db1, @db2, @db3]){raise Sequel::Rollback}.must_be_nil
|
|
1162
1044
|
@sqls.must_equal ['BEGIN -- 1', 'BEGIN -- 2', 'BEGIN -- 3', 'ROLLBACK -- 3', 'ROLLBACK -- 2', 'ROLLBACK -- 1']
|
|
1163
1045
|
end
|
|
1164
1046
|
|
|
@@ -1465,7 +1347,7 @@ end
|
|
|
1465
1347
|
|
|
1466
1348
|
describe "Sequel::Database.load_adapter" do
|
|
1467
1349
|
it "should not raise an error if subadapter does not exist" do
|
|
1468
|
-
Sequel::Database.load_adapter(:foo, :subdir=>'bar').
|
|
1350
|
+
Sequel::Database.load_adapter(:foo, :subdir=>'bar').must_be_nil
|
|
1469
1351
|
end
|
|
1470
1352
|
end
|
|
1471
1353
|
|
|
@@ -1617,7 +1499,7 @@ describe "Database#fetch" do
|
|
|
1617
1499
|
ds.select_sql.must_equal 'select * from xyz'
|
|
1618
1500
|
ds.sql.must_equal 'select * from xyz'
|
|
1619
1501
|
|
|
1620
|
-
ds.
|
|
1502
|
+
ds = ds.where{price.sql_number < 100}
|
|
1621
1503
|
ds.select_sql.must_equal 'select * from xyz'
|
|
1622
1504
|
ds.sql.must_equal 'select * from xyz'
|
|
1623
1505
|
end
|
|
@@ -1950,7 +1832,7 @@ describe "Database#typecast_value" do
|
|
|
1950
1832
|
@db.typecast_value(:boolean, '1').must_equal true
|
|
1951
1833
|
@db.typecast_value(:boolean, 't').must_equal true
|
|
1952
1834
|
@db.typecast_value(:boolean, 'true').must_equal true
|
|
1953
|
-
@db.typecast_value(:boolean, '').
|
|
1835
|
+
@db.typecast_value(:boolean, '').must_be_nil
|
|
1954
1836
|
end
|
|
1955
1837
|
|
|
1956
1838
|
it "should typecast date values to Date" do
|
|
@@ -2405,37 +2287,11 @@ describe "Database#supports_transaction_isolation_levels?" do
|
|
|
2405
2287
|
end
|
|
2406
2288
|
end
|
|
2407
2289
|
|
|
2408
|
-
describe "Database#input_identifier_meth" do
|
|
2409
|
-
it "should be the input_identifer method of a default dataset for this database" do
|
|
2410
|
-
db = Sequel::Database.new
|
|
2411
|
-
db.send(:input_identifier_meth).call(:a).must_equal 'a'
|
|
2412
|
-
db.identifier_input_method = :upcase
|
|
2413
|
-
db.send(:input_identifier_meth).call(:a).must_equal 'A'
|
|
2414
|
-
end
|
|
2415
|
-
end
|
|
2416
|
-
|
|
2417
|
-
describe "Database#output_identifier_meth" do
|
|
2418
|
-
it "should be the output_identifer method of a default dataset for this database" do
|
|
2419
|
-
db = Sequel::Database.new
|
|
2420
|
-
db.send(:output_identifier_meth).call('A').must_equal :A
|
|
2421
|
-
db.identifier_output_method = :downcase
|
|
2422
|
-
db.send(:output_identifier_meth).call('A').must_equal :a
|
|
2423
|
-
end
|
|
2424
|
-
end
|
|
2425
|
-
|
|
2426
|
-
describe "Database#metadata_dataset" do
|
|
2427
|
-
it "should be a dataset with the default settings for identifier_input_method and identifier_output_method" do
|
|
2428
|
-
ds = Sequel::Database.new.send(:metadata_dataset)
|
|
2429
|
-
ds.literal(:a).must_equal 'A'
|
|
2430
|
-
ds.send(:output_identifier, 'A').must_equal :a
|
|
2431
|
-
end
|
|
2432
|
-
end
|
|
2433
|
-
|
|
2434
2290
|
describe "Database#column_schema_to_ruby_default" do
|
|
2435
2291
|
it "should handle converting many default formats" do
|
|
2436
2292
|
db = Sequel::Database.new
|
|
2437
2293
|
p = lambda{|d,t| db.send(:column_schema_to_ruby_default, d, t)}
|
|
2438
|
-
p[nil, :integer].
|
|
2294
|
+
p[nil, :integer].must_be_nil
|
|
2439
2295
|
p[1, :integer].must_equal 1
|
|
2440
2296
|
p['1', :integer].must_equal 1
|
|
2441
2297
|
p['-1', :integer].must_equal(-1)
|
|
@@ -2471,7 +2327,7 @@ describe "Database#column_schema_to_ruby_default" do
|
|
|
2471
2327
|
p["'2009-10-29T10:20:30-07:00'", :datetime].must_equal DateTime.parse('2009-10-29T10:20:30-07:00')
|
|
2472
2328
|
p["'2009-10-29 10:20:30'", :datetime].must_equal DateTime.parse('2009-10-29 10:20:30')
|
|
2473
2329
|
p["'10:20:30'", :time].must_equal Time.parse('10:20:30')
|
|
2474
|
-
p["NaN", :float].
|
|
2330
|
+
p["NaN", :float].must_be_nil
|
|
2475
2331
|
|
|
2476
2332
|
db = Sequel.mock(:host=>'postgres')
|
|
2477
2333
|
p["''::text", :string].must_equal ""
|
|
@@ -2523,7 +2379,7 @@ describe "Database extensions" do
|
|
|
2523
2379
|
end
|
|
2524
2380
|
end
|
|
2525
2381
|
before do
|
|
2526
|
-
@db = Sequel.mock
|
|
2382
|
+
@db = Sequel.mock(:identifier_mangling=>false)
|
|
2527
2383
|
end
|
|
2528
2384
|
after do
|
|
2529
2385
|
Sequel::Database.instance_variable_set(:@initialize_hook, Proc.new {|db| })
|
|
@@ -2535,25 +2391,21 @@ describe "Database extensions" do
|
|
|
2535
2391
|
end
|
|
2536
2392
|
|
|
2537
2393
|
it "should be able to register an extension with a block and have Database#extension call the block" do
|
|
2538
|
-
|
|
2539
|
-
|
|
2540
|
-
@db.extension(:foo).quote_identifiers?.must_equal true
|
|
2394
|
+
Sequel::Database.register_extension(:foo){|db| db.opts[:foo] = 1}
|
|
2395
|
+
@db.extension(:foo).opts[:foo].must_equal 1
|
|
2541
2396
|
end
|
|
2542
2397
|
|
|
2543
2398
|
it "should be able to register an extension with a callable and Database#extension call the callable" do
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
@db.extension(:foo).quote_identifiers?.must_equal true
|
|
2399
|
+
Sequel::Database.register_extension(:foo, proc{|db| db.opts[:foo] = 1})
|
|
2400
|
+
@db.extension(:foo).opts[:foo].must_equal 1
|
|
2547
2401
|
end
|
|
2548
2402
|
|
|
2549
2403
|
it "should be able to load multiple extensions in the same call" do
|
|
2550
|
-
|
|
2551
|
-
|
|
2552
|
-
Sequel::Database.register_extension(:
|
|
2553
|
-
|
|
2554
|
-
|
|
2555
|
-
@db.quote_identifiers?.must_equal true
|
|
2556
|
-
@db.identifier_input_method.must_equal nil
|
|
2404
|
+
a = []
|
|
2405
|
+
Sequel::Database.register_extension(:foo, proc{|db| a << db.opts[:foo] = 1})
|
|
2406
|
+
Sequel::Database.register_extension(:bar, proc{|db| a << db.opts[:bar] = 2})
|
|
2407
|
+
@db.extension(:foo, :bar).opts.values_at(:foo, :bar).must_equal [1, 2]
|
|
2408
|
+
a.must_equal [1, 2]
|
|
2557
2409
|
end
|
|
2558
2410
|
|
|
2559
2411
|
it "should return the receiver" do
|
|
@@ -2575,8 +2427,8 @@ describe "Database extensions" do
|
|
|
2575
2427
|
Sequel::Database.extension(:foo, :bar)
|
|
2576
2428
|
@db.wont_respond_to(:a)
|
|
2577
2429
|
@db.wont_respond_to(:b)
|
|
2578
|
-
Sequel.mock.a.must_equal 1
|
|
2579
|
-
Sequel.mock.b.must_equal 2
|
|
2430
|
+
Sequel.mock(:identifier_mangling=>false).a.must_equal 1
|
|
2431
|
+
Sequel.mock(:identifier_mangling=>false).b.must_equal 2
|
|
2580
2432
|
end
|
|
2581
2433
|
end
|
|
2582
2434
|
|
|
@@ -2664,3 +2516,9 @@ describe "Database#execute_{dui,ddl,insert}" do
|
|
|
2664
2516
|
@db.sqls.must_equal ["DELETE FROM table", "SET foo", "INSERT INTO table DEFAULT VALUES"]
|
|
2665
2517
|
end
|
|
2666
2518
|
end
|
|
2519
|
+
|
|
2520
|
+
describe "Dataset identifier folding" do
|
|
2521
|
+
it "should fold to uppercase by default, as per SQL" do
|
|
2522
|
+
Sequel::Database.new(:identifier_mangling=>false).send(:folds_unquoted_identifiers_to_uppercase?).must_equal true
|
|
2523
|
+
end
|
|
2524
|
+
end
|