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
|
@@ -17,7 +17,7 @@ describe "Sequel::Dataset::RoundTimestamps" do
|
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
it "should round times properly for databases supporting millisecond precision" do
|
|
20
|
-
|
|
20
|
+
@dataset = @dataset.with_extend{def timestamp_precision; 3 end}
|
|
21
21
|
@dataset.literal(Sequel::SQLTime.create(1, 2, 3, 499500)).must_equal "'01:02:03.500'"
|
|
22
22
|
@dataset.literal(Time.local(2010, 1, 2, 3, 4, 5.4995)).must_equal "'2010-01-02 03:04:05.500'"
|
|
23
23
|
@dataset.literal(DateTime.new(2010, 1, 2, 3, 4, Rational(54995, 10000))).must_equal "'2010-01-02 03:04:05.500'"
|
|
@@ -28,7 +28,7 @@ describe "Sequel::Dataset::RoundTimestamps" do
|
|
|
28
28
|
end
|
|
29
29
|
|
|
30
30
|
it "should round times properly for databases supporting second precision" do
|
|
31
|
-
|
|
31
|
+
@dataset = @dataset.with_extend{def supports_timestamp_usecs?; false end}
|
|
32
32
|
@dataset.literal(Sequel::SQLTime.create(1, 2, 3, 500000)).must_equal "'01:02:04'"
|
|
33
33
|
@dataset.literal(Time.local(2010, 1, 2, 3, 4, 5.5)).must_equal "'2010-01-02 03:04:06'"
|
|
34
34
|
@dataset.literal(DateTime.new(2010, 1, 2, 3, 4, Rational(55, 10))).must_equal "'2010-01-02 03:04:06'"
|
|
@@ -633,8 +633,9 @@ END_MIG
|
|
|
633
633
|
s.each{|_, c| c[:ruby_default] = column_schema_to_ruby_default(c[:default], c[:type])}
|
|
634
634
|
s
|
|
635
635
|
end
|
|
636
|
-
|
|
637
|
-
@d.dump_table_schema(:t4
|
|
636
|
+
e = RUBY_VERSION >= '2.4' ? 'e' : 'E'
|
|
637
|
+
@d.dump_table_schema(:t4).gsub(/[+-]\d\d\d\d"\)/, '")').gsub(/\.0+/, '.0').must_equal "create_table(:t4) do\n TrueClass :c1, :default=>false\n String :c2, :default=>\"blah\"\n Integer :c3, :default=>-1\n Float :c4, :default=>1.0\n BigDecimal :c5, :default=>BigDecimal.new(\"0.1005#{e}3\")\n File :c6, :default=>Sequel::SQL::Blob.new(\"blah\")\n Date :c7, :default=>Date.new(2008, 10, 29)\n DateTime :c8, :default=>DateTime.parse(\"2008-10-29T10:20:30.0\")\n Time :c9, :default=>Sequel::SQLTime.parse(\"10:20:30.0\"), :only_time=>true\n String :c10\n Date :c11, :default=>Sequel::CURRENT_DATE\n DateTime :c12, :default=>Sequel::CURRENT_TIMESTAMP\nend"
|
|
638
|
+
@d.dump_table_schema(:t4, :same_db=>true).gsub(/[+-]\d\d\d\d"\)/, '")').gsub(/\.0+/, '.0').must_equal "create_table(:t4) do\n column :c1, \"boolean\", :default=>false\n column :c2, \"varchar\", :default=>\"blah\"\n column :c3, \"integer\", :default=>-1\n column :c4, \"float\", :default=>1.0\n column :c5, \"decimal\", :default=>BigDecimal.new(\"0.1005#{e}3\")\n column :c6, \"blob\", :default=>Sequel::SQL::Blob.new(\"blah\")\n column :c7, \"date\", :default=>Date.new(2008, 10, 29)\n column :c8, \"datetime\", :default=>DateTime.parse(\"2008-10-29T10:20:30.0\")\n column :c9, \"time\", :default=>Sequel::SQLTime.parse(\"10:20:30.0\")\n column :c10, \"foo\", :default=>Sequel::LiteralString.new(\"'6 weeks'\")\n column :c11, \"date\", :default=>Sequel::CURRENT_DATE\n column :c12, \"timestamp\", :default=>Sequel::CURRENT_TIMESTAMP\nend"
|
|
638
639
|
end
|
|
639
640
|
|
|
640
641
|
it "should not use a literal string as a fallback if using MySQL with the :same_db option" do
|
|
@@ -67,9 +67,9 @@ describe Sequel::Model, "create_table and schema" do
|
|
|
67
67
|
it "should return nil if no schema is present" do
|
|
68
68
|
@model = Class.new(Sequel::Model)
|
|
69
69
|
@model.plugin :schema
|
|
70
|
-
@model.schema.
|
|
70
|
+
@model.schema.must_be_nil
|
|
71
71
|
@submodel = Class.new(@model)
|
|
72
|
-
@submodel.schema.
|
|
72
|
+
@submodel.schema.must_be_nil
|
|
73
73
|
end
|
|
74
74
|
end
|
|
75
75
|
|
|
@@ -19,8 +19,7 @@ describe "scissors plugin" do
|
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
it "Model.destory each instance in the dataset" do
|
|
22
|
-
@m.dataset.
|
|
23
|
-
@m.destroy
|
|
22
|
+
@m.dataset.with_fetch(:id=>1).destroy
|
|
24
23
|
@m.db.sqls.must_equal ['BEGIN', 'SELECT * FROM items', 'DELETE FROM items WHERE id = 1', 'COMMIT']
|
|
25
24
|
end
|
|
26
25
|
end
|
|
@@ -56,25 +56,38 @@ describe "Dataset#insert_multiple" do
|
|
|
56
56
|
end
|
|
57
57
|
end
|
|
58
58
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
59
|
+
# SEQUEL5: Remove
|
|
60
|
+
unless Sequel.mock.dataset.frozen?
|
|
61
|
+
describe "Dataset#db=" do
|
|
62
|
+
it "should change the dataset's database" do
|
|
63
|
+
db = Sequel.mock
|
|
64
|
+
ds = db[:items].extension(:sequel_3_dataset_methods)
|
|
65
|
+
db2 = Sequel.mock
|
|
66
|
+
ds.db = db2
|
|
67
|
+
ds.db.must_equal db2
|
|
68
|
+
ds.db.wont_equal db
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
it "should raise error for frozen datasets" do
|
|
72
|
+
ds = Sequel.mock.dataset.extension(:sequel_3_dataset_methods).freeze
|
|
73
|
+
proc{ds.db = ds.db}.must_raise RuntimeError
|
|
74
|
+
end
|
|
67
75
|
end
|
|
68
|
-
end
|
|
69
76
|
|
|
70
|
-
describe "Dataset#opts=" do
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
77
|
+
describe "Dataset#opts=" do
|
|
78
|
+
it "should change the dataset's opts" do
|
|
79
|
+
db = Sequel.mock
|
|
80
|
+
ds = db[:items].extension(:sequel_3_dataset_methods)
|
|
81
|
+
ds.sql.must_equal 'SELECT * FROM items'
|
|
82
|
+
ds.opts = {}
|
|
83
|
+
ds.sql.must_equal 'SELECT *'
|
|
84
|
+
ds.opts.must_equal({})
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
it "should raise error for frozen datasets" do
|
|
88
|
+
ds = Sequel.mock.dataset.extension(:sequel_3_dataset_methods).freeze
|
|
89
|
+
proc{ds.opts = {}}.must_raise RuntimeError
|
|
90
|
+
end
|
|
78
91
|
end
|
|
79
92
|
end
|
|
80
93
|
|
|
@@ -42,12 +42,12 @@ describe "serialization_modification_detection plugin" do
|
|
|
42
42
|
@o2.changed_columns.must_equal [:h]
|
|
43
43
|
|
|
44
44
|
@o3.changed_columns.must_equal []
|
|
45
|
-
@o3.h.
|
|
45
|
+
@o3.h.must_be_nil
|
|
46
46
|
@o3.h = {}
|
|
47
47
|
@o3.changed_columns.must_equal [:h]
|
|
48
48
|
|
|
49
49
|
@o4.changed_columns.must_equal []
|
|
50
|
-
@o4.h.
|
|
50
|
+
@o4.h.must_be_nil
|
|
51
51
|
@o4.h = {}
|
|
52
52
|
@o4.changed_columns.must_equal [:h]
|
|
53
53
|
end
|
|
@@ -94,7 +94,7 @@ describe "Serialization plugin" do
|
|
|
94
94
|
it "should translate values to and from yaml serialization format using accessor methods" do
|
|
95
95
|
@c.set_primary_key :id
|
|
96
96
|
@c.plugin :serialization, :yaml, :abc, :def
|
|
97
|
-
@c.dataset
|
|
97
|
+
@c.dataset = @c.dataset.with_fetch(:id => 1, :abc => "--- 1\n", :def => "--- hello\n")
|
|
98
98
|
|
|
99
99
|
o = @c.first
|
|
100
100
|
o.id.must_equal 1
|
|
@@ -114,7 +114,7 @@ describe "Serialization plugin" do
|
|
|
114
114
|
it "should translate values to and from marshal serialization format using accessor methods" do
|
|
115
115
|
@c.set_primary_key :id
|
|
116
116
|
@c.plugin :serialization, :marshal, :abc, :def
|
|
117
|
-
@c.dataset
|
|
117
|
+
@c.dataset = @c.dataset.with_fetch([:id => 1, :abc =>[Marshal.dump(1)].pack('m'), :def =>[Marshal.dump('hello')].pack('m')])
|
|
118
118
|
|
|
119
119
|
o = @c.first
|
|
120
120
|
o.id.must_equal 1
|
|
@@ -134,7 +134,7 @@ describe "Serialization plugin" do
|
|
|
134
134
|
it "should handle old non-base-64 encoded marshal serialization format" do
|
|
135
135
|
@c.set_primary_key :id
|
|
136
136
|
@c.plugin :serialization, :marshal, :abc, :def
|
|
137
|
-
@c.dataset
|
|
137
|
+
@c.dataset = @c.dataset.with_fetch([:id => 1, :abc =>Marshal.dump(1), :def =>Marshal.dump('hello')])
|
|
138
138
|
|
|
139
139
|
o = @c.first
|
|
140
140
|
o.abc.must_equal 1
|
|
@@ -144,7 +144,7 @@ describe "Serialization plugin" do
|
|
|
144
144
|
it "should raise exception for bad marshal data" do
|
|
145
145
|
@c.set_primary_key :id
|
|
146
146
|
@c.plugin :serialization, :marshal, :abc, :def
|
|
147
|
-
@c.dataset
|
|
147
|
+
@c.dataset = @c.dataset.with_fetch([:id => 1, :abc =>'foo', :def =>'bar'])
|
|
148
148
|
|
|
149
149
|
o = @c.first
|
|
150
150
|
proc{o.abc}.must_raise TypeError, ArgumentError
|
|
@@ -154,7 +154,7 @@ describe "Serialization plugin" do
|
|
|
154
154
|
it "should translate values to and from json serialization format using accessor methods" do
|
|
155
155
|
@c.set_primary_key :id
|
|
156
156
|
@c.plugin :serialization, :json, :abc, :def
|
|
157
|
-
@c.dataset
|
|
157
|
+
@c.dataset = @c.dataset.with_fetch(:id => 1, :abc => [1].to_json, :def => ["hello"].to_json)
|
|
158
158
|
|
|
159
159
|
o = @c.first
|
|
160
160
|
o.id.must_equal 1
|
|
@@ -175,7 +175,7 @@ describe "Serialization plugin" do
|
|
|
175
175
|
it "should translate values to and from arbitrary callables using accessor methods" do
|
|
176
176
|
@c.set_primary_key :id
|
|
177
177
|
@c.plugin :serialization, [proc{|s| s.reverse}, proc{|s| s.reverse}], :abc, :def
|
|
178
|
-
@c.dataset
|
|
178
|
+
@c.dataset = @c.dataset.with_fetch(:id => 1, :abc => 'cba', :def => 'olleh')
|
|
179
179
|
|
|
180
180
|
o = @c.first
|
|
181
181
|
o.id.must_equal 1
|
|
@@ -198,7 +198,7 @@ describe "Serialization plugin" do
|
|
|
198
198
|
require 'sequel/plugins/serialization'
|
|
199
199
|
Sequel::Plugins::Serialization.register_format(:reverse, proc{|s| s.reverse}, proc{|s| s.reverse})
|
|
200
200
|
@c.plugin :serialization, :reverse, :abc, :def
|
|
201
|
-
@c.dataset
|
|
201
|
+
@c.dataset = @c.dataset.with_fetch(:id => 1, :abc => 'cba', :def => 'olleh')
|
|
202
202
|
|
|
203
203
|
o = @c.first
|
|
204
204
|
o.id.must_equal 1
|
|
@@ -219,7 +219,7 @@ describe "Serialization plugin" do
|
|
|
219
219
|
it "should copy serialization formats and columns to subclasses" do
|
|
220
220
|
@c.set_primary_key :id
|
|
221
221
|
@c.plugin :serialization, :yaml, :abc, :def
|
|
222
|
-
@c.dataset
|
|
222
|
+
@c.dataset = @c.dataset.with_fetch(:id => 1, :abc => "--- 1\n", :def => "--- hello\n")
|
|
223
223
|
|
|
224
224
|
o = Class.new(@c).first
|
|
225
225
|
o.id.must_equal 1
|
|
@@ -259,8 +259,10 @@ describe "Serialization plugin" do
|
|
|
259
259
|
it "should not clear the deserialized columns when refreshing after saving a new object with insert_select" do
|
|
260
260
|
@c.set_primary_key :id
|
|
261
261
|
@c.plugin :serialization, :yaml, :abc, :def
|
|
262
|
-
|
|
263
|
-
|
|
262
|
+
@c.dataset = @c.dataset.with_extend do
|
|
263
|
+
def supports_insert_select?; true end
|
|
264
|
+
def insert_select(*) {:id=>1} end
|
|
265
|
+
end
|
|
264
266
|
o = @c.new(:abc => "--- 1\n", :def => "--- hello\n")
|
|
265
267
|
o.deserialized_values.length.must_equal 2
|
|
266
268
|
o.save
|
|
@@ -301,7 +303,7 @@ describe "Serialization plugin" do
|
|
|
301
303
|
it "should work correctly with frozen instances" do
|
|
302
304
|
@c.set_primary_key :id
|
|
303
305
|
@c.plugin :serialization, :yaml, :abc, :def
|
|
304
|
-
@c.dataset
|
|
306
|
+
@c.dataset = @c.dataset.with_fetch(:id => 1, :abc => "--- 1\n", :def => "--- hello\n")
|
|
305
307
|
|
|
306
308
|
o = @c.first
|
|
307
309
|
o.freeze
|
|
@@ -322,7 +324,7 @@ describe "Serialization plugin" do
|
|
|
322
324
|
|
|
323
325
|
it "should have changed_columns include serialized columns if those columns have changed" do
|
|
324
326
|
@c.plugin :serialization, :yaml, :abc, :def
|
|
325
|
-
@c.dataset
|
|
327
|
+
@c.dataset = @c.dataset.with_fetch(:id => 1, :abc => "--- 1\n", :def => "--- hello\n")
|
|
326
328
|
o = @c.first
|
|
327
329
|
o.changed_columns.must_equal []
|
|
328
330
|
o.abc = 1
|
|
@@ -342,7 +344,7 @@ describe "Serialization plugin" do
|
|
|
342
344
|
it "should update column_changes if the dirty plugin is used" do
|
|
343
345
|
@c.plugin :serialization, :yaml, :abc, :def
|
|
344
346
|
@c.plugin :dirty
|
|
345
|
-
@c.dataset
|
|
347
|
+
@c.dataset = @c.dataset.with_fetch(:id => 1, :abc => "--- 1\n", :def => "--- hello\n")
|
|
346
348
|
o = @c.first
|
|
347
349
|
o.column_changes.must_equal({})
|
|
348
350
|
o.abc = 1
|
|
@@ -25,10 +25,13 @@ describe "Sequel::Dataset #set_defaults" do
|
|
|
25
25
|
@ds.update_sql('y = 2').must_equal "UPDATE items SET y = 2"
|
|
26
26
|
end
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
# SEQUEL5: Remove
|
|
29
|
+
unless Sequel.mock.dataset.frozen?
|
|
30
|
+
it "should have working mutation method" do
|
|
31
|
+
@ds = Sequel.mock.dataset.from(:items).extension(:set_overrides)
|
|
32
|
+
@ds.set_defaults!(:x=>1)
|
|
33
|
+
@ds.insert_sql.must_equal "INSERT INTO items (x) VALUES (1)"
|
|
34
|
+
end
|
|
32
35
|
end
|
|
33
36
|
end
|
|
34
37
|
|
|
@@ -53,10 +56,13 @@ describe "Sequel::Dataset #set_overrides" do
|
|
|
53
56
|
@ds.set_overrides(:x=>2).update_sql.must_equal "UPDATE items SET x = 1"
|
|
54
57
|
end
|
|
55
58
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
59
|
+
# SEQUEL5: Remove
|
|
60
|
+
unless Sequel.mock.dataset.frozen?
|
|
61
|
+
it "should have working mutation method" do
|
|
62
|
+
@ds = Sequel.mock.dataset.from(:items).extension(:set_overrides)
|
|
63
|
+
@ds.set_overrides!(:x=>1)
|
|
64
|
+
@ds.insert_sql.must_equal "INSERT INTO items (x) VALUES (1)"
|
|
65
|
+
end
|
|
60
66
|
end
|
|
61
67
|
|
|
62
68
|
it "should consider dataset with select overrides and default a simple select all" do
|
|
@@ -3,21 +3,18 @@ require File.join(File.dirname(File.expand_path(__FILE__)), "spec_helper")
|
|
|
3
3
|
describe "sharding plugin" do
|
|
4
4
|
before do
|
|
5
5
|
@db = Sequel.mock(:numrows=>1, :autoid=>proc{1}, :servers=>{:s1=>{}, :s2=>{}, :s3=>{}, :s4=>{}})
|
|
6
|
-
@Artist = Class.new(Sequel::Model(@db[:artists]))
|
|
6
|
+
@Artist = Class.new(Sequel::Model(@db[:artists].with_fetch(:id=>2, :name=>'YJM')))
|
|
7
7
|
@Artist.class_eval do
|
|
8
|
-
instance_dataset._fetch = dataset._fetch = {:id=>2, :name=>'YJM'}
|
|
9
8
|
columns :id, :name
|
|
10
9
|
plugin :sharding
|
|
11
10
|
end
|
|
12
|
-
@Album = Class.new(Sequel::Model(@db[:albums]))
|
|
11
|
+
@Album = Class.new(Sequel::Model(@db[:albums].with_fetch(:id=>1, :name=>'RF', :artist_id=>2)))
|
|
13
12
|
@Album.class_eval do
|
|
14
|
-
instance_dataset._fetch = dataset._fetch = {:id=>1, :name=>'RF', :artist_id=>2}
|
|
15
13
|
columns :id, :artist_id, :name
|
|
16
14
|
plugin :sharding
|
|
17
15
|
end
|
|
18
|
-
@Tag = Class.new(Sequel::Model(@db[:tags]))
|
|
16
|
+
@Tag = Class.new(Sequel::Model(@db[:tags].with_fetch(:id=>3, :name=>'M')))
|
|
19
17
|
@Tag.class_eval do
|
|
20
|
-
instance_dataset._fetch = dataset._fetch = {:id=>3, :name=>'M'}
|
|
21
18
|
columns :id, :name
|
|
22
19
|
plugin :sharding
|
|
23
20
|
end
|
|
@@ -67,7 +64,7 @@ describe "sharding plugin" do
|
|
|
67
64
|
end
|
|
68
65
|
|
|
69
66
|
it "should not use current dataset's shard when eager loading if eagerly loaded dataset has its own shard" do
|
|
70
|
-
@Artist.
|
|
67
|
+
@Artist.dataset = @Artist.dataset.server(:s2)
|
|
71
68
|
albums = @Album.server(:s1).eager(:artist).all
|
|
72
69
|
@db.sqls.must_equal ["SELECT * FROM albums -- s1", "SELECT * FROM artists WHERE (artists.id IN (2)) -- s2"]
|
|
73
70
|
albums.length.must_equal 1
|
|
@@ -76,9 +73,7 @@ describe "sharding plugin" do
|
|
|
76
73
|
end
|
|
77
74
|
|
|
78
75
|
it "should use current dataset's shard when eager graphing if eagerly graphed dataset doesn't have its own shard" do
|
|
79
|
-
|
|
80
|
-
ds._fetch = {:id=>1, :artist_id=>2, :name=>'RF', :artist_id_0=>2, :artist_name=>'YJM'}
|
|
81
|
-
albums = ds.all
|
|
76
|
+
albums = @Album.server(:s1).eager_graph(:artist).with_fetch(:id=>1, :artist_id=>2, :name=>'RF', :artist_id_0=>2, :artist_name=>'YJM').all
|
|
82
77
|
@db.sqls.must_equal ["SELECT albums.id, albums.artist_id, albums.name, artist.id AS artist_id_0, artist.name AS artist_name FROM albums LEFT OUTER JOIN artists AS artist ON (artist.id = albums.artist_id) -- s1"]
|
|
83
78
|
albums.length.must_equal 1
|
|
84
79
|
albums.first.artist.save
|
|
@@ -86,10 +81,8 @@ describe "sharding plugin" do
|
|
|
86
81
|
end
|
|
87
82
|
|
|
88
83
|
it "should not use current dataset's shard when eager graphing if eagerly graphed dataset has its own shard" do
|
|
89
|
-
@Artist.
|
|
90
|
-
|
|
91
|
-
ds._fetch = {:id=>1, :artist_id=>2, :name=>'RF', :artist_id_0=>2, :artist_name=>'YJM'}
|
|
92
|
-
albums = ds.all
|
|
84
|
+
@Artist.dataset = @Artist.dataset.server(:s2)
|
|
85
|
+
albums = @Album.server(:s1).eager_graph(:artist).with_fetch(:id=>1, :artist_id=>2, :name=>'RF', :artist_id_0=>2, :artist_name=>'YJM').all
|
|
93
86
|
@db.sqls.must_equal ["SELECT albums.id, albums.artist_id, albums.name, artist.id AS artist_id_0, artist.name AS artist_name FROM albums LEFT OUTER JOIN artists AS artist ON (artist.id = albums.artist_id) -- s1"]
|
|
94
87
|
albums.length.must_equal 1
|
|
95
88
|
albums.first.artist.save
|
|
@@ -97,10 +90,8 @@ describe "sharding plugin" do
|
|
|
97
90
|
end
|
|
98
91
|
|
|
99
92
|
it "should use eagerly graphed dataset shard for eagerly graphed objects even if current dataset does not have a shard" do
|
|
100
|
-
@Artist.
|
|
101
|
-
|
|
102
|
-
ds._fetch = {:id=>1, :artist_id=>2, :name=>'RF', :artist_id_0=>2, :artist_name=>'YJM'}
|
|
103
|
-
albums = ds.all
|
|
93
|
+
@Artist.dataset = @Artist.dataset.server(:s2)
|
|
94
|
+
albums = @Album.eager_graph(:artist).with_fetch(:id=>1, :artist_id=>2, :name=>'RF', :artist_id_0=>2, :artist_name=>'YJM').all
|
|
104
95
|
@db.sqls.must_equal ["SELECT albums.id, albums.artist_id, albums.name, artist.id AS artist_id_0, artist.name AS artist_name FROM albums LEFT OUTER JOIN artists AS artist ON (artist.id = albums.artist_id)"]
|
|
105
96
|
albums.length.must_equal 1
|
|
106
97
|
albums.first.artist.save
|
|
@@ -28,7 +28,7 @@ describe "Shared caching behavior" do
|
|
|
28
28
|
@c.load(:id=>3, :caching_model_id=>2, :caching_model_id2=>1).caching_model2.must_be_same_as(@cm21)
|
|
29
29
|
@db.sqls.must_equal []
|
|
30
30
|
@db.fetch = []
|
|
31
|
-
@c.load(:id=>4, :caching_model_id=>2, :caching_model_id2=>2).caching_model2.
|
|
31
|
+
@c.load(:id=>4, :caching_model_id=>2, :caching_model_id2=>2).caching_model2.must_be_nil
|
|
32
32
|
end
|
|
33
33
|
end
|
|
34
34
|
|
|
@@ -40,7 +40,7 @@ describe "Shared caching behavior" do
|
|
|
40
40
|
@c.load(:id=>4, :caching_model_id=>2).caching_model.must_be_same_as(@cm2)
|
|
41
41
|
@db.sqls.must_equal []
|
|
42
42
|
@db.fetch = []
|
|
43
|
-
@c.load(:id=>4, :caching_model_id=>3).caching_model.
|
|
43
|
+
@c.load(:id=>4, :caching_model_id=>3).caching_model.must_be_nil
|
|
44
44
|
end
|
|
45
45
|
|
|
46
46
|
it "should not use a simple primary key lookup if the assocation has a nil :key option" do
|
|
@@ -93,8 +93,7 @@ describe "Shared caching behavior" do
|
|
|
93
93
|
end
|
|
94
94
|
|
|
95
95
|
it "should not use a simple primary key lookup if the prepared_statements_associations method is being used" do
|
|
96
|
-
c2 = Class.new(Sequel::Model(@db[:not_caching_model]))
|
|
97
|
-
c2.dataset._fetch = {:id=>1}
|
|
96
|
+
c2 = Class.new(Sequel::Model(@db[:not_caching_model].with_fetch(:id=>1)))
|
|
98
97
|
c = Class.new(Sequel::Model(@db[:lookup_model]))
|
|
99
98
|
c.class_eval do
|
|
100
99
|
plugin :prepared_statements_associations
|
|
@@ -21,7 +21,7 @@ describe Sequel::Model, "single table inheritance plugin" do
|
|
|
21
21
|
|
|
22
22
|
it "should have simple_table = nil" do
|
|
23
23
|
StiTest.simple_table.must_equal "sti_tests"
|
|
24
|
-
StiTestSub1.simple_table.
|
|
24
|
+
StiTestSub1.simple_table.must_be_nil
|
|
25
25
|
end
|
|
26
26
|
|
|
27
27
|
it "should allow changing the inheritance column via a plugin :single_table_inheritance call" do
|
|
@@ -30,7 +30,7 @@ describe Sequel::Model, "single table inheritance plugin" do
|
|
|
30
30
|
Object.send(:remove_const, :StiTestSub2)
|
|
31
31
|
class ::StiTestSub1 < StiTest; end
|
|
32
32
|
class ::StiTestSub2 < StiTest; end
|
|
33
|
-
StiTest.dataset
|
|
33
|
+
StiTest.dataset = StiTest.dataset.with_fetch([{:blah=>'StiTest'}, {:blah=>'StiTestSub1'}, {:blah=>'StiTestSub2'}])
|
|
34
34
|
StiTest.all.collect{|x| x.class}.must_equal [StiTest, StiTestSub1, StiTestSub2]
|
|
35
35
|
StiTest.dataset.sql.must_equal "SELECT * FROM sti_tests"
|
|
36
36
|
StiTestSub1.dataset.sql.must_equal "SELECT * FROM sti_tests WHERE (sti_tests.blah IN ('StiTestSub1'))"
|
|
@@ -38,23 +38,23 @@ describe Sequel::Model, "single table inheritance plugin" do
|
|
|
38
38
|
end
|
|
39
39
|
|
|
40
40
|
it "should return rows with the correct class based on the polymorphic_key value" do
|
|
41
|
-
|
|
41
|
+
StiTest.dataset = StiTest.dataset.with_fetch([{:kind=>'StiTest'}, {:kind=>'StiTestSub1'}, {:kind=>'StiTestSub2'}])
|
|
42
42
|
StiTest.all.collect{|x| x.class}.must_equal [StiTest, StiTestSub1, StiTestSub2]
|
|
43
43
|
end
|
|
44
44
|
|
|
45
45
|
it "should return rows with the correct class based on the polymorphic_key value when retreiving by primary key" do
|
|
46
|
-
|
|
46
|
+
StiTest.dataset = StiTest.dataset.with_fetch([{:kind=>'StiTestSub1'}])
|
|
47
47
|
StiTest[1].class.must_equal StiTestSub1
|
|
48
48
|
end
|
|
49
49
|
|
|
50
50
|
it "should return rows with the correct class for subclasses based on the polymorphic_key value" do
|
|
51
51
|
class ::StiTestSub1Sub < StiTestSub1; end
|
|
52
|
-
StiTestSub1.dataset
|
|
52
|
+
StiTestSub1.dataset = StiTestSub1.dataset.with_fetch([{:kind=>'StiTestSub1'}, {:kind=>'StiTestSub1Sub'}])
|
|
53
53
|
StiTestSub1.all.collect{|x| x.class}.must_equal [StiTestSub1, StiTestSub1Sub]
|
|
54
54
|
end
|
|
55
55
|
|
|
56
56
|
it "should fallback to the main class if the given class does not exist" do
|
|
57
|
-
|
|
57
|
+
StiTest.dataset = StiTest.dataset.with_fetch(:kind=>'StiTestSub3')
|
|
58
58
|
StiTest.all.collect{|x| x.class}.must_equal [StiTest]
|
|
59
59
|
end
|
|
60
60
|
|
|
@@ -65,7 +65,7 @@ describe Sequel::Model, "single table inheritance plugin" do
|
|
|
65
65
|
Object
|
|
66
66
|
end
|
|
67
67
|
StiTest.plugin :single_table_inheritance, :kind
|
|
68
|
-
StiTest.dataset
|
|
68
|
+
StiTest.dataset = StiTest.dataset.with_fetch([{:kind=>''}, {:kind=>nil}])
|
|
69
69
|
StiTest.all.collect{|x| x.class}.must_equal [StiTest, StiTest]
|
|
70
70
|
called.must_equal false
|
|
71
71
|
end
|
|
@@ -147,8 +147,8 @@ describe Sequel::Model, "single table inheritance plugin" do
|
|
|
147
147
|
c2[obj2.id]
|
|
148
148
|
c2.cache_get_pk(obj2.id).values.must_equal StiTest.cache_get_pk(obj2.id).values
|
|
149
149
|
obj2.save
|
|
150
|
-
c2.cache_get_pk(obj2.id).
|
|
151
|
-
StiTest.cache_get_pk(obj2.id).
|
|
150
|
+
c2.cache_get_pk(obj2.id).must_be_nil
|
|
151
|
+
StiTest.cache_get_pk(obj2.id).must_be_nil
|
|
152
152
|
end
|
|
153
153
|
|
|
154
154
|
describe "with custom options" do
|
|
@@ -170,7 +170,7 @@ describe Sequel::Model, "single table inheritance plugin" do
|
|
|
170
170
|
set_dataset(dataset.select(*(columns - [:blah])))
|
|
171
171
|
end
|
|
172
172
|
class ::StiTest4 < ::StiTest3; end
|
|
173
|
-
StiTest3.dataset
|
|
173
|
+
StiTest3.dataset = StiTest3.dataset.with_fetch(:id=>1, :kind=>'StiTest4')
|
|
174
174
|
StiTest3[1].must_equal StiTest4.load(:id=>1, :kind=>'StiTest4')
|
|
175
175
|
end
|
|
176
176
|
|
|
@@ -214,7 +214,7 @@ describe Sequel::Model, "single table inheritance plugin" do
|
|
|
214
214
|
StiTest4.create.kind.must_equal 6
|
|
215
215
|
|
|
216
216
|
class ::StiTest5 < ::StiTest4; end
|
|
217
|
-
StiTest5.create.kind.
|
|
217
|
+
StiTest5.create.kind.must_be_nil
|
|
218
218
|
end
|
|
219
219
|
|
|
220
220
|
it "should infer key_map from model_map if provided as a hash" do
|