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
|
@@ -40,7 +40,7 @@ describe Sequel::Model, "TypecastOnLoad plugin" do
|
|
|
40
40
|
|
|
41
41
|
it "should call setter method with value when automatically reloading the object on creation via insert_select" do
|
|
42
42
|
@c.plugin :typecast_on_load, :b
|
|
43
|
-
@c.dataset.
|
|
43
|
+
@c.dataset = @c.dataset.with_extend{def insert_select(h) insert(h); first end}
|
|
44
44
|
o = @c.new(:b=>"1", :y=>"0")
|
|
45
45
|
o.save.values.must_equal(:id=>1, :b=>1, :y=>"0")
|
|
46
46
|
o.bset.must_equal true
|
|
@@ -3,6 +3,7 @@ require File.join(File.dirname(File.expand_path(__FILE__)), "spec_helper")
|
|
|
3
3
|
describe "Sequel::Plugins::UnlimitedUpdate" do
|
|
4
4
|
before do
|
|
5
5
|
@db = Sequel.mock(:host=>'mysql', :numrows=>1)
|
|
6
|
+
@db.extend_datasets{def quote_identifiers?; false end}
|
|
6
7
|
@c = Class.new(Sequel::Model(@db[:test]))
|
|
7
8
|
@c.columns :id, :name
|
|
8
9
|
@o = @c.load(:id=>1, :name=>'a')
|
|
@@ -5,6 +5,10 @@ describe "Sequel::Plugins::UpdatePrimaryKey" do
|
|
|
5
5
|
@c = Class.new(Sequel::Model(:a))
|
|
6
6
|
@c.plugin :update_primary_key
|
|
7
7
|
@c.columns :a, :b
|
|
8
|
+
def @c.set_dataset(*)
|
|
9
|
+
super
|
|
10
|
+
set_primary_key :a
|
|
11
|
+
end
|
|
8
12
|
@c.set_primary_key :a
|
|
9
13
|
@c.unrestrict_primary_key
|
|
10
14
|
@ds = @c.dataset
|
|
@@ -12,7 +16,7 @@ describe "Sequel::Plugins::UpdatePrimaryKey" do
|
|
|
12
16
|
end
|
|
13
17
|
|
|
14
18
|
it "should handle regular updates" do
|
|
15
|
-
@
|
|
19
|
+
@c.dataset = @c.dataset.with_fetch([[{:a=>1, :b=>3}], [{:a=>1, :b=>4}], [{:a=>1, :b=>4}], [{:a=>1, :b=>5}], [{:a=>1, :b=>5}], [{:a=>1, :b=>6}], [{:a=>1, :b=>6}]])
|
|
16
20
|
@c.first.update(:b=>4)
|
|
17
21
|
@c.all.must_equal [@c.load(:a=>1, :b=>4)]
|
|
18
22
|
DB.sqls.must_equal ["SELECT * FROM a LIMIT 1", "UPDATE a SET b = 4 WHERE (a = 1)", "SELECT * FROM a"]
|
|
@@ -25,7 +29,7 @@ describe "Sequel::Plugins::UpdatePrimaryKey" do
|
|
|
25
29
|
end
|
|
26
30
|
|
|
27
31
|
it "should handle updating the primary key field with another field" do
|
|
28
|
-
@
|
|
32
|
+
@c.dataset = @c.dataset.with_fetch([[{:a=>1, :b=>3}], [{:a=>2, :b=>4}]])
|
|
29
33
|
@c.first.update(:a=>2, :b=>4)
|
|
30
34
|
@c.all.must_equal [@c.load(:a=>2, :b=>4)]
|
|
31
35
|
sqls = DB.sqls
|
|
@@ -34,7 +38,7 @@ describe "Sequel::Plugins::UpdatePrimaryKey" do
|
|
|
34
38
|
end
|
|
35
39
|
|
|
36
40
|
it "should handle updating just the primary key field when saving changes" do
|
|
37
|
-
@
|
|
41
|
+
@c.dataset = @c.dataset.with_fetch([[{:a=>1, :b=>3}], [{:a=>2, :b=>3}], [{:a=>2, :b=>3}], [{:a=>3, :b=>3}]])
|
|
38
42
|
@c.first.update(:a=>2)
|
|
39
43
|
@c.all.must_equal [@c.load(:a=>2, :b=>3)]
|
|
40
44
|
DB.sqls.must_equal ["SELECT * FROM a LIMIT 1", "UPDATE a SET a = 2 WHERE (a = 1)", "SELECT * FROM a"]
|
|
@@ -44,7 +48,7 @@ describe "Sequel::Plugins::UpdatePrimaryKey" do
|
|
|
44
48
|
end
|
|
45
49
|
|
|
46
50
|
it "should handle saving after modifying the primary key field with another field" do
|
|
47
|
-
@
|
|
51
|
+
@c.dataset = @c.dataset.with_fetch([[{:a=>1, :b=>3}], [{:a=>2, :b=>4}]])
|
|
48
52
|
@c.first.set(:a=>2, :b=>4).save
|
|
49
53
|
@c.all.must_equal [@c.load(:a=>2, :b=>4)]
|
|
50
54
|
sqls = DB.sqls
|
|
@@ -53,7 +57,7 @@ describe "Sequel::Plugins::UpdatePrimaryKey" do
|
|
|
53
57
|
end
|
|
54
58
|
|
|
55
59
|
it "should handle saving after modifying just the primary key field" do
|
|
56
|
-
@
|
|
60
|
+
@c.dataset = @c.dataset.with_fetch([[{:a=>1, :b=>3}], [{:a=>2, :b=>3}]])
|
|
57
61
|
@c.first.set(:a=>2).save
|
|
58
62
|
@c.all.must_equal [@c.load(:a=>2, :b=>3)]
|
|
59
63
|
sqls = DB.sqls
|
|
@@ -62,7 +66,7 @@ describe "Sequel::Plugins::UpdatePrimaryKey" do
|
|
|
62
66
|
end
|
|
63
67
|
|
|
64
68
|
it "should handle saving after updating the primary key" do
|
|
65
|
-
@
|
|
69
|
+
@c.dataset = @c.dataset.with_fetch([[{:a=>1, :b=>3}], [{:a=>2, :b=>5}]])
|
|
66
70
|
@c.first.update(:a=>2).update(:b=>4).set(:b=>5).save
|
|
67
71
|
@c.all.must_equal [@c.load(:a=>2, :b=>5)]
|
|
68
72
|
DB.sqls.must_equal ["SELECT * FROM a LIMIT 1", "UPDATE a SET a = 2 WHERE (a = 1)", "UPDATE a SET b = 4 WHERE (a = 2)", "UPDATE a SET b = 5 WHERE (a = 2)", "SELECT * FROM a"]
|
|
@@ -70,7 +74,7 @@ describe "Sequel::Plugins::UpdatePrimaryKey" do
|
|
|
70
74
|
|
|
71
75
|
it "should work correctly when using the prepared_statements plugin" do
|
|
72
76
|
@c.plugin :prepared_statements
|
|
73
|
-
@
|
|
77
|
+
@c.dataset = @c.dataset.with_fetch([[{:a=>1, :b=>3}], [{:a=>2, :b=>4}]])
|
|
74
78
|
o = @c.first
|
|
75
79
|
o.update(:a=>2, :b=>4)
|
|
76
80
|
@c.all.must_equal [@c.load(:a=>2, :b=>4)]
|
|
@@ -45,7 +45,7 @@ describe "Sequel::Plugins::UpdateRefresh" do
|
|
|
45
45
|
@c.dataset = @db[:test].select(:id, :name)
|
|
46
46
|
@db.sqls
|
|
47
47
|
o = @c.load(:id=>1, :name=>'a')
|
|
48
|
-
o.this.
|
|
48
|
+
o.instance_variable_set(:@this, o.this.returning(:id, :name))
|
|
49
49
|
o.save
|
|
50
50
|
@db.sqls.must_equal ["UPDATE test SET name = 'a' WHERE (id = 1) RETURNING id, name"]
|
|
51
51
|
o.name.must_equal 'b'
|
|
@@ -16,7 +16,7 @@ describe "ValidatesAssociated plugin" do
|
|
|
16
16
|
@c.send(:define_method, :validate){|*| errors.add(:name, 'is b') if name == 'b'}
|
|
17
17
|
o = @c.load(:id=>2, :name=>'b')
|
|
18
18
|
@o.send(:delay_validate_associated_object, @c.association_reflection(:cs), o)
|
|
19
|
-
@o.save.
|
|
19
|
+
@o.save.must_be_nil
|
|
20
20
|
@o.errors[:cs].must_equal ["name is b"]
|
|
21
21
|
o.errors[:name].must_equal ['is b']
|
|
22
22
|
end
|
|
@@ -100,8 +100,8 @@ describe Sequel::Model do
|
|
|
100
100
|
atts = nil
|
|
101
101
|
o.values.clear
|
|
102
102
|
o.valid?.must_equal true
|
|
103
|
-
vals.
|
|
104
|
-
atts.
|
|
103
|
+
vals.must_be_nil
|
|
104
|
+
atts.must_be_nil
|
|
105
105
|
end
|
|
106
106
|
|
|
107
107
|
it "should overwrite existing validation with the same tag and attribute" do
|
|
@@ -175,7 +175,7 @@ describe Sequel::Model do
|
|
|
175
175
|
@o.score = 86
|
|
176
176
|
@o.wont_be :valid?
|
|
177
177
|
@o.errors[:score].must_equal ['too low']
|
|
178
|
-
@o.errors.on(:blah).
|
|
178
|
+
@o.errors.on(:blah).must_be_nil
|
|
179
179
|
end
|
|
180
180
|
end
|
|
181
181
|
|
|
@@ -203,7 +203,7 @@ describe Sequel::Model do
|
|
|
203
203
|
@c = model_class.call Sequel::Model do
|
|
204
204
|
columns :value
|
|
205
205
|
|
|
206
|
-
def self.
|
|
206
|
+
def self.where(*args)
|
|
207
207
|
o = Object.new
|
|
208
208
|
def o.count; 2; end
|
|
209
209
|
o
|
|
@@ -620,7 +620,7 @@ describe "Superclass validations" do
|
|
|
620
620
|
end
|
|
621
621
|
|
|
622
622
|
it "should have skip_superclass_validations? return whether superclass validations were skipped" do
|
|
623
|
-
@c2.skip_superclass_validations?.
|
|
623
|
+
@c2.skip_superclass_validations?.must_be_nil
|
|
624
624
|
@c2.skip_superclass_validations
|
|
625
625
|
@c2.skip_superclass_validations?.must_equal true
|
|
626
626
|
end
|
|
@@ -829,7 +829,7 @@ describe Sequel::Model, "Validations" do
|
|
|
829
829
|
uniqueness_of :username
|
|
830
830
|
end
|
|
831
831
|
end
|
|
832
|
-
User.dataset
|
|
832
|
+
User.dataset = User.dataset.with_fetch(proc do |sql|
|
|
833
833
|
case sql
|
|
834
834
|
when /count.*username = '0records'/
|
|
835
835
|
{:v => 0}
|
|
@@ -840,7 +840,7 @@ describe Sequel::Model, "Validations" do
|
|
|
840
840
|
when /username = '1record'/
|
|
841
841
|
{:id => 3, :username => "1record", :password => "test"}
|
|
842
842
|
end
|
|
843
|
-
end
|
|
843
|
+
end)
|
|
844
844
|
|
|
845
845
|
@user = User.new(:username => "2records", :password => "anothertest")
|
|
846
846
|
@user.wont_be :valid?
|
|
@@ -876,7 +876,7 @@ describe Sequel::Model, "Validations" do
|
|
|
876
876
|
uniqueness_of [:username, :password]
|
|
877
877
|
end
|
|
878
878
|
end
|
|
879
|
-
User.dataset
|
|
879
|
+
User.dataset = User.dataset.with_fetch(proc do |sql|
|
|
880
880
|
case sql
|
|
881
881
|
when /count.*username = '0records'/
|
|
882
882
|
{:v => 0}
|
|
@@ -891,7 +891,7 @@ describe Sequel::Model, "Validations" do
|
|
|
891
891
|
{:id => 4, :username => "1record", :password => "test"}
|
|
892
892
|
end
|
|
893
893
|
end
|
|
894
|
-
end
|
|
894
|
+
end)
|
|
895
895
|
|
|
896
896
|
@user = User.new(:username => "2records", :password => "anothertest")
|
|
897
897
|
@user.wont_be :valid?
|
|
@@ -1022,6 +1022,6 @@ describe "Model#save" do
|
|
|
1022
1022
|
|
|
1023
1023
|
it "should return nil if validations fail and raise_on_save_faiure is false" do
|
|
1024
1024
|
@m.raise_on_save_failure = false
|
|
1025
|
-
@m.save.
|
|
1025
|
+
@m.save.must_be_nil
|
|
1026
1026
|
end
|
|
1027
1027
|
end
|
|
@@ -365,14 +365,14 @@ describe "Sequel::Plugins::ValidationHelpers" do
|
|
|
365
365
|
@c.columns(:id, :username, :password)
|
|
366
366
|
@c.set_dataset DB[:items]
|
|
367
367
|
@c.set_validations{validates_unique(:username)}
|
|
368
|
-
@c.dataset
|
|
368
|
+
@c.dataset = @c.dataset.with_fetch(proc do |sql|
|
|
369
369
|
case sql
|
|
370
370
|
when /count.*username = '0records'/
|
|
371
371
|
{:v => 0}
|
|
372
372
|
when /count.*username = '1record'/
|
|
373
373
|
{:v => 1}
|
|
374
374
|
end
|
|
375
|
-
end
|
|
375
|
+
end)
|
|
376
376
|
|
|
377
377
|
@user = @c.new(:username => "0records", :password => "anothertest")
|
|
378
378
|
@user.must_be :valid?
|
|
@@ -403,14 +403,14 @@ describe "Sequel::Plugins::ValidationHelpers" do
|
|
|
403
403
|
@c.columns(:id, :username, :password)
|
|
404
404
|
@c.set_dataset DB[:items]
|
|
405
405
|
@c.set_validations{validates_unique([:username, :password])}
|
|
406
|
-
@c.dataset
|
|
406
|
+
@c.dataset = @c.dataset.with_fetch(proc do |sql|
|
|
407
407
|
case sql
|
|
408
408
|
when /count.*username = '0records'/
|
|
409
409
|
{:v => 0}
|
|
410
410
|
when /count.*username = '1record'/
|
|
411
411
|
{:v => 1}
|
|
412
412
|
end
|
|
413
|
-
end
|
|
413
|
+
end)
|
|
414
414
|
|
|
415
415
|
@user = @c.new(:username => "0records", :password => "anothertest")
|
|
416
416
|
@user.must_be :valid?
|
|
@@ -448,7 +448,7 @@ describe "Sequel::Plugins::ValidationHelpers" do
|
|
|
448
448
|
@c.columns(:id, :username, :password)
|
|
449
449
|
@c.set_dataset DB[:items]
|
|
450
450
|
@c.set_validations{validates_unique(:username){|ds| ds.filter(:active)}}
|
|
451
|
-
@c.dataset
|
|
451
|
+
@c.dataset = @c.dataset.with_fetch(:v=>0)
|
|
452
452
|
|
|
453
453
|
DB.reset
|
|
454
454
|
@c.new(:username => "0records", :password => "anothertest").must_be :valid?
|
|
@@ -461,7 +461,7 @@ describe "Sequel::Plugins::ValidationHelpers" do
|
|
|
461
461
|
@c.columns(:id, :username, :password)
|
|
462
462
|
@c.set_dataset DB[:items]
|
|
463
463
|
@c.set_validations{validates_unique(:username, :where=>proc{|ds, obj, cols| ds.where(cols.map{|c| [Sequel.function(:lower, c), obj.send(c).downcase]})})}
|
|
464
|
-
@c.dataset
|
|
464
|
+
@c.dataset = @c.dataset.with_fetch(:v=>0)
|
|
465
465
|
|
|
466
466
|
DB.reset
|
|
467
467
|
@c.new(:username => "0RECORDS", :password => "anothertest").must_be :valid?
|
|
@@ -475,7 +475,7 @@ describe "Sequel::Plugins::ValidationHelpers" do
|
|
|
475
475
|
@c.set_dataset DB[:items]
|
|
476
476
|
c = @c
|
|
477
477
|
@c.set_validations{validates_unique(:username, :dataset=>c.where(:a=>[1,2,3]))}
|
|
478
|
-
@c.dataset
|
|
478
|
+
@c.dataset = @c.dataset.with_fetch(:v=>0)
|
|
479
479
|
|
|
480
480
|
DB.reset
|
|
481
481
|
@c.new(:username => "0records", :password => "anothertest").must_be :valid?
|
|
@@ -489,7 +489,7 @@ describe "Sequel::Plugins::ValidationHelpers" do
|
|
|
489
489
|
@c.set_dataset DB[:items]
|
|
490
490
|
c = @c
|
|
491
491
|
@c.set_validations{validates_unique(:username, :dataset=>c.cross_join(:a))}
|
|
492
|
-
@c.dataset
|
|
492
|
+
@c.dataset = @c.dataset.with_fetch(:v=>0)
|
|
493
493
|
|
|
494
494
|
DB.reset
|
|
495
495
|
@c.new(:username => "0records", :password => "anothertest").must_be :valid?
|
|
@@ -502,7 +502,7 @@ describe "Sequel::Plugins::ValidationHelpers" do
|
|
|
502
502
|
@c.columns(:id, :username, :password)
|
|
503
503
|
@c.set_dataset DB[:items]
|
|
504
504
|
@c.set_validations{validates_unique([:username, :password], :only_if_modified=>true)}
|
|
505
|
-
@c.dataset
|
|
505
|
+
@c.dataset = @c.dataset.with_fetch(:v=>0)
|
|
506
506
|
|
|
507
507
|
DB.reset
|
|
508
508
|
@c.new(:username => "0records", :password => "anothertest").must_be :valid?
|
|
@@ -531,7 +531,7 @@ describe "Sequel::Plugins::ValidationHelpers" do
|
|
|
531
531
|
@c.columns(:id, :username, :password)
|
|
532
532
|
@c.set_dataset DB[:items]
|
|
533
533
|
@c.set_validations{errors.add(:username, 'foo'); validates_unique([:username, :password])}
|
|
534
|
-
@c.dataset
|
|
534
|
+
@c.dataset = @c.dataset.with_fetch(:v=>0)
|
|
535
535
|
|
|
536
536
|
DB.reset
|
|
537
537
|
m = @c.new(:username => "1", :password => "anothertest")
|
|
@@ -19,7 +19,11 @@ describe "Sequel::Plugins::XmlSerializer" do
|
|
|
19
19
|
attr_accessor :blah
|
|
20
20
|
plugin :xml_serializer
|
|
21
21
|
columns :id, :name, :artist_id
|
|
22
|
-
@db_schema = {:id=>{:type=>:integer}, :name=>{:type=>:string}, :artist_id=>{:type=>:integer}}
|
|
22
|
+
@db_schema2 = @db_schema = {:id=>{:type=>:integer}, :name=>{:type=>:string}, :artist_id=>{:type=>:integer}}
|
|
23
|
+
def self.set_dataset(*)
|
|
24
|
+
super
|
|
25
|
+
@db_schema = @db_schema2
|
|
26
|
+
end
|
|
23
27
|
many_to_one :artist
|
|
24
28
|
end
|
|
25
29
|
@artist = Artist.load(:id=>2, :name=>'YJM')
|
|
@@ -142,7 +146,7 @@ describe "Sequel::Plugins::XmlSerializer" do
|
|
|
142
146
|
|
|
143
147
|
it "should support an :array_root_name option when serializing arrays" do
|
|
144
148
|
artist = @artist
|
|
145
|
-
Artist.dataset.
|
|
149
|
+
Artist.dataset = Artist.dataset.with_extend{define_method(:all){[artist]}}
|
|
146
150
|
["<?xml version=\"1.0\"?><ars><ar><id>2</id><name>YJM</name></ar></ars>",
|
|
147
151
|
"<?xml version=\"1.0\"?><ars><ar><name>YJM</name><id>2</id></ar></ars>"].must_include(Artist.to_xml(:array_root_name=>'ars', :root_name=>'ar').gsub(/\n */m, ''))
|
|
148
152
|
end
|
|
@@ -154,7 +158,7 @@ describe "Sequel::Plugins::XmlSerializer" do
|
|
|
154
158
|
|
|
155
159
|
it "should support a to_xml class and dataset method" do
|
|
156
160
|
album = @album
|
|
157
|
-
Album.dataset.
|
|
161
|
+
Album.dataset = Album.dataset.with_extend{define_method(:all){[album]}}
|
|
158
162
|
Album.array_from_xml(Album.to_xml).must_equal [@album]
|
|
159
163
|
Album.array_from_xml(Album.to_xml(:include=>:artist), :associations=>:artist).map{|x| x.artist}.must_equal [@artist]
|
|
160
164
|
Album.array_from_xml(Album.dataset.to_xml(:only=>:name)).must_equal [Album.load(:name=>@album.name)]
|
|
@@ -14,9 +14,9 @@ OneToOneEagerLimitStrategies = shared_description do
|
|
|
14
14
|
a.first.first_album.must_equal @album
|
|
15
15
|
a.first.last_album.must_equal diff_album
|
|
16
16
|
a.first.second_album.must_equal diff_album
|
|
17
|
-
a.last.first_album.
|
|
18
|
-
a.last.last_album.
|
|
19
|
-
a.last.second_album.
|
|
17
|
+
a.last.first_album.must_be_nil
|
|
18
|
+
a.last.last_album.must_be_nil
|
|
19
|
+
a.last.second_album.must_be_nil
|
|
20
20
|
|
|
21
21
|
# Check that no extra columns got added by the eager loading
|
|
22
22
|
a.first.first_album.values.must_equal @album.values
|
|
@@ -27,7 +27,7 @@ OneToOneEagerLimitStrategies = shared_description do
|
|
|
27
27
|
a = Artist.eager(:first_album).order(:name).all
|
|
28
28
|
a.must_equal [@artist, ar]
|
|
29
29
|
[@album, same_album].must_include(a.first.first_album)
|
|
30
|
-
a.last.first_album.
|
|
30
|
+
a.last.first_album.must_be_nil
|
|
31
31
|
end
|
|
32
32
|
end
|
|
33
33
|
|
|
@@ -42,14 +42,14 @@ OneToOneEagerGraphLimitStrategies = shared_description do
|
|
|
42
42
|
a = ds.eager_graph_with_options(:first_album, limit_strategy).all
|
|
43
43
|
a.must_equal [@artist, ar]
|
|
44
44
|
a.first.first_album.must_equal @album
|
|
45
|
-
a.last.first_album.
|
|
45
|
+
a.last.first_album.must_be_nil
|
|
46
46
|
a.first.first_album.values.must_equal @album.values
|
|
47
47
|
|
|
48
48
|
a = ds.eager_graph_with_options(:last_album, limit_strategy).all
|
|
49
49
|
a = ds.eager_graph(:last_album).all
|
|
50
50
|
a.must_equal [@artist, ar]
|
|
51
51
|
a.first.last_album.must_equal diff_album
|
|
52
|
-
a.last.last_album.
|
|
52
|
+
a.last.last_album.must_be_nil
|
|
53
53
|
a.first.last_album.values.must_equal diff_album.values
|
|
54
54
|
|
|
55
55
|
if @els[:eager_limit_strategy] != :distinct_on && (@els[:eager_limit_strategy] != :correlated_subquery || Album.dataset.supports_offsets_in_correlated_subqueries?)
|
|
@@ -57,7 +57,7 @@ OneToOneEagerGraphLimitStrategies = shared_description do
|
|
|
57
57
|
a = ds.eager_graph(:second_album).all
|
|
58
58
|
a.must_equal [@artist, ar]
|
|
59
59
|
a.first.second_album.must_equal diff_album
|
|
60
|
-
a.last.second_album.
|
|
60
|
+
a.last.second_album.must_be_nil
|
|
61
61
|
a.first.second_album.values.must_equal diff_album.values
|
|
62
62
|
end
|
|
63
63
|
|
|
@@ -65,7 +65,7 @@ OneToOneEagerGraphLimitStrategies = shared_description do
|
|
|
65
65
|
a = ds.eager_graph_with_options(:first_album, limit_strategy).all
|
|
66
66
|
a.must_equal [@artist, ar]
|
|
67
67
|
[@album, same_album].must_include(a.first.first_album)
|
|
68
|
-
a.last.first_album.
|
|
68
|
+
a.last.first_album.must_be_nil
|
|
69
69
|
end
|
|
70
70
|
end
|
|
71
71
|
|
|
@@ -149,9 +149,9 @@ OneThroughOneEagerLimitStrategies = shared_description do
|
|
|
149
149
|
als.first.first_tag.must_equal @tag
|
|
150
150
|
als.first.second_tag.must_equal tu
|
|
151
151
|
als.first.last_tag.must_equal tv
|
|
152
|
-
als.last.first_tag.
|
|
153
|
-
als.last.second_tag.
|
|
154
|
-
als.last.last_tag.
|
|
152
|
+
als.last.first_tag.must_be_nil
|
|
153
|
+
als.last.second_tag.must_be_nil
|
|
154
|
+
als.last.last_tag.must_be_nil
|
|
155
155
|
|
|
156
156
|
# Check that no extra columns got added by the eager loading
|
|
157
157
|
als.first.first_tag.values.must_equal @tag.values
|
|
@@ -170,19 +170,19 @@ OneThroughOneEagerGraphLimitStrategies = shared_description do
|
|
|
170
170
|
als = ds.eager_graph_with_options(:first_tag, limit_strategy).all
|
|
171
171
|
als.must_equal [@album, al]
|
|
172
172
|
als.first.first_tag.must_equal @tag
|
|
173
|
-
als.last.first_tag.
|
|
173
|
+
als.last.first_tag.must_be_nil
|
|
174
174
|
als.first.first_tag.values.must_equal @tag.values
|
|
175
175
|
|
|
176
176
|
als = ds.eager_graph_with_options(:second_tag, @els[:eager_limit_strategy] != :distinct_on ? limit_strategy : {}).all
|
|
177
177
|
als.must_equal [@album, al]
|
|
178
178
|
als.first.second_tag.must_equal tu
|
|
179
|
-
als.last.second_tag.
|
|
179
|
+
als.last.second_tag.must_be_nil
|
|
180
180
|
als.first.second_tag.values.must_equal tu.values
|
|
181
181
|
|
|
182
182
|
als = ds.eager_graph_with_options(:last_tag, limit_strategy).all
|
|
183
183
|
als.must_equal [@album, al]
|
|
184
184
|
als.first.last_tag.must_equal tv
|
|
185
|
-
als.last.last_tag.
|
|
185
|
+
als.last.last_tag.must_be_nil
|
|
186
186
|
als.first.last_tag.values.must_equal tv.values
|
|
187
187
|
end
|
|
188
188
|
end
|
|
@@ -333,7 +333,7 @@ OneThroughManyEagerLimitStrategies = shared_description do
|
|
|
333
333
|
ars.first.second_tag.must_equal tu
|
|
334
334
|
ars.first.last_tag.must_equal tv
|
|
335
335
|
ars.last.first_tag.must_equal tu
|
|
336
|
-
ars.last.second_tag.
|
|
336
|
+
ars.last.second_tag.must_be_nil
|
|
337
337
|
ars.last.last_tag.must_equal tu
|
|
338
338
|
|
|
339
339
|
# Check that no extra columns got added by the eager loading
|
|
@@ -362,7 +362,7 @@ OneThroughManyEagerGraphLimitStrategies = shared_description do
|
|
|
362
362
|
ars = ds.eager_graph_with_options(:second_tag, @els[:eager_limit_strategy] != :distinct_on ? limit_strategy : {}).all
|
|
363
363
|
ars.must_equal [@artist, ar]
|
|
364
364
|
ars.first.second_tag.must_equal tu
|
|
365
|
-
ars.last.second_tag.
|
|
365
|
+
ars.last.second_tag.must_be_nil
|
|
366
366
|
ars.first.second_tag.values.must_equal tu.values
|
|
367
367
|
|
|
368
368
|
ars = ds.eager_graph_with_options(:last_tag, limit_strategy).all
|
|
@@ -1495,10 +1495,10 @@ BasicRegularAndCompositeKeyAssociations = shared_description do
|
|
|
1495
1495
|
end
|
|
1496
1496
|
|
|
1497
1497
|
it "should return no objects if none are associated" do
|
|
1498
|
-
@album.artist.
|
|
1499
|
-
@album.artist_dataset.first.
|
|
1500
|
-
@artist.first_album.
|
|
1501
|
-
@artist.first_album_dataset.first.
|
|
1498
|
+
@album.artist.must_be_nil
|
|
1499
|
+
@album.artist_dataset.first.must_be_nil
|
|
1500
|
+
@artist.first_album.must_be_nil
|
|
1501
|
+
@artist.first_album_dataset.first.must_be_nil
|
|
1502
1502
|
@artist.albums.must_equal []
|
|
1503
1503
|
@artist.albums_dataset.all.must_equal []
|
|
1504
1504
|
@album.tags.must_equal []
|
|
@@ -1508,8 +1508,8 @@ BasicRegularAndCompositeKeyAssociations = shared_description do
|
|
|
1508
1508
|
@tag.albums.must_equal []
|
|
1509
1509
|
@tag.albums_dataset.all.must_equal []
|
|
1510
1510
|
unless @no_many_through_many
|
|
1511
|
-
@album.first_tag.
|
|
1512
|
-
@album.first_tag_dataset.first.
|
|
1511
|
+
@album.first_tag.must_be_nil
|
|
1512
|
+
@album.first_tag_dataset.first.must_be_nil
|
|
1513
1513
|
end
|
|
1514
1514
|
end
|
|
1515
1515
|
|
|
@@ -1518,13 +1518,13 @@ BasicRegularAndCompositeKeyAssociations = shared_description do
|
|
|
1518
1518
|
@album.update(:artist => @artist)
|
|
1519
1519
|
@album.reload.artist.must_equal @artist
|
|
1520
1520
|
@album.update(:artist => nil)
|
|
1521
|
-
@album.reload.artist.
|
|
1521
|
+
@album.reload.artist.must_be_nil
|
|
1522
1522
|
|
|
1523
1523
|
# one to one
|
|
1524
1524
|
@artist.update(:first_album => @album)
|
|
1525
1525
|
@artist.reload.first_album.must_equal @album
|
|
1526
1526
|
@artist.update(:first_album => nil)
|
|
1527
|
-
@artist.reload.first_album.
|
|
1527
|
+
@artist.reload.first_album.must_be_nil
|
|
1528
1528
|
|
|
1529
1529
|
unless @no_many_through_many
|
|
1530
1530
|
tag = @pr.call.last
|
|
@@ -1536,15 +1536,15 @@ BasicRegularAndCompositeKeyAssociations = shared_description do
|
|
|
1536
1536
|
@album.update(:first_tag => tag)
|
|
1537
1537
|
@album.reload.first_tag.must_equal tag
|
|
1538
1538
|
@album.update(:first_tag => nil)
|
|
1539
|
-
@album.reload.first_tag.
|
|
1539
|
+
@album.reload.first_tag.must_be_nil
|
|
1540
1540
|
@album.update(:first_tag => nil)
|
|
1541
|
-
@album.reload.first_tag.
|
|
1541
|
+
@album.reload.first_tag.must_be_nil
|
|
1542
1542
|
|
|
1543
1543
|
# one through one with alias
|
|
1544
1544
|
@album.update(:alias_t_tag => @tag)
|
|
1545
1545
|
@album.reload.alias_t_tag.must_equal @tag
|
|
1546
1546
|
@album.update(:alias_t_tag => nil)
|
|
1547
|
-
@album.reload.alias_t_tag.
|
|
1547
|
+
@album.reload.alias_t_tag.must_be_nil
|
|
1548
1548
|
end
|
|
1549
1549
|
end
|
|
1550
1550
|
|
|
@@ -2041,12 +2041,12 @@ describe "Sequel::Model Simple Associations" do
|
|
|
2041
2041
|
@artist.albums(proc{|ds| ds.filter(:id=>@album.id)}).must_equal [@album]
|
|
2042
2042
|
|
|
2043
2043
|
@album.artist.must_equal @artist
|
|
2044
|
-
@album.artist(proc{|ds| ds.exclude(:id=>@artist.id)}).
|
|
2044
|
+
@album.artist(proc{|ds| ds.exclude(:id=>@artist.id)}).must_be_nil
|
|
2045
2045
|
@album.artist(proc{|ds| ds.filter(:id=>@artist.id)}).must_equal @artist
|
|
2046
2046
|
|
|
2047
2047
|
@artist.albums{|ds| ds.exclude(:id=>@album.id)}.must_equal []
|
|
2048
2048
|
@artist.albums{|ds| ds.filter(:id=>@album.id)}.must_equal [@album]
|
|
2049
|
-
@album.artist{|ds| ds.exclude(:id=>@artist.id)}.
|
|
2049
|
+
@album.artist{|ds| ds.exclude(:id=>@artist.id)}.must_be_nil
|
|
2050
2050
|
@album.artist{|ds| ds.filter(:id=>@artist.id)}.must_equal @artist
|
|
2051
2051
|
end
|
|
2052
2052
|
|
|
@@ -2082,8 +2082,8 @@ describe "Sequel::Model Simple Associations" do
|
|
|
2082
2082
|
Album.many_to_many :tags, :right_key=>:tag_id, :select=>[Sequel.expr(:tags).*, Sequel[:albums_tags][:tag_id].as(:atid)], :dataset_associations_join=>true
|
|
2083
2083
|
Artist.many_through_many :tags, [[:albums, :artist_id, :id], [:albums_tags, :album_id, :tag_id]], :select=>[Sequel.expr(:tags).*, Sequel[:albums_tags][:tag_id].as(:atid), Sequel[:albums][:artist_id].as(:aid)], :dataset_associations_join=>true
|
|
2084
2084
|
|
|
2085
|
-
Album.tags.order(Sequel[:tags][:name]).first.
|
|
2086
|
-
Artist.tags.order(Sequel[:tags][:name]).first.
|
|
2085
|
+
Album.tags.order(Sequel[:tags][:name]).first.must_be_nil
|
|
2086
|
+
Artist.tags.order(Sequel[:tags][:name]).first.must_be_nil
|
|
2087
2087
|
|
|
2088
2088
|
@album.add_tag(@tag)
|
|
2089
2089
|
@artist.add_album(@album)
|