sequel 4.22.0 → 4.23.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 +22 -0
- data/README.rdoc +6 -0
- data/Rakefile +59 -81
- data/doc/migration.rdoc +2 -0
- data/doc/release_notes/4.23.0.txt +65 -0
- data/doc/sharding.rdoc +16 -14
- data/doc/testing.rdoc +61 -77
- data/lib/sequel/adapters/jdbc.rb +1 -0
- data/lib/sequel/adapters/mock.rb +0 -1
- data/lib/sequel/adapters/postgres.rb +1 -0
- data/lib/sequel/adapters/postgresql.rb +1 -0
- data/lib/sequel/adapters/shared/postgres.rb +3 -3
- data/lib/sequel/connection_pool/sharded_threaded.rb +5 -0
- data/lib/sequel/connection_pool/threaded.rb +9 -1
- data/lib/sequel/database/connecting.rb +1 -1
- data/lib/sequel/database/transactions.rb +2 -1
- data/lib/sequel/dataset/prepared_statements.rb +1 -1
- data/lib/sequel/extensions/constraint_validations.rb +12 -12
- data/lib/sequel/extensions/date_arithmetic.rb +0 -4
- data/lib/sequel/extensions/pagination.rb +14 -2
- data/lib/sequel/extensions/pg_enum.rb +2 -2
- data/lib/sequel/extensions/pg_hstore.rb +1 -1
- data/lib/sequel/extensions/pg_json_ops.rb +2 -2
- data/lib/sequel/plugins/csv_serializer.rb +2 -0
- data/lib/sequel/plugins/delay_add_association.rb +50 -0
- data/lib/sequel/plugins/list.rb +2 -2
- data/lib/sequel/plugins/nested_attributes.rb +8 -28
- data/lib/sequel/plugins/update_refresh.rb +50 -0
- data/lib/sequel/plugins/validate_associated.rb +55 -0
- data/lib/sequel/version.rb +1 -1
- data/spec/adapters/db2_spec.rb +29 -29
- data/spec/adapters/firebird_spec.rb +97 -103
- data/spec/adapters/informix_spec.rb +25 -25
- data/spec/adapters/mssql_spec.rb +156 -172
- data/spec/adapters/mysql_spec.rb +334 -359
- data/spec/adapters/oracle_spec.rb +67 -69
- data/spec/adapters/postgres_spec.rb +1298 -1249
- data/spec/adapters/spec_helper.rb +2 -35
- data/spec/adapters/sqlanywhere_spec.rb +39 -39
- data/spec/adapters/sqlite_spec.rb +203 -200
- data/spec/bin_spec.rb +57 -59
- data/spec/core/connection_pool_spec.rb +402 -401
- data/spec/core/database_spec.rb +953 -944
- data/spec/core/dataset_spec.rb +2178 -2168
- data/spec/core/deprecated_spec.rb +19 -19
- data/spec/core/expression_filters_spec.rb +415 -415
- data/spec/core/mock_adapter_spec.rb +212 -212
- data/spec/core/object_graph_spec.rb +73 -73
- data/spec/core/placeholder_literalizer_spec.rb +71 -71
- data/spec/core/schema_generator_spec.rb +44 -44
- data/spec/core/schema_spec.rb +470 -472
- data/spec/core/spec_helper.rb +5 -20
- data/spec/core/version_spec.rb +2 -2
- data/spec/core_extensions_spec.rb +320 -320
- data/spec/extensions/accessed_columns_spec.rb +12 -12
- data/spec/extensions/active_model_spec.rb +3 -3
- data/spec/extensions/after_initialize_spec.rb +2 -2
- data/spec/extensions/arbitrary_servers_spec.rb +23 -23
- data/spec/extensions/association_dependencies_spec.rb +34 -34
- data/spec/extensions/association_pks_spec.rb +98 -98
- data/spec/extensions/association_proxies_spec.rb +33 -33
- data/spec/extensions/auto_validations_spec.rb +46 -46
- data/spec/extensions/blacklist_security_spec.rb +19 -18
- data/spec/extensions/blank_spec.rb +36 -36
- data/spec/extensions/boolean_readers_spec.rb +36 -36
- data/spec/extensions/caching_spec.rb +82 -82
- data/spec/extensions/class_table_inheritance_spec.rb +72 -72
- data/spec/extensions/column_conflicts_spec.rb +19 -14
- data/spec/extensions/column_select_spec.rb +19 -19
- data/spec/extensions/columns_introspection_spec.rb +43 -43
- data/spec/extensions/composition_spec.rb +64 -64
- data/spec/extensions/connection_validator_spec.rb +92 -90
- data/spec/extensions/constraint_validations_plugin_spec.rb +92 -92
- data/spec/extensions/constraint_validations_spec.rb +80 -80
- data/spec/extensions/core_refinements_spec.rb +220 -220
- data/spec/extensions/csv_serializer_spec.rb +44 -44
- data/spec/extensions/current_datetime_timestamp_spec.rb +8 -8
- data/spec/extensions/dataset_associations_spec.rb +65 -65
- data/spec/extensions/dataset_source_alias_spec.rb +16 -16
- data/spec/extensions/date_arithmetic_spec.rb +51 -58
- data/spec/extensions/defaults_setter_spec.rb +19 -19
- data/spec/extensions/delay_add_association_spec.rb +52 -0
- data/spec/extensions/dirty_spec.rb +51 -51
- data/spec/extensions/eager_each_spec.rb +8 -8
- data/spec/extensions/empty_array_ignore_nulls_spec.rb +10 -10
- data/spec/extensions/error_splitter_spec.rb +2 -2
- data/spec/extensions/error_sql_spec.rb +4 -4
- data/spec/extensions/eval_inspect_spec.rb +3 -3
- data/spec/extensions/filter_having_spec.rb +8 -8
- data/spec/extensions/force_encoding_spec.rb +30 -30
- data/spec/extensions/from_block_spec.rb +7 -7
- data/spec/extensions/graph_each_spec.rb +19 -19
- data/spec/extensions/hash_aliases_spec.rb +5 -5
- data/spec/extensions/hook_class_methods_spec.rb +100 -100
- data/spec/extensions/inflector_spec.rb +54 -54
- data/spec/extensions/input_transformer_spec.rb +10 -10
- data/spec/extensions/insert_returning_select_spec.rb +8 -8
- data/spec/extensions/instance_filters_spec.rb +26 -26
- data/spec/extensions/instance_hooks_spec.rb +85 -85
- data/spec/extensions/json_serializer_spec.rb +68 -68
- data/spec/extensions/lazy_attributes_spec.rb +49 -49
- data/spec/extensions/list_spec.rb +77 -75
- data/spec/extensions/looser_typecasting_spec.rb +16 -16
- data/spec/extensions/many_through_many_spec.rb +627 -627
- data/spec/extensions/meta_def_spec.rb +7 -7
- data/spec/extensions/migration_spec.rb +217 -217
- data/spec/extensions/modification_detection_spec.rb +20 -20
- data/spec/extensions/mssql_optimistic_locking_spec.rb +21 -21
- data/spec/extensions/named_timezones_spec.rb +18 -18
- data/spec/extensions/nested_attributes_spec.rb +107 -107
- data/spec/extensions/null_dataset_spec.rb +24 -24
- data/spec/extensions/optimistic_locking_spec.rb +21 -21
- data/spec/extensions/pagination_spec.rb +52 -52
- data/spec/extensions/pg_array_associations_spec.rb +273 -273
- data/spec/extensions/pg_array_ops_spec.rb +52 -52
- data/spec/extensions/pg_array_spec.rb +152 -152
- data/spec/extensions/pg_enum_spec.rb +13 -13
- data/spec/extensions/pg_hstore_ops_spec.rb +63 -63
- data/spec/extensions/pg_hstore_spec.rb +84 -84
- data/spec/extensions/pg_inet_spec.rb +15 -15
- data/spec/extensions/pg_interval_spec.rb +29 -29
- data/spec/extensions/pg_json_ops_spec.rb +86 -84
- data/spec/extensions/pg_json_spec.rb +104 -104
- data/spec/extensions/pg_loose_count_spec.rb +6 -6
- data/spec/extensions/pg_range_ops_spec.rb +24 -24
- data/spec/extensions/pg_range_spec.rb +143 -143
- data/spec/extensions/pg_row_ops_spec.rb +14 -14
- data/spec/extensions/pg_row_plugin_spec.rb +12 -12
- data/spec/extensions/pg_row_spec.rb +118 -118
- data/spec/extensions/pg_static_cache_updater_spec.rb +28 -28
- data/spec/extensions/pg_typecast_on_load_spec.rb +21 -21
- data/spec/extensions/prepared_statements_associations_spec.rb +42 -42
- data/spec/extensions/prepared_statements_safe_spec.rb +18 -18
- data/spec/extensions/prepared_statements_spec.rb +28 -28
- data/spec/extensions/prepared_statements_with_pk_spec.rb +11 -11
- data/spec/extensions/pretty_table_spec.rb +16 -16
- data/spec/extensions/query_literals_spec.rb +37 -37
- data/spec/extensions/query_spec.rb +32 -32
- data/spec/extensions/rcte_tree_spec.rb +141 -141
- data/spec/extensions/round_timestamps_spec.rb +21 -21
- data/spec/extensions/schema_caching_spec.rb +8 -8
- data/spec/extensions/schema_dumper_spec.rb +78 -78
- data/spec/extensions/schema_spec.rb +31 -27
- data/spec/extensions/scissors_spec.rb +3 -3
- data/spec/extensions/select_remove_spec.rb +14 -14
- data/spec/extensions/sequel_3_dataset_methods_spec.rb +28 -28
- data/spec/extensions/serialization_modification_detection_spec.rb +33 -33
- data/spec/extensions/serialization_spec.rb +79 -78
- data/spec/extensions/server_block_spec.rb +17 -17
- data/spec/extensions/set_overrides_spec.rb +30 -30
- data/spec/extensions/sharding_spec.rb +65 -65
- data/spec/extensions/shared_caching_spec.rb +29 -29
- data/spec/extensions/single_table_inheritance_spec.rb +79 -79
- data/spec/extensions/skip_create_refresh_spec.rb +3 -3
- data/spec/extensions/spec_helper.rb +4 -29
- data/spec/extensions/split_array_nil_spec.rb +9 -9
- data/spec/extensions/split_values_spec.rb +7 -7
- data/spec/extensions/sql_expr_spec.rb +32 -32
- data/spec/extensions/static_cache_spec.rb +123 -123
- data/spec/extensions/string_date_time_spec.rb +34 -34
- data/spec/extensions/string_stripper_spec.rb +15 -15
- data/spec/extensions/subclasses_spec.rb +31 -31
- data/spec/extensions/table_select_spec.rb +15 -15
- data/spec/extensions/tactical_eager_loading_spec.rb +23 -23
- data/spec/extensions/thread_local_timezones_spec.rb +13 -13
- data/spec/extensions/timestamps_spec.rb +40 -40
- data/spec/extensions/to_dot_spec.rb +34 -34
- data/spec/extensions/touch_spec.rb +52 -52
- data/spec/extensions/tree_spec.rb +72 -72
- data/spec/extensions/typecast_on_load_spec.rb +25 -25
- data/spec/extensions/unlimited_update_spec.rb +2 -2
- data/spec/extensions/update_or_create_spec.rb +36 -36
- data/spec/extensions/update_primary_key_spec.rb +35 -35
- data/spec/extensions/update_refresh_spec.rb +41 -0
- data/spec/extensions/validate_associated_spec.rb +52 -0
- data/spec/extensions/validation_class_methods_spec.rb +314 -317
- data/spec/extensions/validation_helpers_spec.rb +195 -195
- data/spec/extensions/xml_serializer_spec.rb +48 -48
- data/spec/guards_helper.rb +55 -0
- data/spec/integration/associations_test.rb +1089 -1088
- data/spec/integration/database_test.rb +29 -29
- data/spec/integration/dataset_test.rb +661 -661
- data/spec/integration/eager_loader_test.rb +147 -147
- data/spec/integration/migrator_test.rb +122 -122
- data/spec/integration/model_test.rb +70 -70
- data/spec/integration/plugin_test.rb +682 -640
- data/spec/integration/prepared_statement_test.rb +172 -172
- data/spec/integration/schema_test.rb +245 -245
- data/spec/integration/spec_helper.rb +1 -64
- data/spec/integration/timezone_test.rb +17 -17
- data/spec/integration/transaction_test.rb +87 -87
- data/spec/integration/type_test.rb +33 -33
- data/spec/model/association_reflection_spec.rb +130 -121
- data/spec/model/associations_spec.rb +1112 -1113
- data/spec/model/base_spec.rb +197 -196
- data/spec/model/class_dataset_methods_spec.rb +118 -118
- data/spec/model/dataset_methods_spec.rb +49 -49
- data/spec/model/eager_loading_spec.rb +705 -702
- data/spec/model/hooks_spec.rb +169 -168
- data/spec/model/inflector_spec.rb +5 -5
- data/spec/model/model_spec.rb +287 -297
- data/spec/model/plugins_spec.rb +47 -47
- data/spec/model/record_spec.rb +534 -535
- data/spec/model/spec_helper.rb +3 -21
- data/spec/model/validations_spec.rb +72 -70
- data/spec/spec_config.rb +8 -0
- metadata +41 -9
- data/lib/sequel/adapters/fdbsql.rb +0 -286
- data/lib/sequel/adapters/jdbc/fdbsql.rb +0 -66
- data/lib/sequel/adapters/openbase.rb +0 -54
- data/lib/sequel/adapters/shared/fdbsql.rb +0 -550
- data/spec/adapters/fdbsql_spec.rb +0 -429
- data/spec/rspec_helper.rb +0 -22
|
@@ -30,8 +30,8 @@ describe "Sequel::Plugins::JsonSerializer" do
|
|
|
30
30
|
end
|
|
31
31
|
|
|
32
32
|
it "should round trip successfully" do
|
|
33
|
-
Artist.from_json(@artist.to_json).
|
|
34
|
-
Album.from_json(@album.to_json).
|
|
33
|
+
Artist.from_json(@artist.to_json).must_equal @artist
|
|
34
|
+
Album.from_json(@album.to_json).must_equal @album
|
|
35
35
|
end
|
|
36
36
|
|
|
37
37
|
it "should handle ruby objects in values" do
|
|
@@ -40,31 +40,31 @@ describe "Sequel::Plugins::JsonSerializer" do
|
|
|
40
40
|
super(Date.parse(v))
|
|
41
41
|
end
|
|
42
42
|
end
|
|
43
|
-
Artist.from_json(Artist.load(:name=>Date.today).to_json).
|
|
43
|
+
Artist.from_json(Artist.load(:name=>Date.today).to_json).must_equal Artist.load(:name=>Date.today)
|
|
44
44
|
end
|
|
45
45
|
|
|
46
46
|
it "should handle the :only option" do
|
|
47
|
-
Artist.from_json(@artist.to_json(:only=>:name)).
|
|
48
|
-
Album.from_json(@album.to_json(:only=>[:id, :name])).
|
|
47
|
+
Artist.from_json(@artist.to_json(:only=>:name)).must_equal Artist.load(:name=>@artist.name)
|
|
48
|
+
Album.from_json(@album.to_json(:only=>[:id, :name])).must_equal Album.load(:id=>@album.id, :name=>@album.name)
|
|
49
49
|
end
|
|
50
50
|
|
|
51
51
|
it "should handle the :except option" do
|
|
52
|
-
Artist.from_json(@artist.to_json(:except=>:id)).
|
|
53
|
-
Album.from_json(@album.to_json(:except=>[:id, :artist_id])).
|
|
52
|
+
Artist.from_json(@artist.to_json(:except=>:id)).must_equal Artist.load(:name=>@artist.name)
|
|
53
|
+
Album.from_json(@album.to_json(:except=>[:id, :artist_id])).must_equal Album.load(:name=>@album.name)
|
|
54
54
|
end
|
|
55
55
|
|
|
56
56
|
it "should handle the :include option for associations" do
|
|
57
|
-
Artist.from_json(@artist.to_json(:include=>:albums), :associations=>:albums).albums.
|
|
58
|
-
Album.from_json(@album.to_json(:include=>:artist), :associations=>:artist).artist.
|
|
57
|
+
Artist.from_json(@artist.to_json(:include=>:albums), :associations=>:albums).albums.must_equal [@album]
|
|
58
|
+
Album.from_json(@album.to_json(:include=>:artist), :associations=>:artist).artist.must_equal @artist
|
|
59
59
|
end
|
|
60
60
|
|
|
61
61
|
it "should raise an error if attempting to parse json when providing array to non-array association or vice-versa" do
|
|
62
|
-
proc{Artist.from_json('{"albums":{"id":1,"name":"RF","artist_id":2,"json_class":"Album"},"id":2,"name":"YJM"}', :associations=>:albums)}.
|
|
63
|
-
proc{Album.from_json('{"artist":[{"id":2,"name":"YJM","json_class":"Artist"}],"id":1,"name":"RF","artist_id":2}', :associations=>:artist)}.
|
|
62
|
+
proc{Artist.from_json('{"albums":{"id":1,"name":"RF","artist_id":2,"json_class":"Album"},"id":2,"name":"YJM"}', :associations=>:albums)}.must_raise(Sequel::Error)
|
|
63
|
+
proc{Album.from_json('{"artist":[{"id":2,"name":"YJM","json_class":"Artist"}],"id":1,"name":"RF","artist_id":2}', :associations=>:artist)}.must_raise(Sequel::Error)
|
|
64
64
|
end
|
|
65
65
|
|
|
66
66
|
it "should raise an error if attempting to parse an array containing non-hashes" do
|
|
67
|
-
proc{Artist.from_json('[{"id":2,"name":"YJM","json_class":"Artist"}, 2]')}.
|
|
67
|
+
proc{Artist.from_json('[{"id":2,"name":"YJM","json_class":"Artist"}, 2]')}.must_raise(Sequel::Error)
|
|
68
68
|
end
|
|
69
69
|
|
|
70
70
|
it "should raise an error if attempting to parse invalid JSON" do
|
|
@@ -75,7 +75,7 @@ describe "Sequel::Plugins::JsonSerializer" do
|
|
|
75
75
|
v
|
|
76
76
|
end
|
|
77
77
|
end
|
|
78
|
-
proc{Album.from_json('1')}.
|
|
78
|
+
proc{Album.from_json('1')}.must_raise(Sequel::Error)
|
|
79
79
|
ensure
|
|
80
80
|
Sequel.instance_eval do
|
|
81
81
|
alias parse_json pj
|
|
@@ -91,7 +91,7 @@ describe "Sequel::Plugins::JsonSerializer" do
|
|
|
91
91
|
Album.load(:id=>3)
|
|
92
92
|
end
|
|
93
93
|
end
|
|
94
|
-
::Album.from_json('1').
|
|
94
|
+
::Album.from_json('1').must_equal Album.load(:id=>3)
|
|
95
95
|
ensure
|
|
96
96
|
Sequel.instance_eval do
|
|
97
97
|
alias parse_json pj
|
|
@@ -100,91 +100,91 @@ describe "Sequel::Plugins::JsonSerializer" do
|
|
|
100
100
|
end
|
|
101
101
|
|
|
102
102
|
it "should handle the :include option for arbitrary attributes" do
|
|
103
|
-
Album.from_json(@album.to_json(:include=>:blah)).blah.
|
|
103
|
+
Album.from_json(@album.to_json(:include=>:blah)).blah.must_equal @album.blah
|
|
104
104
|
end
|
|
105
105
|
|
|
106
106
|
it "should handle multiple inclusions using an array for the :include option" do
|
|
107
107
|
a = Album.from_json(@album.to_json(:include=>[:blah, :artist]), :associations=>:artist)
|
|
108
|
-
a.blah.
|
|
109
|
-
a.artist.
|
|
108
|
+
a.blah.must_equal @album.blah
|
|
109
|
+
a.artist.must_equal @artist
|
|
110
110
|
end
|
|
111
111
|
|
|
112
112
|
it "should handle cascading using a hash for the :include option" do
|
|
113
|
-
Artist.from_json(@artist.to_json(:include=>{:albums=>{:include=>:artist}}), :associations=>{:albums=>{:associations=>:artist}}).albums.map{|a| a.artist}.
|
|
114
|
-
Album.from_json(@album.to_json(:include=>{:artist=>{:include=>:albums}}), :associations=>{:artist=>{:associations=>:albums}}).artist.albums.
|
|
113
|
+
Artist.from_json(@artist.to_json(:include=>{:albums=>{:include=>:artist}}), :associations=>{:albums=>{:associations=>:artist}}).albums.map{|a| a.artist}.must_equal [@artist]
|
|
114
|
+
Album.from_json(@album.to_json(:include=>{:artist=>{:include=>:albums}}), :associations=>{:artist=>{:associations=>:albums}}).artist.albums.must_equal [@album]
|
|
115
115
|
|
|
116
|
-
Artist.from_json(@artist.to_json(:include=>{:albums=>{:only=>:name}}), :associations=>[:albums]).albums.
|
|
117
|
-
Album.from_json(@album.to_json(:include=>{:artist=>{:except=>:name}}), :associations=>[:artist]).artist.
|
|
116
|
+
Artist.from_json(@artist.to_json(:include=>{:albums=>{:only=>:name}}), :associations=>[:albums]).albums.must_equal [Album.load(:name=>@album.name)]
|
|
117
|
+
Album.from_json(@album.to_json(:include=>{:artist=>{:except=>:name}}), :associations=>[:artist]).artist.must_equal Artist.load(:id=>@artist.id)
|
|
118
118
|
|
|
119
|
-
Artist.from_json(@artist.to_json(:include=>{:albums=>{:include=>{:artist=>{:include=>:albums}}}}), :associations=>{:albums=>{:associations=>{:artist=>{:associations=>:albums}}}}).albums.map{|a| a.artist.albums}.
|
|
120
|
-
Album.from_json(@album.to_json(:include=>{:artist=>{:include=>{:albums=>{:only=>:name}}}}), :associations=>{:artist=>{:associations=>:albums}}).artist.albums.
|
|
119
|
+
Artist.from_json(@artist.to_json(:include=>{:albums=>{:include=>{:artist=>{:include=>:albums}}}}), :associations=>{:albums=>{:associations=>{:artist=>{:associations=>:albums}}}}).albums.map{|a| a.artist.albums}.must_equal [[@album]]
|
|
120
|
+
Album.from_json(@album.to_json(:include=>{:artist=>{:include=>{:albums=>{:only=>:name}}}}), :associations=>{:artist=>{:associations=>:albums}}).artist.albums.must_equal [Album.load(:name=>@album.name)]
|
|
121
121
|
end
|
|
122
122
|
|
|
123
123
|
it "should handle the :include option cascading with an empty hash" do
|
|
124
|
-
Album.from_json(@album.to_json(:include=>{:artist=>{}}), :associations=>:artist).artist.
|
|
125
|
-
Album.from_json(@album.to_json(:include=>{:blah=>{}})).blah.
|
|
124
|
+
Album.from_json(@album.to_json(:include=>{:artist=>{}}), :associations=>:artist).artist.must_equal @artist
|
|
125
|
+
Album.from_json(@album.to_json(:include=>{:blah=>{}})).blah.must_equal @album.blah
|
|
126
126
|
end
|
|
127
127
|
|
|
128
128
|
it "should accept a :naked option to not include the JSON.create_id, so parsing yields a plain hash" do
|
|
129
|
-
Sequel.parse_json(@album.to_json(:naked=>true)).
|
|
129
|
+
Sequel.parse_json(@album.to_json(:naked=>true)).must_equal @album.values.inject({}){|h, (k, v)| h[k.to_s] = v; h}
|
|
130
130
|
end
|
|
131
131
|
|
|
132
132
|
it "should support #from_json to set column values" do
|
|
133
133
|
@artist.from_json('{"name": "AS"}')
|
|
134
|
-
@artist.name.
|
|
135
|
-
@artist.id.
|
|
134
|
+
@artist.name.must_equal 'AS'
|
|
135
|
+
@artist.id.must_equal 2
|
|
136
136
|
end
|
|
137
137
|
|
|
138
138
|
it "should support #from_json to support specific :fields" do
|
|
139
139
|
@album.from_json('{"name": "AS", "artist_id": 3}', :fields=>['name'])
|
|
140
|
-
@album.name.
|
|
141
|
-
@album.artist_id.
|
|
140
|
+
@album.name.must_equal 'AS'
|
|
141
|
+
@album.artist_id.must_equal 2
|
|
142
142
|
end
|
|
143
143
|
|
|
144
144
|
it "should support #from_json to support :missing=>:skip option" do
|
|
145
145
|
@album.from_json('{"artist_id": 3}', :fields=>['name'], :missing=>:skip)
|
|
146
|
-
@album.name.
|
|
147
|
-
@album.artist_id.
|
|
146
|
+
@album.name.must_equal 'RF'
|
|
147
|
+
@album.artist_id.must_equal 2
|
|
148
148
|
end
|
|
149
149
|
|
|
150
150
|
it "should support #from_json to support :missing=>:raise option" do
|
|
151
|
-
proc{@album.from_json('{"artist_id": 3}', :fields=>['name'], :missing=>:raise)}.
|
|
151
|
+
proc{@album.from_json('{"artist_id": 3}', :fields=>['name'], :missing=>:raise)}.must_raise(Sequel::Error)
|
|
152
152
|
end
|
|
153
153
|
|
|
154
154
|
it "should have #from_json raise an error if parsed json isn't a hash" do
|
|
155
|
-
proc{@artist.from_json('[]')}.
|
|
155
|
+
proc{@artist.from_json('[]')}.must_raise(Sequel::Error)
|
|
156
156
|
end
|
|
157
157
|
|
|
158
158
|
it "should raise an exception for json keys that aren't associations, columns, or setter methods" do
|
|
159
159
|
Album.send(:undef_method, :blah=)
|
|
160
|
-
proc{Album.from_json(@album.to_json(:include=>:blah))}.
|
|
160
|
+
proc{Album.from_json(@album.to_json(:include=>:blah))}.must_raise(Sequel::MassAssignmentRestriction)
|
|
161
161
|
end
|
|
162
162
|
|
|
163
163
|
it "should support a to_json class and dataset method" do
|
|
164
164
|
Album.dataset._fetch = {:id=>1, :name=>'RF', :artist_id=>2}
|
|
165
165
|
Artist.dataset._fetch = {:id=>2, :name=>'YJM'}
|
|
166
|
-
Album.array_from_json(Album.to_json).
|
|
167
|
-
Album.array_from_json(Album.to_json(:include=>:artist), :associations=>:artist).map{|x| x.artist}.
|
|
168
|
-
Album.array_from_json(Album.dataset.to_json(:only=>:name)).
|
|
166
|
+
Album.array_from_json(Album.to_json).must_equal [@album]
|
|
167
|
+
Album.array_from_json(Album.to_json(:include=>:artist), :associations=>:artist).map{|x| x.artist}.must_equal [@artist]
|
|
168
|
+
Album.array_from_json(Album.dataset.to_json(:only=>:name)).must_equal [Album.load(:name=>@album.name)]
|
|
169
169
|
end
|
|
170
170
|
|
|
171
171
|
it "should have dataset to_json method work with naked datasets" do
|
|
172
172
|
ds = Album.dataset.naked
|
|
173
173
|
ds._fetch = {:id=>1, :name=>'RF', :artist_id=>2}
|
|
174
|
-
Sequel.parse_json(ds.to_json).
|
|
174
|
+
Sequel.parse_json(ds.to_json).must_equal [@album.values.inject({}){|h, (k, v)| h[k.to_s] = v; h}]
|
|
175
175
|
end
|
|
176
176
|
|
|
177
177
|
it "should have dataset to_json method respect :array option for the array to use" do
|
|
178
178
|
a = Album.new(:name=>'RF', :artist_id=>3)
|
|
179
|
-
Album.array_from_json(Album.to_json(:array=>[a])).
|
|
179
|
+
Album.array_from_json(Album.to_json(:array=>[a])).must_equal [a]
|
|
180
180
|
|
|
181
181
|
a.associations[:artist] = artist = Artist.load(:id=>3, :name=>'YJM')
|
|
182
|
-
Album.array_from_json(Album.to_json(:array=>[a], :include=>:artist), :associations=>:artist).first.artist.
|
|
182
|
+
Album.array_from_json(Album.to_json(:array=>[a], :include=>:artist), :associations=>:artist).first.artist.must_equal artist
|
|
183
183
|
|
|
184
184
|
artist.associations[:albums] = [a]
|
|
185
185
|
x = Artist.array_from_json(Artist.to_json(:array=>[artist], :include=>:albums), :associations=>[:albums])
|
|
186
|
-
x.
|
|
187
|
-
x.first.albums.
|
|
186
|
+
x.must_equal [artist]
|
|
187
|
+
x.first.albums.must_equal [a]
|
|
188
188
|
end
|
|
189
189
|
|
|
190
190
|
it "should propagate class default options to instance to_json output" do
|
|
@@ -197,14 +197,14 @@ describe "Sequel::Plugins::JsonSerializer" do
|
|
|
197
197
|
@album2 = Album2.load(:id=>2, :name=>'JK')
|
|
198
198
|
@album2.artist = @artist
|
|
199
199
|
@album2.blah = 'Gak'
|
|
200
|
-
JSON.parse(@album2.to_json).
|
|
201
|
-
JSON.parse(@album2.to_json(:only => :name)).
|
|
202
|
-
JSON.parse(@album2.to_json(:except => :artist_id)).
|
|
200
|
+
JSON.parse(@album2.to_json).must_equal @album2.values.reject{|k,v| k.to_s == 'id'}.inject({}){|h, (k, v)| h[k.to_s] = v; h}
|
|
201
|
+
JSON.parse(@album2.to_json(:only => :name)).must_equal @album2.values.reject{|k,v| k.to_s != 'name'}.inject({}){|h, (k, v)| h[k.to_s] = v; h}
|
|
202
|
+
JSON.parse(@album2.to_json(:except => :artist_id)).must_equal @album2.values.reject{|k,v| k.to_s == 'artist_id'}.inject({}){|h, (k, v)| h[k.to_s] = v; h}
|
|
203
203
|
end
|
|
204
204
|
|
|
205
205
|
it "should handle the :root option to qualify single records" do
|
|
206
|
-
@album.to_json(:root=>true, :except => [:name, :artist_id]).to_s.
|
|
207
|
-
@album.to_json(:root=>true, :only => :name).to_s.
|
|
206
|
+
@album.to_json(:root=>true, :except => [:name, :artist_id]).to_s.must_equal '{"album":{"id":1}}'
|
|
207
|
+
@album.to_json(:root=>true, :only => :name).to_s.must_equal '{"album":{"name":"RF"}}'
|
|
208
208
|
end
|
|
209
209
|
|
|
210
210
|
it "should handle the :root option to qualify single records of namespaced models" do
|
|
@@ -213,79 +213,79 @@ describe "Sequel::Plugins::JsonSerializer" do
|
|
|
213
213
|
plugin :json_serializer, :naked=>true
|
|
214
214
|
end
|
|
215
215
|
end
|
|
216
|
-
Namespace::Album.new({}).to_json(:root=>true).to_s.
|
|
216
|
+
Namespace::Album.new({}).to_json(:root=>true).to_s.must_equal '{"album":{}}'
|
|
217
217
|
Namespace::Album.dataset._fetch = [{}]
|
|
218
|
-
Namespace::Album.dataset.to_json(:root=>:collection).to_s.
|
|
219
|
-
Namespace::Album.dataset.to_json(:root=>:both).to_s.
|
|
218
|
+
Namespace::Album.dataset.to_json(:root=>:collection).to_s.must_equal '{"albums":[{}]}'
|
|
219
|
+
Namespace::Album.dataset.to_json(:root=>:both).to_s.must_equal '{"albums":[{"album":{}}]}'
|
|
220
220
|
Object.send(:remove_const, :Namespace)
|
|
221
221
|
end
|
|
222
222
|
|
|
223
223
|
it "should handle the :root option with a string to qualify single records using the string as the key" do
|
|
224
|
-
@album.to_json(:root=>"foo", :except => [:name, :artist_id]).to_s.
|
|
225
|
-
@album.to_json(:root=>"bar", :only => :name).to_s.
|
|
224
|
+
@album.to_json(:root=>"foo", :except => [:name, :artist_id]).to_s.must_equal '{"foo":{"id":1}}'
|
|
225
|
+
@album.to_json(:root=>"bar", :only => :name).to_s.must_equal '{"bar":{"name":"RF"}}'
|
|
226
226
|
end
|
|
227
227
|
|
|
228
228
|
it "should handle the :root=>:both option to qualify a dataset of records" do
|
|
229
229
|
Album.dataset._fetch = [{:id=>1, :name=>'RF'}, {:id=>1, :name=>'RF'}]
|
|
230
|
-
Album.dataset.to_json(:root=>:both, :only => :id).to_s.
|
|
230
|
+
Album.dataset.to_json(:root=>:both, :only => :id).to_s.must_equal '{"albums":[{"album":{"id":1}},{"album":{"id":1}}]}'
|
|
231
231
|
end
|
|
232
232
|
|
|
233
233
|
it "should handle the :root=>:collection option to qualify just the collection" do
|
|
234
234
|
Album.dataset._fetch = [{:id=>1, :name=>'RF'}, {:id=>1, :name=>'RF'}]
|
|
235
|
-
Album.dataset.to_json(:root=>:collection, :only => :id).to_s.
|
|
236
|
-
Album.dataset.to_json(:root=>true, :only => :id).to_s.
|
|
235
|
+
Album.dataset.to_json(:root=>:collection, :only => :id).to_s.must_equal '{"albums":[{"id":1},{"id":1}]}'
|
|
236
|
+
Album.dataset.to_json(:root=>true, :only => :id).to_s.must_equal '{"albums":[{"id":1},{"id":1}]}'
|
|
237
237
|
end
|
|
238
238
|
|
|
239
239
|
it "should handle the :root=>:instance option to qualify just the instances" do
|
|
240
240
|
Album.dataset._fetch = [{:id=>1, :name=>'RF'}, {:id=>1, :name=>'RF'}]
|
|
241
|
-
Album.dataset.to_json(:root=>:instance, :only => :id).to_s.
|
|
241
|
+
Album.dataset.to_json(:root=>:instance, :only => :id).to_s.must_equal '[{"album":{"id":1}},{"album":{"id":1}}]'
|
|
242
242
|
end
|
|
243
243
|
|
|
244
244
|
it "should handle the :root=>string option to qualify just the collection using the string as the key" do
|
|
245
245
|
Album.dataset._fetch = [{:id=>1, :name=>'RF'}, {:id=>1, :name=>'RF'}]
|
|
246
|
-
Album.dataset.to_json(:root=>"foos", :only => :id).to_s.
|
|
247
|
-
Album.dataset.to_json(:root=>"bars", :only => :id).to_s.
|
|
246
|
+
Album.dataset.to_json(:root=>"foos", :only => :id).to_s.must_equal '{"foos":[{"id":1},{"id":1}]}'
|
|
247
|
+
Album.dataset.to_json(:root=>"bars", :only => :id).to_s.must_equal '{"bars":[{"id":1},{"id":1}]}'
|
|
248
248
|
end
|
|
249
249
|
|
|
250
250
|
it "should store the default options in json_serializer_opts" do
|
|
251
|
-
Album.json_serializer_opts.
|
|
251
|
+
Album.json_serializer_opts.must_equal(:naked=>true)
|
|
252
252
|
c = Class.new(Album)
|
|
253
253
|
c.plugin :json_serializer, :naked=>false
|
|
254
|
-
c.json_serializer_opts.
|
|
254
|
+
c.json_serializer_opts.must_equal(:naked=>false)
|
|
255
255
|
end
|
|
256
256
|
|
|
257
257
|
it "should work correctly when subclassing" do
|
|
258
258
|
class ::Artist2 < Artist
|
|
259
259
|
plugin :json_serializer, :only=>:name
|
|
260
260
|
end
|
|
261
|
-
Artist2.from_json(Artist2.load(:id=>2, :name=>'YYY').to_json).
|
|
261
|
+
Artist2.from_json(Artist2.load(:id=>2, :name=>'YYY').to_json).must_equal Artist2.load(:name=>'YYY')
|
|
262
262
|
class ::Artist3 < Artist2
|
|
263
263
|
plugin :json_serializer, :naked=>:true
|
|
264
264
|
end
|
|
265
|
-
Sequel.parse_json(Artist3.load(:id=>2, :name=>'YYY').to_json).
|
|
265
|
+
Sequel.parse_json(Artist3.load(:id=>2, :name=>'YYY').to_json).must_equal("name"=>'YYY')
|
|
266
266
|
Object.send(:remove_const, :Artist2)
|
|
267
267
|
Object.send(:remove_const, :Artist3)
|
|
268
268
|
end
|
|
269
269
|
|
|
270
270
|
it "should raise an error if attempting to set a restricted column and :all_columns is not used" do
|
|
271
271
|
Artist.restrict_primary_key
|
|
272
|
-
proc{Artist.from_json(@artist.to_json)}.
|
|
272
|
+
proc{Artist.from_json(@artist.to_json)}.must_raise(Sequel::MassAssignmentRestriction)
|
|
273
273
|
end
|
|
274
274
|
|
|
275
275
|
it "should raise an error if an unsupported association is passed in the :associations option" do
|
|
276
276
|
Artist.association_reflections.delete(:albums)
|
|
277
|
-
proc{Artist.from_json(@artist.to_json(:include=>:albums), :associations=>:albums)}.
|
|
277
|
+
proc{Artist.from_json(@artist.to_json(:include=>:albums), :associations=>:albums)}.must_raise(Sequel::Error)
|
|
278
278
|
end
|
|
279
279
|
|
|
280
280
|
it "should raise an error if using from_json and JSON parsing returns an array" do
|
|
281
|
-
proc{Artist.from_json([@artist].to_json)}.
|
|
281
|
+
proc{Artist.from_json([@artist].to_json)}.must_raise(Sequel::Error)
|
|
282
282
|
end
|
|
283
283
|
|
|
284
284
|
it "should raise an error if using array_from_json and JSON parsing does not return an array" do
|
|
285
|
-
proc{Artist.array_from_json(@artist.to_json)}.
|
|
285
|
+
proc{Artist.array_from_json(@artist.to_json)}.must_raise(Sequel::Error)
|
|
286
286
|
end
|
|
287
287
|
|
|
288
288
|
it "should raise an error if using an unsupported :associations option" do
|
|
289
|
-
proc{Artist.from_json(@artist.to_json, :associations=>'')}.
|
|
289
|
+
proc{Artist.from_json(@artist.to_json, :associations=>'')}.must_raise(Sequel::Error)
|
|
290
290
|
end
|
|
291
291
|
end
|
|
@@ -44,90 +44,90 @@ describe "Sequel::Plugins::LazyAttributes" do
|
|
|
44
44
|
|
|
45
45
|
it "should allowing adding additional lazy attributes via plugin :lazy_attributes" do
|
|
46
46
|
@c.set_dataset(@ds.select(:id, :blah))
|
|
47
|
-
@c.dataset.sql.
|
|
47
|
+
@c.dataset.sql.must_equal 'SELECT id, blah FROM la'
|
|
48
48
|
@c.plugin :lazy_attributes, :blah
|
|
49
|
-
@c.dataset.sql.
|
|
49
|
+
@c.dataset.sql.must_equal 'SELECT id FROM la'
|
|
50
50
|
end
|
|
51
51
|
|
|
52
52
|
it "should allowing adding additional lazy attributes via lazy_attributes" do
|
|
53
53
|
@c.set_dataset(@ds.select(:id, :blah))
|
|
54
|
-
@c.dataset.sql.
|
|
54
|
+
@c.dataset.sql.must_equal 'SELECT id, blah FROM la'
|
|
55
55
|
@c.lazy_attributes :blah
|
|
56
|
-
@c.dataset.sql.
|
|
56
|
+
@c.dataset.sql.must_equal 'SELECT id FROM la'
|
|
57
57
|
end
|
|
58
58
|
|
|
59
59
|
it "should handle lazy attributes that are qualified in the selection" do
|
|
60
60
|
@c.set_dataset(@ds.select(:la__id, :la__blah))
|
|
61
|
-
@c.dataset.sql.
|
|
61
|
+
@c.dataset.sql.must_equal 'SELECT la.id, la.blah FROM la'
|
|
62
62
|
@c.plugin :lazy_attributes, :blah
|
|
63
|
-
@c.dataset.sql.
|
|
63
|
+
@c.dataset.sql.must_equal 'SELECT la.id FROM la'
|
|
64
64
|
end
|
|
65
65
|
|
|
66
66
|
it "should remove the attributes given from the SELECT columns of the model's dataset" do
|
|
67
|
-
@ds.sql.
|
|
67
|
+
@ds.sql.must_equal 'SELECT la.id FROM la'
|
|
68
68
|
end
|
|
69
69
|
|
|
70
70
|
it "should still typecast correctly in lazy loaded column setters" do
|
|
71
71
|
m = @c.new
|
|
72
72
|
m.name = 1
|
|
73
|
-
m.name.
|
|
73
|
+
m.name.must_equal '1'
|
|
74
74
|
end
|
|
75
75
|
|
|
76
76
|
it "should raise error if the model has no primary key" do
|
|
77
77
|
m = @c.first
|
|
78
78
|
@c.no_primary_key
|
|
79
|
-
proc{m.name}.
|
|
79
|
+
proc{m.name}.must_raise(Sequel::Error)
|
|
80
80
|
end
|
|
81
81
|
|
|
82
82
|
it "should lazily load the attribute for a single model object" do
|
|
83
83
|
m = @c.first
|
|
84
|
-
m.values.
|
|
85
|
-
m.name.
|
|
86
|
-
m.values.
|
|
87
|
-
@db.sqls.
|
|
84
|
+
m.values.must_equal(:id=>1)
|
|
85
|
+
m.name.must_equal '1'
|
|
86
|
+
m.values.must_equal(:id=>1, :name=>'1')
|
|
87
|
+
@db.sqls.must_equal ['SELECT la.id FROM la LIMIT 1', 'SELECT la.name FROM la WHERE (id = 1) LIMIT 1']
|
|
88
88
|
end
|
|
89
89
|
|
|
90
90
|
it "should lazily load the attribute for a frozen model object" do
|
|
91
91
|
m = @c.first
|
|
92
92
|
m.freeze
|
|
93
|
-
m.name.
|
|
94
|
-
@db.sqls.
|
|
95
|
-
m.name.
|
|
96
|
-
@db.sqls.
|
|
93
|
+
m.name.must_equal '1'
|
|
94
|
+
@db.sqls.must_equal ['SELECT la.id FROM la LIMIT 1', 'SELECT la.name FROM la WHERE (id = 1) LIMIT 1']
|
|
95
|
+
m.name.must_equal '1'
|
|
96
|
+
@db.sqls.must_equal ['SELECT la.name FROM la WHERE (id = 1) LIMIT 1']
|
|
97
97
|
end
|
|
98
98
|
|
|
99
99
|
it "should not lazily load the attribute for a single model object if the value already exists" do
|
|
100
100
|
m = @c.first
|
|
101
|
-
m.values.
|
|
101
|
+
m.values.must_equal(:id=>1)
|
|
102
102
|
m[:name] = '1'
|
|
103
|
-
m.name.
|
|
104
|
-
m.values.
|
|
105
|
-
@db.sqls.
|
|
103
|
+
m.name.must_equal '1'
|
|
104
|
+
m.values.must_equal(:id=>1, :name=>'1')
|
|
105
|
+
@db.sqls.must_equal ['SELECT la.id FROM la LIMIT 1']
|
|
106
106
|
end
|
|
107
107
|
|
|
108
108
|
it "should not lazily load the attribute for a single model object if it is a new record" do
|
|
109
109
|
m = @c.new
|
|
110
|
-
m.values.
|
|
111
|
-
m.name.
|
|
112
|
-
@db.sqls.
|
|
110
|
+
m.values.must_equal({})
|
|
111
|
+
m.name.must_equal nil
|
|
112
|
+
@db.sqls.must_equal []
|
|
113
113
|
end
|
|
114
114
|
|
|
115
115
|
it "should eagerly load the attribute for all model objects reteived with it" do
|
|
116
116
|
ms = @c.all
|
|
117
|
-
ms.map{|m| m.values}.
|
|
118
|
-
ms.map{|m| m.name}.
|
|
119
|
-
ms.map{|m| m.values}.
|
|
117
|
+
ms.map{|m| m.values}.must_equal [{:id=>1}, {:id=>2}]
|
|
118
|
+
ms.map{|m| m.name}.must_equal %w'1 2'
|
|
119
|
+
ms.map{|m| m.values}.must_equal [{:id=>1, :name=>'1'}, {:id=>2, :name=>'2'}]
|
|
120
120
|
sqls = @db.sqls
|
|
121
121
|
['SELECT la.id, la.name FROM la WHERE (la.id IN (1, 2))',
|
|
122
|
-
'SELECT la.id, la.name FROM la WHERE (la.id IN (2, 1))'].
|
|
123
|
-
sqls.
|
|
122
|
+
'SELECT la.id, la.name FROM la WHERE (la.id IN (2, 1))'].must_include(sqls.pop)
|
|
123
|
+
sqls.must_equal ['SELECT la.id FROM la']
|
|
124
124
|
end
|
|
125
125
|
|
|
126
126
|
it "should not eagerly load the attribute if model instance is frozen, and deal with other frozen instances if not frozen" do
|
|
127
127
|
ms = @c.all
|
|
128
128
|
ms.first.freeze
|
|
129
|
-
ms.map{|m| m.name}.
|
|
130
|
-
@db.sqls.
|
|
129
|
+
ms.map{|m| m.name}.must_equal %w'1 2'
|
|
130
|
+
@db.sqls.must_equal ['SELECT la.id FROM la', 'SELECT la.name FROM la WHERE (id = 1) LIMIT 1', 'SELECT la.id, la.name FROM la WHERE (la.id IN (2))']
|
|
131
131
|
end
|
|
132
132
|
|
|
133
133
|
it "should add the accessors to a module included in the class, so they can be easily overridden" do
|
|
@@ -137,34 +137,34 @@ describe "Sequel::Plugins::LazyAttributes" do
|
|
|
137
137
|
end
|
|
138
138
|
end
|
|
139
139
|
ms = @c.all
|
|
140
|
-
ms.map{|m| m.values}.
|
|
141
|
-
ms.map{|m| m.name}.
|
|
142
|
-
ms.map{|m| m.values}.
|
|
140
|
+
ms.map{|m| m.values}.must_equal [{:id=>1}, {:id=>2}]
|
|
141
|
+
ms.map{|m| m.name}.must_equal %w'1-blah 2-blah'
|
|
142
|
+
ms.map{|m| m.values}.must_equal [{:id=>1, :name=>'1'}, {:id=>2, :name=>'2'}]
|
|
143
143
|
sqls = @db.sqls
|
|
144
144
|
['SELECT la.id, la.name FROM la WHERE (la.id IN (1, 2))',
|
|
145
|
-
'SELECT la.id, la.name FROM la WHERE (la.id IN (2, 1))'].
|
|
146
|
-
sqls.
|
|
145
|
+
'SELECT la.id, la.name FROM la WHERE (la.id IN (2, 1))'].must_include(sqls.pop)
|
|
146
|
+
sqls.must_equal ['SELECT la.id FROM la']
|
|
147
147
|
end
|
|
148
148
|
|
|
149
149
|
it "should work with the serialization plugin" do
|
|
150
150
|
@c.plugin :serialization, :yaml, :name
|
|
151
151
|
@c.instance_dataset._fetch = @ds._fetch = [[{:id=>1}, {:id=>2}], [{:id=>1, :name=>"--- 3\n"}, {:id=>2, :name=>"--- 6\n"}], [{:id=>1}], [{:name=>"--- 3\n"}]]
|
|
152
152
|
ms = @ds.all
|
|
153
|
-
ms.map{|m| m.values}.
|
|
154
|
-
ms.map{|m| m.name}.
|
|
155
|
-
ms.map{|m| m.values}.
|
|
156
|
-
ms.map{|m| m.deserialized_values}.
|
|
157
|
-
ms.map{|m| m.name}.
|
|
153
|
+
ms.map{|m| m.values}.must_equal [{:id=>1}, {:id=>2}]
|
|
154
|
+
ms.map{|m| m.name}.must_equal [3,6]
|
|
155
|
+
ms.map{|m| m.values}.must_equal [{:id=>1, :name=>"--- 3\n"}, {:id=>2, :name=>"--- 6\n"}]
|
|
156
|
+
ms.map{|m| m.deserialized_values}.must_equal [{:name=>3}, {:name=>6}]
|
|
157
|
+
ms.map{|m| m.name}.must_equal [3,6]
|
|
158
158
|
sqls = @db.sqls
|
|
159
159
|
['SELECT la.id, la.name FROM la WHERE (la.id IN (1, 2))',
|
|
160
|
-
'SELECT la.id, la.name FROM la WHERE (la.id IN (2, 1))'].
|
|
161
|
-
sqls.
|
|
160
|
+
'SELECT la.id, la.name FROM la WHERE (la.id IN (2, 1))'].must_include(sqls.pop)
|
|
161
|
+
sqls.must_equal ['SELECT la.id FROM la']
|
|
162
162
|
m = @ds.first
|
|
163
|
-
m.values.
|
|
164
|
-
m.name.
|
|
165
|
-
m.values.
|
|
166
|
-
m.deserialized_values.
|
|
167
|
-
m.name.
|
|
168
|
-
@db.sqls.
|
|
163
|
+
m.values.must_equal(:id=>1)
|
|
164
|
+
m.name.must_equal 3
|
|
165
|
+
m.values.must_equal(:id=>1, :name=>"--- 3\n")
|
|
166
|
+
m.deserialized_values.must_equal(:name=>3)
|
|
167
|
+
m.name.must_equal 3
|
|
168
|
+
@db.sqls.must_equal ["SELECT la.id FROM la LIMIT 1", "SELECT la.name FROM la WHERE (id = 1) LIMIT 1"]
|
|
169
169
|
end
|
|
170
170
|
end
|