« blib/lib/DBIO/Test/MooSchema/ResultSet/Artist.pm
↑ Summary
blib/lib/DBIO/InflateColumn/Serializer/YAML.pm »
| 1 | package DBIO::Test::Conformance::Cases::Diff; | ||||||||||||
| 2 | # ABSTRACT: The shared Diff cases every DBIO driver answers | ||||||||||||
| 3 | |||||||||||||
| 4 | 4 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 5 | 4 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 6 | |||||||||||||
| 7 | 4 | our $VERSION = '0.900007'; | |||||||||||
| 8 | |||||||||||||
| 9 | 4 | ▶ | use DBIO::Util (); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 10 | |||||||||||||
| 11 | |||||||||||||
| 12 | 220 | ▶ | my $id = sub { +{ data_type => 'integer', is_nullable => 0 } }; | ||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||
| 13 | |||||||||||||
| 14 | # a small table the cases share: id and a nullable text column | ||||||||||||
| 15 | 64 | ▶ | my $base = sub { | ||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||
| 16 | 64 | my (%extra) = @_; | |||||||||||
| 17 | return { | ||||||||||||
| 18 | name => 'Base', table => 'base', | ||||||||||||
| 19 | columns => [ | ||||||||||||
| 20 | id => $id->(), | ||||||||||||
| 21 | name => { data_type => 'varchar', size => 20, is_nullable => 1 }, | ||||||||||||
| 22 | 64 | ▶ | @{ delete $extra{more} || [] }, | ||||||||||
|
Condition100%2/2
delete $extra{'more'} || []
MC/DC100%1/1
delete $extra{'more'} || []
delete $extra{'more'}
Truth table100%2/2
A
A= delete $extra{'more'}
| |||||||||||||
| 23 | ], | ||||||||||||
| 24 | primary_key => [ 'id' ], | ||||||||||||
| 25 | %extra, | ||||||||||||
| 26 | }; | ||||||||||||
| 27 | 4 | }; | |||||||||||
| 28 | |||||||||||||
| 29 | 24 | ▶ | my $view = sub { | ||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||
| 30 | 24 | my ($definition, @columns) = @_; | |||||||||||
| 31 | return { | ||||||||||||
| 32 | 24 | name => 'BaseView', table => 'base_view', | |||||||||||
| 33 | columns => [ @columns ], | ||||||||||||
| 34 | view => { definition => $definition, virtual => 0 }, | ||||||||||||
| 35 | }; | ||||||||||||
| 36 | 4 | }; | |||||||||||
| 37 | |||||||||||||
| 38 | 36 | ▶ | my $parent = sub { | ||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||
| 39 | return { | ||||||||||||
| 40 | name => 'Parent', table => 'parent', | ||||||||||||
| 41 | 36 | ▶ | columns => [ id => $id->(), @{ shift || [] } ], | ||||||||||
|
Condition100%2/2
shift() || []
MC/DC100%1/1
shift() || []
shift()
Truth table100%2/2
A
A= shift()
| |||||||||||||
| 42 | primary_key => [ 'id' ], | ||||||||||||
| 43 | @_, | ||||||||||||
| 44 | }; | ||||||||||||
| 45 | 4 | }; | |||||||||||
| 46 | |||||||||||||
| 47 | 4 | my @CASES = ( | |||||||||||
| 48 | |||||||||||||
| 49 | { | ||||||||||||
| 50 | name => 'diff-view-added', | ||||||||||||
| 51 | since => 1, | ||||||||||||
| 52 | subject => { source => 'BaseView' }, | ||||||||||||
| 53 | input => { | ||||||||||||
| 54 | from => { sources => [ $base->() ] }, | ||||||||||||
| 55 | to => { sources => [ | ||||||||||||
| 56 | $base->(), | ||||||||||||
| 57 | $view->('SELECT {{id}}, {{name}} FROM {{base}}', | ||||||||||||
| 58 | id => { data_type => 'integer' }, name => { data_type => 'varchar', size => 20 }), | ||||||||||||
| 59 | ] }, | ||||||||||||
| 60 | rows => [ { source => 'Base', values => { id => 1, name => 'x' } } ], | ||||||||||||
| 61 | }, | ||||||||||||
| 62 | expect => [ | ||||||||||||
| 63 | { fact => { name => 'object_kind', source => 'BaseView', is => 'view' } }, | ||||||||||||
| 64 | { rows_kept => { source => 'Base', find => { id => 1 }, is => { name => 'x' } } }, | ||||||||||||
| 65 | { search_by => { source => 'Base', create => { id => 2, name => 'y' }, | ||||||||||||
| 66 | through => 'BaseView', column => 'name', value => 'y' } }, | ||||||||||||
| 67 | ], | ||||||||||||
| 68 | }, | ||||||||||||
| 69 | |||||||||||||
| 70 | { | ||||||||||||
| 71 | name => 'diff-view-dropped', | ||||||||||||
| 72 | since => 1, | ||||||||||||
| 73 | subject => { source => 'BaseView' }, | ||||||||||||
| 74 | input => { | ||||||||||||
| 75 | from => { sources => [ | ||||||||||||
| 76 | $base->(), | ||||||||||||
| 77 | $view->('SELECT {{id}}, {{name}} FROM {{base}}', | ||||||||||||
| 78 | id => { data_type => 'integer' }, name => { data_type => 'varchar', size => 20 }), | ||||||||||||
| 79 | ] }, | ||||||||||||
| 80 | to => { sources => [ $base->() ] }, | ||||||||||||
| 81 | rows => [ { source => 'Base', values => { id => 1, name => 'x' } } ], | ||||||||||||
| 82 | }, | ||||||||||||
| 83 | expect => [ | ||||||||||||
| 84 | { fact => { name => 'object_kind', source => 'BaseView', is => undef } }, | ||||||||||||
| 85 | { fact => { name => 'object_kind', source => 'Base', is => 'table' } }, | ||||||||||||
| 86 | { rows_kept => { source => 'Base', find => { id => 1 }, is => { name => 'x' } } }, | ||||||||||||
| 87 | ], | ||||||||||||
| 88 | }, | ||||||||||||
| 89 | |||||||||||||
| 90 | { | ||||||||||||
| 91 | name => 'diff-view-definition-changed', | ||||||||||||
| 92 | since => 1, | ||||||||||||
| 93 | subject => { source => 'BaseView' }, | ||||||||||||
| 94 | input => { | ||||||||||||
| 95 | from => { sources => [ | ||||||||||||
| 96 | $base->(more => [ extra => { data_type => 'varchar', size => 20, is_nullable => 1 } ]), | ||||||||||||
| 97 | $view->('SELECT {{id}}, {{name}} FROM {{base}}', | ||||||||||||
| 98 | id => { data_type => 'integer' }, name => { data_type => 'varchar', size => 20 }), | ||||||||||||
| 99 | ] }, | ||||||||||||
| 100 | to => { sources => [ | ||||||||||||
| 101 | $base->(more => [ extra => { data_type => 'varchar', size => 20, is_nullable => 1 } ]), | ||||||||||||
| 102 | $view->('SELECT {{id}}, {{name}}, {{extra}} FROM {{base}}', | ||||||||||||
| 103 | id => { data_type => 'integer' }, name => { data_type => 'varchar', size => 20 }, | ||||||||||||
| 104 | extra => { data_type => 'varchar', size => 20 }), | ||||||||||||
| 105 | ] }, | ||||||||||||
| 106 | rows => [ { source => 'Base', values => { id => 1, name => 'x', extra => 'e' } } ], | ||||||||||||
| 107 | }, | ||||||||||||
| 108 | expect => [ | ||||||||||||
| 109 | { fact => { name => 'object_kind', source => 'BaseView', is => 'view' } }, | ||||||||||||
| 110 | { search_by => { source => 'Base', create => { id => 2, name => 'y', extra => 'f' }, | ||||||||||||
| 111 | through => 'BaseView', column => 'extra', value => 'f' } }, | ||||||||||||
| 112 | ], | ||||||||||||
| 113 | }, | ||||||||||||
| 114 | |||||||||||||
| 115 | { | ||||||||||||
| 116 | name => 'diff-table-added-complete', | ||||||||||||
| 117 | since => 1, | ||||||||||||
| 118 | subject => { source => 'Child', column => 'parent_id' }, | ||||||||||||
| 119 | input => { | ||||||||||||
| 120 | from => { sources => [ | ||||||||||||
| 121 | { name => 'Anchor', table => 'anchor', columns => [ id => $id->() ], | ||||||||||||
| 122 | primary_key => [ 'id' ] }, | ||||||||||||
| 123 | ] }, | ||||||||||||
| 124 | to => { sources => [ | ||||||||||||
| 125 | { name => 'Anchor', table => 'anchor', columns => [ id => $id->() ], | ||||||||||||
| 126 | primary_key => [ 'id' ] }, | ||||||||||||
| 127 | $parent->(), | ||||||||||||
| 128 | { | ||||||||||||
| 129 | name => 'Child', table => 'child', | ||||||||||||
| 130 | columns => [ | ||||||||||||
| 131 | id => $id->(), | ||||||||||||
| 132 | parent_id => { data_type => 'integer', is_nullable => 0 }, | ||||||||||||
| 133 | code => { data_type => 'varchar', size => 20, is_nullable => 0 }, | ||||||||||||
| 134 | label => { data_type => 'varchar', size => 20, is_nullable => 1 }, | ||||||||||||
| 135 | ], | ||||||||||||
| 136 | primary_key => [ 'id' ], | ||||||||||||
| 137 | unique => [ [ child_code => [ 'code' ] ] ], | ||||||||||||
| 138 | indexes => [ { name => 'child_label_idx', columns => [ 'label' ] } ], | ||||||||||||
| 139 | relationships => [ | ||||||||||||
| 140 | { type => 'belongs_to', name => 'parent', source => 'Parent', | ||||||||||||
| 141 | cond => 'parent_id', attrs => { on_delete => 'CASCADE' } }, | ||||||||||||
| 142 | ], | ||||||||||||
| 143 | }, | ||||||||||||
| 144 | ] }, | ||||||||||||
| 145 | rows => [ { source => 'Anchor', values => { id => 1 } } ], | ||||||||||||
| 146 | }, | ||||||||||||
| 147 | expect => [ | ||||||||||||
| 148 | { fact => { name => 'object_kind', source => 'Child', is => 'table' } }, | ||||||||||||
| 149 | { fact => { name => 'primary_key_columns', source => 'Child', is => [ 'id' ] } }, | ||||||||||||
| 150 | { fact => { name => 'unique_exists', source => 'Child', columns => [ 'code' ], is => 1 } }, | ||||||||||||
| 151 | { fact => { name => 'index_count', source => 'Child', columns => [ 'label' ], is => 1 } }, | ||||||||||||
| 152 | { fact => { name => 'foreign_key_count', source => 'Child', is => 1 } }, | ||||||||||||
| 153 | { rows_kept => { source => 'Anchor', find => { id => 1 } } }, | ||||||||||||
| 154 | { read_back => { source => 'Parent', create => { id => 5 } } }, | ||||||||||||
| 155 | { rejects => { source => 'Child', first => { id => 10, parent_id => 5, code => 'dup' }, | ||||||||||||
| 156 | create => { id => 11, parent_id => 5, code => 'dup' } } }, | ||||||||||||
| 157 | { rejects => { source => 'Child', create => { id => 12, parent_id => 1000, code => 'orphan' } } }, | ||||||||||||
| 158 | { cascade_delete => { parent => 'Parent', parent_values => { id => 1 }, | ||||||||||||
| 159 | child => 'Child', child_values => { id => 1, code => 'c1' }, | ||||||||||||
| 160 | link => { parent_id => 'id' } } }, | ||||||||||||
| 161 | ], | ||||||||||||
| 162 | }, | ||||||||||||
| 163 | |||||||||||||
| 164 | { | ||||||||||||
| 165 | name => 'diff-column-added-not-null-populated', | ||||||||||||
| 166 | since => 1, | ||||||||||||
| 167 | subject => { source => 'Base', column => 'code' }, | ||||||||||||
| 168 | input => { | ||||||||||||
| 169 | from => { sources => [ $base->() ] }, | ||||||||||||
| 170 | to => { sources => [ | ||||||||||||
| 171 | $base->(more => [ code => { data_type => 'varchar', size => 10, is_nullable => 0 } ]), | ||||||||||||
| 172 | ] }, | ||||||||||||
| 173 | rows => [ | ||||||||||||
| 174 | { source => 'Base', values => { id => 1, name => 'one' } }, | ||||||||||||
| 175 | { source => 'Base', values => { id => 2, name => 'two' } }, | ||||||||||||
| 176 | ], | ||||||||||||
| 177 | }, | ||||||||||||
| 178 | expect => [ | ||||||||||||
| 179 | { fact => { name => 'column_names', source => 'Base', is => [ 'code', 'id', 'name' ] } }, | ||||||||||||
| 180 | { rows_kept => { source => 'Base', find => { id => 1 }, is => { name => 'one' } } }, | ||||||||||||
| 181 | { rows_kept => { source => 'Base', find => { id => 2 }, is => { name => 'two' } } }, | ||||||||||||
| 182 | { read_back => { source => 'Base', create => { id => 3, name => 'three', code => 'z' }, | ||||||||||||
| 183 | is => { code => 'z' } } }, | ||||||||||||
| 184 | ], | ||||||||||||
| 185 | }, | ||||||||||||
| 186 | |||||||||||||
| 187 | { | ||||||||||||
| 188 | name => 'diff-column-added-expression-default', | ||||||||||||
| 189 | since => 1, | ||||||||||||
| 190 | subject => { source => 'Base', column => 'created' }, | ||||||||||||
| 191 | input => { | ||||||||||||
| 192 | from => { sources => [ $base->() ] }, | ||||||||||||
| 193 | to => { sources => [ | ||||||||||||
| 194 | $base->(more => [ | ||||||||||||
| 195 | created => { data_type => 'timestamp', is_nullable => 0, | ||||||||||||
| 196 | default_value => \'CURRENT_TIMESTAMP' }, | ||||||||||||
| 197 | ]), | ||||||||||||
| 198 | ] }, | ||||||||||||
| 199 | rows => [ { source => 'Base', values => { id => 1, name => 'one' } } ], | ||||||||||||
| 200 | }, | ||||||||||||
| 201 | expect => [ | ||||||||||||
| 202 | { fact => { name => 'column_names', source => 'Base', is => [ 'created', 'id', 'name' ] } }, | ||||||||||||
| 203 | { rows_kept => { source => 'Base', find => { id => 1 }, is => { name => 'one' } } }, | ||||||||||||
| 204 | { read_back => { source => 'Base', create => { id => 2, name => 'two' }, | ||||||||||||
| 205 | like => { created => qr/^\d{4}-\d\d-\d\d/ }, | ||||||||||||
| 206 | isnt => { created => 'CURRENT_TIMESTAMP' } } }, | ||||||||||||
| 207 | ], | ||||||||||||
| 208 | }, | ||||||||||||
| 209 | |||||||||||||
| 210 | { | ||||||||||||
| 211 | name => 'diff-default-changed-apostrophe', | ||||||||||||
| 212 | since => 1, | ||||||||||||
| 213 | subject => { source => 'Note', column => 'note' }, | ||||||||||||
| 214 | input => { | ||||||||||||
| 215 | from => { sources => [ { | ||||||||||||
| 216 | name => 'Note', table => 'note', | ||||||||||||
| 217 | columns => [ | ||||||||||||
| 218 | id => $id->(), | ||||||||||||
| 219 | note => { data_type => 'varchar', size => 20, is_nullable => 0, default_value => 'a' }, | ||||||||||||
| 220 | ], | ||||||||||||
| 221 | primary_key => [ 'id' ], | ||||||||||||
| 222 | } ] }, | ||||||||||||
| 223 | to => { sources => [ { | ||||||||||||
| 224 | name => 'Note', table => 'note', | ||||||||||||
| 225 | columns => [ | ||||||||||||
| 226 | id => $id->(), | ||||||||||||
| 227 | note => { data_type => 'varchar', size => 20, is_nullable => 0, default_value => "it's" }, | ||||||||||||
| 228 | ], | ||||||||||||
| 229 | primary_key => [ 'id' ], | ||||||||||||
| 230 | } ] }, | ||||||||||||
| 231 | rows => [ { source => 'Note', values => { id => 1, note => 'a' } } ], | ||||||||||||
| 232 | }, | ||||||||||||
| 233 | expect => [ | ||||||||||||
| 234 | { rows_kept => { source => 'Note', find => { id => 1 }, is => { note => 'a' } } }, | ||||||||||||
| 235 | { read_back => { source => 'Note', create => { id => 2 }, is => { note => "it's" } } }, | ||||||||||||
| 236 | ], | ||||||||||||
| 237 | }, | ||||||||||||
| 238 | |||||||||||||
| 239 | { | ||||||||||||
| 240 | name => 'diff-default-expression-kept', | ||||||||||||
| 241 | since => 1, | ||||||||||||
| 242 | subject => { source => 'Stamp', column => 'created' }, | ||||||||||||
| 243 | input => { | ||||||||||||
| 244 | from => { sources => [ { | ||||||||||||
| 245 | name => 'Stamp', table => 'stamp', | ||||||||||||
| 246 | columns => [ | ||||||||||||
| 247 | id => $id->(), | ||||||||||||
| 248 | created => { data_type => 'timestamp', is_nullable => 0, | ||||||||||||
| 249 | default_value => \'CURRENT_TIMESTAMP' }, | ||||||||||||
| 250 | ], | ||||||||||||
| 251 | primary_key => [ 'id' ], | ||||||||||||
| 252 | } ] }, | ||||||||||||
| 253 | to => { sources => [ { | ||||||||||||
| 254 | name => 'Stamp', table => 'stamp', | ||||||||||||
| 255 | columns => [ | ||||||||||||
| 256 | id => $id->(), | ||||||||||||
| 257 | created => { data_type => 'timestamp', is_nullable => 0, | ||||||||||||
| 258 | default_value => \'CURRENT_TIMESTAMP' }, | ||||||||||||
| 259 | extra => { data_type => 'varchar', size => 20, is_nullable => 1 }, | ||||||||||||
| 260 | ], | ||||||||||||
| 261 | primary_key => [ 'id' ], | ||||||||||||
| 262 | } ] }, | ||||||||||||
| 263 | rows => [ { source => 'Stamp', values => { id => 1 } } ], | ||||||||||||
| 264 | }, | ||||||||||||
| 265 | expect => [ | ||||||||||||
| 266 | { rows_kept => { source => 'Stamp', find => { id => 1 } } }, | ||||||||||||
| 267 | { read_back => { source => 'Stamp', create => { id => 2 }, | ||||||||||||
| 268 | like => { created => qr/^\d{4}-\d\d-\d\d/ }, | ||||||||||||
| 269 | isnt => { created => 'CURRENT_TIMESTAMP' } } }, | ||||||||||||
| 270 | ], | ||||||||||||
| 271 | }, | ||||||||||||
| 272 | |||||||||||||
| 273 | { | ||||||||||||
| 274 | name => 'diff-default-removed', | ||||||||||||
| 275 | since => 1, | ||||||||||||
| 276 | subject => { source => 'Opt', column => 'c' }, | ||||||||||||
| 277 | input => { | ||||||||||||
| 278 | from => { sources => [ { | ||||||||||||
| 279 | name => 'Opt', table => 'opt', | ||||||||||||
| 280 | columns => [ | ||||||||||||
| 281 | id => $id->(), | ||||||||||||
| 282 | c => { data_type => 'varchar', size => 10, is_nullable => 1, default_value => 'x' }, | ||||||||||||
| 283 | ], | ||||||||||||
| 284 | primary_key => [ 'id' ], | ||||||||||||
| 285 | } ] }, | ||||||||||||
| 286 | to => { sources => [ { | ||||||||||||
| 287 | name => 'Opt', table => 'opt', | ||||||||||||
| 288 | columns => [ | ||||||||||||
| 289 | id => $id->(), | ||||||||||||
| 290 | c => { data_type => 'varchar', size => 10, is_nullable => 1 }, | ||||||||||||
| 291 | ], | ||||||||||||
| 292 | primary_key => [ 'id' ], | ||||||||||||
| 293 | } ] }, | ||||||||||||
| 294 | rows => [ { source => 'Opt', values => { id => 1, c => 'x' } } ], | ||||||||||||
| 295 | }, | ||||||||||||
| 296 | expect => [ | ||||||||||||
| 297 | { rows_kept => { source => 'Opt', find => { id => 1 }, is => { c => 'x' } } }, | ||||||||||||
| 298 | { read_back => { source => 'Opt', create => { id => 2 }, is => { c => undef } } }, | ||||||||||||
| 299 | ], | ||||||||||||
| 300 | }, | ||||||||||||
| 301 | |||||||||||||
| 302 | { | ||||||||||||
| 303 | name => 'diff-indexed-column-dropped', | ||||||||||||
| 304 | since => 3, | ||||||||||||
| 305 | subject => { source => 'Wide', column => 'drop_idx_col' }, | ||||||||||||
| 306 | input => { | ||||||||||||
| 307 | from => { sources => [ { | ||||||||||||
| 308 | name => 'Wide', table => 'wide', | ||||||||||||
| 309 | columns => [ | ||||||||||||
| 310 | id => $id->(), | ||||||||||||
| 311 | drop_idx_col => { data_type => 'integer', is_nullable => 1 }, | ||||||||||||
| 312 | wide_uq_one => { data_type => 'integer', is_nullable => 0 }, | ||||||||||||
| 313 | wide_uq_two => { data_type => 'integer', is_nullable => 0 }, | ||||||||||||
| 314 | ], | ||||||||||||
| 315 | primary_key => [ 'id' ], | ||||||||||||
| 316 | unique => [ [ wide_uq_idx => [ 'wide_uq_one', 'wide_uq_two' ] ] ], | ||||||||||||
| 317 | indexes => [ { name => 'wide_drop_idx', columns => [ 'drop_idx_col' ] } ], | ||||||||||||
| 318 | } ] }, | ||||||||||||
| 319 | to => { sources => [ { | ||||||||||||
| 320 | name => 'Wide', table => 'wide', | ||||||||||||
| 321 | columns => [ | ||||||||||||
| 322 | id => $id->(), | ||||||||||||
| 323 | wide_uq_two => { data_type => 'integer', is_nullable => 0 }, | ||||||||||||
| 324 | ], | ||||||||||||
| 325 | primary_key => [ 'id' ], | ||||||||||||
| 326 | } ] }, | ||||||||||||
| 327 | rows => [ { source => 'Wide', values => { id => 1, drop_idx_col => 1, wide_uq_one => 2, wide_uq_two => 3 } } ], | ||||||||||||
| 328 | }, | ||||||||||||
| 329 | expect => [ | ||||||||||||
| 330 | { fact => { name => 'column_names', source => 'Wide', is => [ 'id', 'wide_uq_two' ] } }, | ||||||||||||
| 331 | { fact => { name => 'unique_exists', source => 'Wide', columns => [ 'wide_uq_one', 'wide_uq_two' ], is => 0 } }, | ||||||||||||
| 332 | { fact => { name => 'index_count', source => 'Wide', columns => [ 'drop_idx_col' ], is => 0 } }, | ||||||||||||
| 333 | { rows_kept => { source => 'Wide', find => { id => 1 }, is => { wide_uq_two => 3 } } }, | ||||||||||||
| 334 | ], | ||||||||||||
| 335 | }, | ||||||||||||
| 336 | |||||||||||||
| 337 | { | ||||||||||||
| 338 | name => 'diff-fk-dropped', | ||||||||||||
| 339 | since => 1, | ||||||||||||
| 340 | subject => { source => 'Child', column => 'parent_id' }, | ||||||||||||
| 341 | input => { | ||||||||||||
| 342 | from => { sources => [ | ||||||||||||
| 343 | $parent->(), | ||||||||||||
| 344 | { | ||||||||||||
| 345 | name => 'Child', table => 'child', | ||||||||||||
| 346 | columns => [ | ||||||||||||
| 347 | id => $id->(), | ||||||||||||
| 348 | parent_id => { data_type => 'integer', is_nullable => 0 }, | ||||||||||||
| 349 | ], | ||||||||||||
| 350 | primary_key => [ 'id' ], | ||||||||||||
| 351 | relationships => [ | ||||||||||||
| 352 | { type => 'belongs_to', name => 'parent', source => 'Parent', cond => 'parent_id' }, | ||||||||||||
| 353 | ], | ||||||||||||
| 354 | }, | ||||||||||||
| 355 | ] }, | ||||||||||||
| 356 | to => { sources => [ | ||||||||||||
| 357 | $parent->(), | ||||||||||||
| 358 | { | ||||||||||||
| 359 | name => 'Child', table => 'child', | ||||||||||||
| 360 | columns => [ | ||||||||||||
| 361 | id => $id->(), | ||||||||||||
| 362 | parent_id => { data_type => 'integer', is_nullable => 0 }, | ||||||||||||
| 363 | ], | ||||||||||||
| 364 | primary_key => [ 'id' ], | ||||||||||||
| 365 | }, | ||||||||||||
| 366 | ] }, | ||||||||||||
| 367 | rows => [ | ||||||||||||
| 368 | { source => 'Parent', values => { id => 1 } }, | ||||||||||||
| 369 | { source => 'Child', values => { id => 1, parent_id => 1 } }, | ||||||||||||
| 370 | ], | ||||||||||||
| 371 | }, | ||||||||||||
| 372 | expect => [ | ||||||||||||
| 373 | { fact => { name => 'foreign_key_count', source => 'Child', is => 0 } }, | ||||||||||||
| 374 | { rows_kept => { source => 'Child', find => { id => 1 }, is => { parent_id => 1 } } }, | ||||||||||||
| 375 | { read_back => { source => 'Child', create => { id => 2, parent_id => 999 }, | ||||||||||||
| 376 | is => { parent_id => 999 } } }, | ||||||||||||
| 377 | ], | ||||||||||||
| 378 | }, | ||||||||||||
| 379 | |||||||||||||
| 380 | { | ||||||||||||
| 381 | name => 'diff-fk-added-to-new-unique', | ||||||||||||
| 382 | since => 1, | ||||||||||||
| 383 | subject => { source => 'Child', column => 'parent_code' }, | ||||||||||||
| 384 | input => { | ||||||||||||
| 385 | from => { sources => [ | ||||||||||||
| 386 | $parent->([ code => { data_type => 'varchar', size => 20, is_nullable => 0 } ]), | ||||||||||||
| 387 | { | ||||||||||||
| 388 | name => 'Child', table => 'child', | ||||||||||||
| 389 | columns => [ | ||||||||||||
| 390 | id => $id->(), | ||||||||||||
| 391 | parent_code => { data_type => 'varchar', size => 20, is_nullable => 0 }, | ||||||||||||
| 392 | ], | ||||||||||||
| 393 | primary_key => [ 'id' ], | ||||||||||||
| 394 | }, | ||||||||||||
| 395 | ] }, | ||||||||||||
| 396 | to => { sources => [ | ||||||||||||
| 397 | $parent->([ code => { data_type => 'varchar', size => 20, is_nullable => 0 } ], | ||||||||||||
| 398 | unique => [ [ parent_code_uq => [ 'code' ] ] ]), | ||||||||||||
| 399 | { | ||||||||||||
| 400 | name => 'Child', table => 'child', | ||||||||||||
| 401 | columns => [ | ||||||||||||
| 402 | id => $id->(), | ||||||||||||
| 403 | parent_code => { data_type => 'varchar', size => 20, is_nullable => 0 }, | ||||||||||||
| 404 | ], | ||||||||||||
| 405 | primary_key => [ 'id' ], | ||||||||||||
| 406 | relationships => [ | ||||||||||||
| 407 | { type => 'belongs_to', name => 'parent', source => 'Parent', | ||||||||||||
| 408 | cond => { 'foreign.code' => 'self.parent_code' } }, | ||||||||||||
| 409 | ], | ||||||||||||
| 410 | }, | ||||||||||||
| 411 | ] }, | ||||||||||||
| 412 | rows => [ | ||||||||||||
| 413 | { source => 'Parent', values => { id => 1, code => 'p1' } }, | ||||||||||||
| 414 | { source => 'Child', values => { id => 1, parent_code => 'p1' } }, | ||||||||||||
| 415 | ], | ||||||||||||
| 416 | }, | ||||||||||||
| 417 | expect => [ | ||||||||||||
| 418 | { fact => { name => 'unique_exists', source => 'Parent', columns => [ 'code' ], is => 1 } }, | ||||||||||||
| 419 | { fact => { name => 'foreign_key_count', source => 'Child', is => 1 } }, | ||||||||||||
| 420 | { rows_kept => { source => 'Child', find => { id => 1 }, is => { parent_code => 'p1' } } }, | ||||||||||||
| 421 | { rejects => { source => 'Child', create => { id => 2, parent_code => 'nobody' } } }, | ||||||||||||
| 422 | ], | ||||||||||||
| 423 | }, | ||||||||||||
| 424 | |||||||||||||
| 425 | { | ||||||||||||
| 426 | name => 'diff-constraint-changed', | ||||||||||||
| 427 | since => 1, | ||||||||||||
| 428 | subject => { source => 'Child', column => 'code' }, | ||||||||||||
| 429 | input => { | ||||||||||||
| 430 | from => { sources => [ | ||||||||||||
| 431 | $parent->(), | ||||||||||||
| 432 | { | ||||||||||||
| 433 | name => 'Child', table => 'child', | ||||||||||||
| 434 | columns => [ | ||||||||||||
| 435 | id => $id->(), | ||||||||||||
| 436 | parent_id => { data_type => 'integer', is_nullable => 0 }, | ||||||||||||
| 437 | code => { data_type => 'varchar', size => 20, is_nullable => 0 }, | ||||||||||||
| 438 | ], | ||||||||||||
| 439 | primary_key => [ 'id' ], | ||||||||||||
| 440 | relationships => [ | ||||||||||||
| 441 | { type => 'belongs_to', name => 'parent', source => 'Parent', cond => 'parent_id' }, | ||||||||||||
| 442 | ], | ||||||||||||
| 443 | }, | ||||||||||||
| 444 | ] }, | ||||||||||||
| 445 | to => { sources => [ | ||||||||||||
| 446 | $parent->(), | ||||||||||||
| 447 | { | ||||||||||||
| 448 | name => 'Child', table => 'child', | ||||||||||||
| 449 | columns => [ | ||||||||||||
| 450 | id => $id->(), | ||||||||||||
| 451 | parent_id => { data_type => 'integer', is_nullable => 0 }, | ||||||||||||
| 452 | code => { data_type => 'varchar', size => 20, is_nullable => 0 }, | ||||||||||||
| 453 | ], | ||||||||||||
| 454 | primary_key => [ 'id' ], | ||||||||||||
| 455 | unique => [ [ child_code => [ 'code' ] ] ], | ||||||||||||
| 456 | relationships => [ | ||||||||||||
| 457 | { type => 'belongs_to', name => 'parent', source => 'Parent', cond => 'parent_id' }, | ||||||||||||
| 458 | ], | ||||||||||||
| 459 | }, | ||||||||||||
| 460 | ] }, | ||||||||||||
| 461 | rows => [ | ||||||||||||
| 462 | { source => 'Parent', values => { id => 1 } }, | ||||||||||||
| 463 | { source => 'Child', values => { id => 1, parent_id => 1, code => 'c1' } }, | ||||||||||||
| 464 | ], | ||||||||||||
| 465 | }, | ||||||||||||
| 466 | expect => [ | ||||||||||||
| 467 | { fact => { name => 'unique_exists', source => 'Child', columns => [ 'code' ], is => 1 } }, | ||||||||||||
| 468 | { rows_kept => { source => 'Child', find => { id => 1 }, is => { code => 'c1' } } }, | ||||||||||||
| 469 | { rejects => { source => 'Child', create => { id => 2, parent_id => 1, code => 'c1' } } }, | ||||||||||||
| 470 | ], | ||||||||||||
| 471 | }, | ||||||||||||
| 472 | |||||||||||||
| 473 | { | ||||||||||||
| 474 | name => 'diff-fk-action-changed', | ||||||||||||
| 475 | since => 2, | ||||||||||||
| 476 | subject => { source => 'Child', column => 'parent_id' }, | ||||||||||||
| 477 | input => { | ||||||||||||
| 478 | from => { sources => [ | ||||||||||||
| 479 | $parent->(), | ||||||||||||
| 480 | { | ||||||||||||
| 481 | name => 'Child', table => 'child', | ||||||||||||
| 482 | columns => [ | ||||||||||||
| 483 | id => $id->(), | ||||||||||||
| 484 | parent_id => { data_type => 'integer', is_nullable => 0 }, | ||||||||||||
| 485 | ], | ||||||||||||
| 486 | primary_key => [ 'id' ], | ||||||||||||
| 487 | relationships => [ | ||||||||||||
| 488 | { type => 'belongs_to', name => 'parent', source => 'Parent', cond => 'parent_id' }, | ||||||||||||
| 489 | ], | ||||||||||||
| 490 | }, | ||||||||||||
| 491 | ] }, | ||||||||||||
| 492 | to => { sources => [ | ||||||||||||
| 493 | $parent->(), | ||||||||||||
| 494 | { | ||||||||||||
| 495 | name => 'Child', table => 'child', | ||||||||||||
| 496 | columns => [ | ||||||||||||
| 497 | id => $id->(), | ||||||||||||
| 498 | parent_id => { data_type => 'integer', is_nullable => 0 }, | ||||||||||||
| 499 | ], | ||||||||||||
| 500 | primary_key => [ 'id' ], | ||||||||||||
| 501 | relationships => [ | ||||||||||||
| 502 | { type => 'belongs_to', name => 'parent', source => 'Parent', | ||||||||||||
| 503 | cond => 'parent_id', attrs => { on_delete => 'CASCADE' } }, | ||||||||||||
| 504 | ], | ||||||||||||
| 505 | }, | ||||||||||||
| 506 | ] }, | ||||||||||||
| 507 | rows => [ | ||||||||||||
| 508 | { source => 'Parent', values => { id => 1 } }, | ||||||||||||
| 509 | { source => 'Child', values => { id => 1, parent_id => 1 } }, | ||||||||||||
| 510 | ], | ||||||||||||
| 511 | }, | ||||||||||||
| 512 | expect => [ | ||||||||||||
| 513 | { rows_kept => { source => 'Child', find => { id => 1 }, is => { parent_id => 1 } } }, | ||||||||||||
| 514 | { cascade_delete => { parent => 'Parent', parent_values => { id => 2 }, | ||||||||||||
| 515 | child => 'Child', child_values => { id => 3 }, | ||||||||||||
| 516 | link => { parent_id => 'id' } } }, | ||||||||||||
| 517 | ], | ||||||||||||
| 518 | }, | ||||||||||||
| 519 | |||||||||||||
| 520 | { | ||||||||||||
| 521 | name => 'diff-ident-drop', | ||||||||||||
| 522 | since => 1, | ||||||||||||
| 523 | subject => { source => 'MixedCase' }, | ||||||||||||
| 524 | input => { | ||||||||||||
| 525 | from => { sources => [ | ||||||||||||
| 526 | { name => 'Anchor', table => 'anchor', columns => [ id => $id->() ], | ||||||||||||
| 527 | primary_key => [ 'id' ] }, | ||||||||||||
| 528 | { name => 'MixedCase', table => 'MixedCase', columns => [ id => $id->() ], | ||||||||||||
| 529 | primary_key => [ 'id' ] }, | ||||||||||||
| 530 | { name => 'Order', table => 'order', columns => [ id => $id->() ], | ||||||||||||
| 531 | primary_key => [ 'id' ] }, | ||||||||||||
| 532 | ] }, | ||||||||||||
| 533 | to => { sources => [ | ||||||||||||
| 534 | { name => 'Anchor', table => 'anchor', columns => [ id => $id->() ], | ||||||||||||
| 535 | primary_key => [ 'id' ] }, | ||||||||||||
| 536 | ] }, | ||||||||||||
| 537 | rows => [ { source => 'Anchor', values => { id => 1 } } ], | ||||||||||||
| 538 | }, | ||||||||||||
| 539 | expect => [ | ||||||||||||
| 540 | { fact => { name => 'object_kind', source => 'MixedCase', is => undef } }, | ||||||||||||
| 541 | { fact => { name => 'object_kind', source => 'Order', is => undef } }, | ||||||||||||
| 542 | { fact => { name => 'object_kind', source => 'Anchor', is => 'table' } }, | ||||||||||||
| 543 | { rows_kept => { source => 'Anchor', find => { id => 1 } } }, | ||||||||||||
| 544 | ], | ||||||||||||
| 545 | }, | ||||||||||||
| 546 | |||||||||||||
| 547 | { | ||||||||||||
| 548 | name => 'diff-not-null-over-nulls', | ||||||||||||
| 549 | since => 1, | ||||||||||||
| 550 | subject => { source => 'Opt', column => 'c' }, | ||||||||||||
| 551 | input => { | ||||||||||||
| 552 | from => { sources => [ { | ||||||||||||
| 553 | name => 'Opt', table => 'opt', | ||||||||||||
| 554 | columns => [ | ||||||||||||
| 555 | id => $id->(), | ||||||||||||
| 556 | c => { data_type => 'varchar', size => 20, is_nullable => 1 }, | ||||||||||||
| 557 | ], | ||||||||||||
| 558 | primary_key => [ 'id' ], | ||||||||||||
| 559 | } ] }, | ||||||||||||
| 560 | to => { sources => [ { | ||||||||||||
| 561 | name => 'Opt', table => 'opt', | ||||||||||||
| 562 | columns => [ | ||||||||||||
| 563 | id => $id->(), | ||||||||||||
| 564 | c => { data_type => 'varchar', size => 20, is_nullable => 0 }, | ||||||||||||
| 565 | ], | ||||||||||||
| 566 | primary_key => [ 'id' ], | ||||||||||||
| 567 | } ] }, | ||||||||||||
| 568 | rows => [ | ||||||||||||
| 569 | { source => 'Opt', values => { id => 1, c => undef } }, | ||||||||||||
| 570 | { source => 'Opt', values => { id => 2, c => 'x' } }, | ||||||||||||
| 571 | ], | ||||||||||||
| 572 | }, | ||||||||||||
| 573 | expect => [ | ||||||||||||
| 574 | { rows_kept => { source => 'Opt', find => { id => 2 }, is => { c => 'x' } } }, | ||||||||||||
| 575 | { rejects => { source => 'Opt', create => { id => 3, c => undef } } }, | ||||||||||||
| 576 | ], | ||||||||||||
| 577 | }, | ||||||||||||
| 578 | |||||||||||||
| 579 | { | ||||||||||||
| 580 | name => 'diff-column-type-change', | ||||||||||||
| 581 | since => 1, | ||||||||||||
| 582 | subject => { source => 'Num', column => 'n' }, | ||||||||||||
| 583 | input => { | ||||||||||||
| 584 | from => { sources => [ { | ||||||||||||
| 585 | name => 'Num', table => 'num', | ||||||||||||
| 586 | columns => [ | ||||||||||||
| 587 | id => $id->(), | ||||||||||||
| 588 | n => { data_type => 'integer', is_nullable => 1 }, | ||||||||||||
| 589 | ], | ||||||||||||
| 590 | primary_key => [ 'id' ], | ||||||||||||
| 591 | } ] }, | ||||||||||||
| 592 | to => { sources => [ { | ||||||||||||
| 593 | name => 'Num', table => 'num', | ||||||||||||
| 594 | columns => [ | ||||||||||||
| 595 | id => $id->(), | ||||||||||||
| 596 | n => { data_type => 'varchar', size => 20, is_nullable => 1 }, | ||||||||||||
| 597 | ], | ||||||||||||
| 598 | primary_key => [ 'id' ], | ||||||||||||
| 599 | } ] }, | ||||||||||||
| 600 | rows => [ | ||||||||||||
| 601 | { source => 'Num', values => { id => 1, n => 5 } }, | ||||||||||||
| 602 | { source => 'Num', values => { id => 2, n => 7 } }, | ||||||||||||
| 603 | ], | ||||||||||||
| 604 | }, | ||||||||||||
| 605 | expect => [ | ||||||||||||
| 606 | { fact => { name => 'column_size', source => 'Num', column => 'n', is => 20 } }, | ||||||||||||
| 607 | { rows_kept => { source => 'Num', find => { id => 1 }, is => { n => '5' } } }, | ||||||||||||
| 608 | { rows_kept => { source => 'Num', find => { id => 2 }, is => { n => '7' } } }, | ||||||||||||
| 609 | { read_back => { source => 'Num', create => { id => 3, n => 'abc' }, is => { n => 'abc' } } }, | ||||||||||||
| 610 | ], | ||||||||||||
| 611 | }, | ||||||||||||
| 612 | |||||||||||||
| 613 | { | ||||||||||||
| 614 | name => 'diff-table-with-dependent-view', | ||||||||||||
| 615 | since => 1, | ||||||||||||
| 616 | subject => { source => 'BaseView' }, | ||||||||||||
| 617 | input => { | ||||||||||||
| 618 | from => { sources => [ | ||||||||||||
| 619 | $base->(), | ||||||||||||
| 620 | $view->('SELECT {{id}}, {{name}} FROM {{base}}', | ||||||||||||
| 621 | id => { data_type => 'integer' }, name => { data_type => 'varchar', size => 20 }), | ||||||||||||
| 622 | ] }, | ||||||||||||
| 623 | to => { sources => [ | ||||||||||||
| 624 | $base->(more => [ extra => { data_type => 'varchar', size => 20, is_nullable => 1 } ]), | ||||||||||||
| 625 | $view->('SELECT {{id}}, {{name}} FROM {{base}}', | ||||||||||||
| 626 | id => { data_type => 'integer' }, name => { data_type => 'varchar', size => 20 }), | ||||||||||||
| 627 | ] }, | ||||||||||||
| 628 | rows => [ { source => 'Base', values => { id => 1, name => 'x' } } ], | ||||||||||||
| 629 | }, | ||||||||||||
| 630 | expect => [ | ||||||||||||
| 631 | { fact => { name => 'object_kind', source => 'BaseView', is => 'view' } }, | ||||||||||||
| 632 | { fact => { name => 'column_names', source => 'Base', is => [ 'extra', 'id', 'name' ] } }, | ||||||||||||
| 633 | { rows_kept => { source => 'Base', find => { id => 1 }, is => { name => 'x' } } }, | ||||||||||||
| 634 | { search_by => { source => 'Base', create => { id => 2, name => 'y' }, | ||||||||||||
| 635 | through => 'BaseView', column => 'name', value => 'y' } }, | ||||||||||||
| 636 | ], | ||||||||||||
| 637 | }, | ||||||||||||
| 638 | |||||||||||||
| 639 | { | ||||||||||||
| 640 | name => 'diff-auto-increment-kept', | ||||||||||||
| 641 | since => 1, | ||||||||||||
| 642 | subject => { source => 'Counter', column => 'id' }, | ||||||||||||
| 643 | input => { | ||||||||||||
| 644 | from => { sources => [ { | ||||||||||||
| 645 | name => 'Counter', table => 'counter', | ||||||||||||
| 646 | columns => [ | ||||||||||||
| 647 | id => { data_type => 'integer', is_auto_increment => 1, is_nullable => 0 }, | ||||||||||||
| 648 | name => { data_type => 'varchar', size => 20, is_nullable => 1 }, | ||||||||||||
| 649 | ], | ||||||||||||
| 650 | primary_key => [ 'id' ], | ||||||||||||
| 651 | } ] }, | ||||||||||||
| 652 | to => { sources => [ { | ||||||||||||
| 653 | name => 'Counter', table => 'counter', | ||||||||||||
| 654 | columns => [ | ||||||||||||
| 655 | id => { data_type => 'integer', is_auto_increment => 1, is_nullable => 0 }, | ||||||||||||
| 656 | name => { data_type => 'varchar', size => 40, is_nullable => 1 }, | ||||||||||||
| 657 | ], | ||||||||||||
| 658 | primary_key => [ 'id' ], | ||||||||||||
| 659 | } ] }, | ||||||||||||
| 660 | rows => [ { source => 'Counter', values => { name => 'x' } } ], | ||||||||||||
| 661 | }, | ||||||||||||
| 662 | expect => [ | ||||||||||||
| 663 | { fact => { name => 'column_auto_increment', source => 'Counter', column => 'id', is => 1 } }, | ||||||||||||
| 664 | { rows_kept => { source => 'Counter', find => { name => 'x' } } }, | ||||||||||||
| 665 | { auto_key => { source => 'Counter', create => { name => 'y' } } }, | ||||||||||||
| 666 | ], | ||||||||||||
| 667 | }, | ||||||||||||
| 668 | |||||||||||||
| 669 | { | ||||||||||||
| 670 | name => 'diff-primary-key-order', | ||||||||||||
| 671 | since => 1, | ||||||||||||
| 672 | subject => { source => 'Pair' }, | ||||||||||||
| 673 | input => { | ||||||||||||
| 674 | from => { sources => [ { | ||||||||||||
| 675 | name => 'Pair', table => 'pair', | ||||||||||||
| 676 | columns => [ | ||||||||||||
| 677 | a => { data_type => 'integer', is_nullable => 0 }, | ||||||||||||
| 678 | b => { data_type => 'integer', is_nullable => 0 }, | ||||||||||||
| 679 | ], | ||||||||||||
| 680 | primary_key => [ 'b', 'a' ], | ||||||||||||
| 681 | } ] }, | ||||||||||||
| 682 | to => { sources => [ { | ||||||||||||
| 683 | name => 'Pair', table => 'pair', | ||||||||||||
| 684 | columns => [ | ||||||||||||
| 685 | a => { data_type => 'integer', is_nullable => 0 }, | ||||||||||||
| 686 | b => { data_type => 'integer', is_nullable => 0 }, | ||||||||||||
| 687 | c => { data_type => 'varchar', size => 20, is_nullable => 1 }, | ||||||||||||
| 688 | ], | ||||||||||||
| 689 | primary_key => [ 'b', 'a' ], | ||||||||||||
| 690 | } ] }, | ||||||||||||
| 691 | rows => [ { source => 'Pair', values => { a => 1, b => 2 } } ], | ||||||||||||
| 692 | }, | ||||||||||||
| 693 | expect => [ | ||||||||||||
| 694 | { fact => { name => 'primary_key_columns', source => 'Pair', is => [ 'b', 'a' ] } }, | ||||||||||||
| 695 | { rows_kept => { source => 'Pair', find => { a => 1, b => 2 } } }, | ||||||||||||
| 696 | ], | ||||||||||||
| 697 | }, | ||||||||||||
| 698 | |||||||||||||
| 699 | { | ||||||||||||
| 700 | name => 'diff-deploy-inherited', | ||||||||||||
| 701 | since => 4, | ||||||||||||
| 702 | subject => { source => 'Base' }, | ||||||||||||
| 703 | input => { | ||||||||||||
| 704 | deploy => { check => 'inherited' }, | ||||||||||||
| 705 | from => { sources => [ $base->() ] }, | ||||||||||||
| 706 | to => { sources => [ | ||||||||||||
| 707 | $base->(more => [ extra => { data_type => 'integer', is_nullable => 1 } ]), | ||||||||||||
| 708 | ] }, | ||||||||||||
| 709 | rows => [ { source => 'Base', values => { id => 1, name => 'x' } } ], | ||||||||||||
| 710 | }, | ||||||||||||
| 711 | expect => [ | ||||||||||||
| 712 | { fact => { name => 'column_names', source => 'Base', is => [ 'extra', 'id', 'name' ] } }, | ||||||||||||
| 713 | { rows_kept => { source => 'Base', find => { id => 1 }, is => { name => 'x' } } }, | ||||||||||||
| 714 | ], | ||||||||||||
| 715 | }, | ||||||||||||
| 716 | |||||||||||||
| 717 | { | ||||||||||||
| 718 | name => 'diff-deploy-dry-run', | ||||||||||||
| 719 | since => 4, | ||||||||||||
| 720 | subject => { source => 'Base' }, | ||||||||||||
| 721 | input => { | ||||||||||||
| 722 | deploy => { | ||||||||||||
| 723 | check => 'dry_run', | ||||||||||||
| 724 | unchanged => [ | ||||||||||||
| 725 | { fact => { name => 'column_names', source => 'Base', is => [ 'id', 'name' ] } }, | ||||||||||||
| 726 | ], | ||||||||||||
| 727 | }, | ||||||||||||
| 728 | from => { sources => [ $base->() ] }, | ||||||||||||
| 729 | to => { sources => [ | ||||||||||||
| 730 | $base->(more => [ extra => { data_type => 'integer', is_nullable => 1 } ]), | ||||||||||||
| 731 | ] }, | ||||||||||||
| 732 | rows => [ { source => 'Base', values => { id => 1, name => 'x' } } ], | ||||||||||||
| 733 | }, | ||||||||||||
| 734 | expect => [ | ||||||||||||
| 735 | { fact => { name => 'column_names', source => 'Base', is => [ 'extra', 'id', 'name' ] } }, | ||||||||||||
| 736 | { rows_kept => { source => 'Base', find => { id => 1 }, is => { name => 'x' } } }, | ||||||||||||
| 737 | ], | ||||||||||||
| 738 | }, | ||||||||||||
| 739 | |||||||||||||
| 740 | { | ||||||||||||
| 741 | name => 'diff-deploy-destructive-guard', | ||||||||||||
| 742 | since => 4, | ||||||||||||
| 743 | subject => { source => 'Gone' }, | ||||||||||||
| 744 | input => { | ||||||||||||
| 745 | deploy => { | ||||||||||||
| 746 | check => 'guard', | ||||||||||||
| 747 | unchanged => [ | ||||||||||||
| 748 | { fact => { name => 'object_kind', source => 'Gone', is => 'table' } }, | ||||||||||||
| 749 | { fact => { name => 'column_names', source => 'Keep', is => [ 'id' ] } }, | ||||||||||||
| 750 | ], | ||||||||||||
| 751 | }, | ||||||||||||
| 752 | from => { sources => [ | ||||||||||||
| 753 | { name => 'Keep', table => 'keep', columns => [ id => $id->() ], primary_key => [ 'id' ] }, | ||||||||||||
| 754 | { name => 'Gone', table => 'gone', columns => [ id => $id->() ], primary_key => [ 'id' ] }, | ||||||||||||
| 755 | ] }, | ||||||||||||
| 756 | to => { sources => [ | ||||||||||||
| 757 | { name => 'Keep', table => 'keep', | ||||||||||||
| 758 | columns => [ id => $id->(), extra => { data_type => 'integer', is_nullable => 1 } ], | ||||||||||||
| 759 | primary_key => [ 'id' ] }, | ||||||||||||
| 760 | ] }, | ||||||||||||
| 761 | rows => [ { source => 'Keep', values => { id => 1 } } ], | ||||||||||||
| 762 | }, | ||||||||||||
| 763 | expect => [ | ||||||||||||
| 764 | { fact => { name => 'object_kind', source => 'Gone', is => undef } }, | ||||||||||||
| 765 | { fact => { name => 'column_names', source => 'Keep', is => [ 'extra', 'id' ] } }, | ||||||||||||
| 766 | { rows_kept => { source => 'Keep', find => { id => 1 } } }, | ||||||||||||
| 767 | ], | ||||||||||||
| 768 | }, | ||||||||||||
| 769 | |||||||||||||
| 770 | ); | ||||||||||||
| 771 | |||||||||||||
| 772 | 50 | ▶ | sub cases { | ||||||||||
|
Subroutine
cases: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 773 | 50 | return DBIO::Util::deep_copy([ @CASES ]); | |||||||||||
| 774 | } | ||||||||||||
| 775 | |||||||||||||
| 776 | 4 | 1; | |||||||||||
| 777 | |||||||||||||
| 778 | __END__ | ||||||||||||