Skip to content

Commit

Permalink
Split MySQL server version-dependent tests; Added MySQL server versio…
Browse files Browse the repository at this point in the history
…n tests
  • Loading branch information
wakaba committed Jan 24, 2024
1 parent 8b50815 commit 36e1cbb
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 49 deletions.
7 changes: 7 additions & 0 deletions config/ci.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
{
"github": {
"pmbp": "5.12+",
"env_matrix": {
"TEST_MYSQL_VERSION": [
"mariadb",
"mysql5.6",
"mysql8"
]
},
"gaa": true,
"merger": true
}
Expand Down
49 changes: 49 additions & 0 deletions t/type/basic-2.t
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,55 @@ use Dongry::Database;

my $dsn = test_dsn 'root';

# ------ null_filled ------

sub _null_filled : Test(14) {
my $db = new_db schema => {
table1 => {
primary_keys => ['id'],
type => {value => 'null_filled'},
_create => 'CREATE TABLE table1 (id INT, value BINARY(12))',
},
};
$db->insert ('table1', [{id => 123, value => 'abc'}]);

my $row = $db->table ('table1')->find ({id => 123});
is $row->get ('value'), 'abc';
is $row->get_bare ('value'), "abc\x00\x00\x00\x00\x00\x00\x00\x00\x00";

$row->update ({value => 'xyz'});
$row->reload;
is $row->get ('value'), 'xyz';
is $row->get_bare ('value'), "xyz\x00\x00\x00\x00\x00\x00\x00\x00\x00";

$row->update ({value => '1234567890123456'});
$row->reload;
is $row->get ('value'), '123456789012';
is $row->get_bare ('value'), '123456789012';

$row->update ({value => undef});
$row->reload;
is $row->get ('value'), undef;
is $row->get_bare ('value'), undef;

$row->update ({value => ''});
$row->reload;
is $row->get ('value'), '';
is $row->get_bare ('value'),
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00";

$row->update ({value => "\x00"});
$row->reload;
is $row->get ('value'), '';
is $row->get_bare ('value'),
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00";

$row->update ({value => "ab\x00c"});
$row->reload;
is $row->get ('value'), "ab\x00c";
is $row->get_bare ('value'), "ab\x00c\x00\x00\x00\x00\x00\x00\x00\x00";
} # _null_filled

# ------ text_null_filled ------

test {
Expand Down
49 changes: 0 additions & 49 deletions t/type/basic.t
Original file line number Diff line number Diff line change
Expand Up @@ -564,55 +564,6 @@ sub _text_as_ref_not_ref : Test(3) {
is $DBIx::ShowSQL::SQLCount, 0;
} # _text_as_ref_not_ref

# ------ null_filled ------

sub _null_filled : Test(14) {
my $db = new_db schema => {
table1 => {
primary_keys => ['id'],
type => {value => 'null_filled'},
_create => 'CREATE TABLE table1 (id INT, value BINARY(12))',
},
};
$db->insert ('table1', [{id => 123, value => 'abc'}]);

my $row = $db->table ('table1')->find ({id => 123});
is $row->get ('value'), 'abc';
is $row->get_bare ('value'), "abc\x00\x00\x00\x00\x00\x00\x00\x00\x00";

$row->update ({value => 'xyz'});
$row->reload;
is $row->get ('value'), 'xyz';
is $row->get_bare ('value'), "xyz\x00\x00\x00\x00\x00\x00\x00\x00\x00";

$row->update ({value => '1234567890123456'});
$row->reload;
is $row->get ('value'), '123456789012';
is $row->get_bare ('value'), '123456789012';

$row->update ({value => undef});
$row->reload;
is $row->get ('value'), undef;
is $row->get_bare ('value'), undef;

$row->update ({value => ''});
$row->reload;
is $row->get ('value'), '';
is $row->get_bare ('value'),
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00";

$row->update ({value => "\x00"});
$row->reload;
is $row->get ('value'), '';
is $row->get_bare ('value'),
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00";

$row->update ({value => "ab\x00c"});
$row->reload;
is $row->get ('value'), "ab\x00c";
is $row->get_bare ('value'), "ab\x00c\x00\x00\x00\x00\x00\x00\x00\x00";
} # _null_filled

# ------ set ------


Expand Down

0 comments on commit 36e1cbb

Please sign in to comment.