From 36e1cbbe3abdb679798c6a519216b089a27e0080 Mon Sep 17 00:00:00 2001 From: Wakaba Date: Wed, 24 Jan 2024 17:31:03 +0900 Subject: [PATCH] Split MySQL server version-dependent tests; Added MySQL server version tests --- config/ci.json | 7 +++++++ t/type/basic-2.t | 49 ++++++++++++++++++++++++++++++++++++++++++++++++ t/type/basic.t | 49 ------------------------------------------------ 3 files changed, 56 insertions(+), 49 deletions(-) diff --git a/config/ci.json b/config/ci.json index d722767c..3e9adcfb 100644 --- a/config/ci.json +++ b/config/ci.json @@ -1,6 +1,13 @@ { "github": { "pmbp": "5.12+", + "env_matrix": { + "TEST_MYSQL_VERSION": [ + "mariadb", + "mysql5.6", + "mysql8" + ] + }, "gaa": true, "merger": true } diff --git a/t/type/basic-2.t b/t/type/basic-2.t index bc4c77b0..79e2216e 100644 --- a/t/type/basic-2.t +++ b/t/type/basic-2.t @@ -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 { diff --git a/t/type/basic.t b/t/type/basic.t index 95e3c3e3..f4e79246 100644 --- a/t/type/basic.t +++ b/t/type/basic.t @@ -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 ------