129 | 129 |
is $from_storage_ran, ++$expected_from, 'from did run';
|
130 | 130 |
is $to_storage_ran, $expected_to, 'to did not run';
|
131 | 131 |
|
|
132 |
ok ! $artist->is_changed, 'object clean';
|
|
133 |
is_deeply
|
|
134 |
{ $artist->get_dirty_columns },
|
|
135 |
{},
|
|
136 |
'dirty columns as expected',
|
|
137 |
;
|
|
138 |
|
|
139 |
is $from_storage_ran, $expected_from, 'from did not run';
|
|
140 |
is $to_storage_ran, $expected_to, 'to did not run';
|
|
141 |
|
|
142 |
$artist->charfield(42);
|
|
143 |
|
|
144 |
is $from_storage_ran, $expected_from, 'from did not run';
|
|
145 |
is $to_storage_ran, ++$expected_to, 'to ran once, determining dirtyness';
|
|
146 |
|
|
147 |
is $artist->charfield, 42, 'setting once works';
|
|
148 |
ok $artist->is_column_changed('charfield'), 'column changed';
|
|
149 |
ok $artist->is_changed, 'object changed';
|
|
150 |
is_deeply
|
|
151 |
{ $artist->get_dirty_columns },
|
|
152 |
{ charfield => 21 },
|
|
153 |
'dirty columns as expected',
|
|
154 |
;
|
|
155 |
|
|
156 |
is $from_storage_ran, $expected_from, 'from did not run';
|
|
157 |
is $to_storage_ran, $expected_to, 'to did not run';
|
|
158 |
|
|
159 |
$artist->charfield(66);
|
|
160 |
is $artist->charfield, 66, 'setting twice works';
|
|
161 |
ok $artist->is_column_changed('charfield'), 'column changed';
|
|
162 |
ok $artist->is_changed, 'object changed';
|
|
163 |
|
|
164 |
is $from_storage_ran, $expected_from, 'from did not run';
|
|
165 |
is $to_storage_ran, $expected_to, 'to did not run a second time on dirty column';
|
|
166 |
|
|
167 |
is_deeply
|
|
168 |
{ $artist->get_dirty_columns },
|
|
169 |
{ charfield => 33 },
|
|
170 |
'dirty columns as expected',
|
|
171 |
;
|
|
172 |
is $from_storage_ran, $expected_from, 'from did not run';
|
|
173 |
is $to_storage_ran, ++$expected_to, 'to did run producing a new dirty_columns set';
|
|
174 |
|
|
175 |
is_deeply
|
|
176 |
{ $artist->get_dirty_columns },
|
|
177 |
{ charfield => 33 },
|
|
178 |
'dirty columns still as expected',
|
|
179 |
;
|
|
180 |
is $from_storage_ran, $expected_from, 'from did not run';
|
|
181 |
is $to_storage_ran, $expected_to, 'to did not run on re-invoked get_dirty_columns';
|
|
182 |
|
|
183 |
$artist->update;
|
|
184 |
is $artist->charfield, 66, 'value still there';
|
|
185 |
|
|
186 |
is $from_storage_ran, $expected_from, 'from did not run';
|
|
187 |
is $to_storage_ran, $expected_to, 'to did not run ';
|
|
188 |
|
|
189 |
$artist->discard_changes;
|
|
190 |
|
|
191 |
is $from_storage_ran, $expected_from, 'from did not run after discard_changes';
|
|
192 |
is $to_storage_ran, $expected_to, 'to did not run after discard_changes';
|
|
193 |
|
|
194 |
is $artist->charfield, 66, 'value still there post reload';
|
|
195 |
|
|
196 |
is $from_storage_ran, ++$expected_from, 'from did run';
|
|
197 |
is $to_storage_ran, $expected_to, 'to did not run';
|
132 | 198 |
}
|
133 | 199 |
|
134 | 200 |
# test in-memory operations
|
|
136 | 202 |
sub { $schema->resultset('Artist')->new({ charfield => 42 }) },
|
137 | 203 |
sub { my $art = $schema->resultset('Artist')->new({}); $art->charfield(42); $art },
|
138 | 204 |
) {
|
|
205 |
$schema->resultset('Artist')->delete;
|
139 | 206 |
|
140 | 207 |
my $expected_from = $from_storage_ran;
|
141 | 208 |
my $expected_to = $to_storage_ran;
|
|
149 | 216 |
ok( $artist->has_column_loaded('charfield'), 'Filtered column marked as loaded under new' );
|
150 | 217 |
is( $artist->charfield, 42, 'Proper unfiltered value' );
|
151 | 218 |
is( $artist->get_column('charfield'), 21, 'Proper filtered value' );
|
|
219 |
|
|
220 |
$artist->insert;
|
|
221 |
($raw_db_charfield) = $schema->resultset('Artist')
|
|
222 |
->search ($artist->ident_condition)
|
|
223 |
->get_column('charfield')
|
|
224 |
->next;
|
|
225 |
|
|
226 |
is $raw_db_charfield, 21, 'Proper value in database';
|
152 | 227 |
}
|
153 | 228 |
|
154 | 229 |
# test literals
|