| 1 | package DBIO::MSSQL::Test::Conformance; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | # ABSTRACT: Answers the shared conformance case table for the SQL Server driver | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 6 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 6 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 6 | our $VERSION = '0.900007'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 6 | ▶ | use base 'DBIO::Test::Conformance'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 6 | ▶ | use DBI (); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 6 | ▶ | use DBIO::Exception (); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 6 | ▶ | use DBIO::MSSQL::Introspect (); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 6 | ▶ | use DBIO::MSSQL::Deploy (); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 6 | my $SEQ = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | # schema class => name of the database of its case | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 6 | my %DATABASE; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | # the connection details of the access path in use: [ dsn, user, pass ] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 7 | ▶ | sub _server { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_server: called CC=12 SCAR=36.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 7 | my @odbc = @ENV{qw(DBIO_TEST_MSSQL_ODBC_DSN DBIO_TEST_MSSQL_ODBC_USER DBIO_TEST_MSSQL_ODBC_PASS)}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 7 | my @sybase = @ENV{qw(DBIO_TEST_MSSQL_DSN DBIO_TEST_MSSQL_USER DBIO_TEST_MSSQL_PASS)}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | # The Bind list writes and reads text beyond ASCII. Over DBD::ODBC without Unicode | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | # support the storage takes that only with a UTF-8 client character set, which the | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | # FreeTDS ODBC driver reads from the locale of the process; the DSN names it | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | # instead (a DSN that names a ClientCharset keeps it). | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 7 | ▶ | $odbc[0] .= ($odbc[0] =~ /;\z/ ? '' : ';') . 'ClientCharset=UTF-8' | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition37%3/8
length($odbc[0] // "") and $odbc[0] =~ /\Adbi:ODBC:/i and not $odbc[0] =~ /ClientCharset=/i
length($odbc[0] // "") and $odbc[0] =~ /\Adbi:ODBC:/i
$odbc[0] // ""
MC/DC0%0/3
length($odbc[0] // "") and $odbc[0] =~ /\Adbi:ODBC:/i and not $odbc[0] =~ /ClientCharset=/i
$odbc[0]
$odbc[0] =~ /\Adbi:ODBC:/i
not $odbc[0] =~ /ClientCharset=/i
Truth table25%1/4
A and B and not(C)
A= $odbc[0]B= $odbc[0] =~ /\Adbi:ODBC:/iC= not $odbc[0] =~ /ClientCharset=/i
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | if length($odbc[0] // '') and $odbc[0] =~ /\Adbi:ODBC:/i and $odbc[0] !~ /ClientCharset=/i; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 0 | ▶ | return \@odbc if length($odbc[0] // '') and eval { require DBD::ODBC; 1 }; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition40%2/5
length($odbc[0] // "") and eval {
do {
require DBD::ODBC;
1
}
}
$odbc[0] // ""
MC/DC0%0/2
length($odbc[0] // "") and eval {
do {
require DBD::ODBC;
1
}
}
$odbc[0]
eval {
do {
require DBD::ODBC;
1
}
}
Truth table33%1/3
A and B
A= $odbc[0]B= eval {
do {
require DBD::ODBC;
1
}
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 0 | ▶ | return \@sybase if length($sybase[0] // '') and eval { require DBD::Sybase; 1 }; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition40%2/5
length($sybase[0] // "") and eval {
do {
require DBD::Sybase;
1
}
}
$sybase[0] // ""
MC/DC0%0/2
length($sybase[0] // "") and eval {
do {
require DBD::Sybase;
1
}
}
$sybase[0]
eval {
do {
require DBD::Sybase;
1
}
}
Truth table33%1/3
A and B
A= $sybase[0]B= eval {
do {
require DBD::Sybase;
1
}
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 7 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | # the DSN with its database swapped, in the spelling of the DBD (as | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | # DBIO::MSSQL::Deploy::_temp_dsn does) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | ▶ | sub _dsn_for { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_dsn_for: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | my ($class, $dsn, $database) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | ▶ | return $dsn if $dsn =~ s/\b((?:Database|dbname)=)[^;]*/$1$database/i; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | ▶ | my $key = $dsn =~ /^dbi:Sybase:/i ? 'database' : 'Database'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | $dsn =~ s/;\z//; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | return "$dsn;$key=$database"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | ▶ | sub _admin_dbh { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_admin_dbh: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | my ($class) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | my ($dsn, $user, $pass) = @{ $class->_server }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | return DBI->connect($dsn, $user, $pass, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | { RaiseError => 1, PrintError => 0, PrintWarn => 0, AutoCommit => 1 }); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 4 | ▶ | sub conformance_live_available { $_[0]->_server ? 1 : 0 } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
conformance_live_available: called CC=2 SCAR=7.6
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | ▶ | sub conformance_connect { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
conformance_connect: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | my ($class, $schema_class) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | ▶ | my $server = $class->_server | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | or DBIO::Exception->throw('conformance: no SQL Server configured'); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | my $name = $class->_database_name; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | $DATABASE{$schema_class} = $name; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | $schema_class->load_components('MSSQL'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | my ($dsn, $user, $pass) = @$server; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | return $schema_class->connect($class->_dsn_for($dsn, $name), $user, $pass, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | { AutoCommit => 1, RaiseError => 1, PrintError => 0, PrintWarn => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | $class->_long_read_len($dsn) }); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | # Over DBD::Sybase a value longer than the TEXTSIZE of the session (LongReadLen, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | # 32768 unless the connect info says otherwise) is refused when it is read, not | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | # cut (karr k47); the Bind list writes and reads 100000 characters, so the | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | # connection names a LongReadLen for them, as the message of that refusal says. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | # DBD::Sybase also reads a datetime as 'Oct 25 2026 04:02PM' unless the | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | # connection asks for datetime_setup (ISO). DBD::ODBC has 1 GiB by default and | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | # reads ISO; it is left alone. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | ▶ | sub _long_read_len { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_long_read_len: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | my ($class, $dsn) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | ▶ | return $dsn =~ /^dbi:Sybase:/i | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | ? (LongReadLen => 1_000_000, on_connect_call => 'datetime_setup') | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | : (); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | # The name of the next case's database. A hook for the test of the refusal | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | # (t/89): a subclass answers a name that is taken already. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | ▶ | sub _database_name { sprintf 'dbio_cf_%d_%d', $$, ++$SEQ } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_database_name: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | ▶ | sub _database_of { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_database_of: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | my ($class, $schema) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | my $name = $DATABASE{ ref $schema }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | ▶ | DBIO::Exception->throw('conformance: this schema was not connected through ' | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | . 'conformance_connect') unless defined $name; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | return $name; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 11 | ▶ | sub conformance_quote_ident { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
conformance_quote_ident: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 11 | my ($class, $schema, $name) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 11 | (my $inner = $name) =~ s/\]/]]/g; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 11 | return "[$inner]"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | ▶ | sub conformance_namespace { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
conformance_namespace: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | my ($class, $schema, $case) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | my $name = $class->_database_of($schema); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | my $admin = $class->_admin_dbh; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | my $ok = eval { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | my ($id) = $admin->selectrow_array('SELECT DB_ID(?)', undef, $name); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | ▶ | DBIO::Exception->throw("conformance: the database $name exists already; " | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | . 'refusing to use or drop a database the case did not create') | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | if defined $id; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | $admin->do("CREATE DATABASE [$name]"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | my $err = $@; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | $admin->disconnect; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | ▶ | die $err unless $ok; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | return { name => $name, created => 1 }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | ▶ | sub conformance_install { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
conformance_install: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | my ($class, $schema, $case) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | $schema->deploy; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | ▶ | sub conformance_cleanup { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
conformance_cleanup: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | my ($class, $schema, $case, $namespace) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | delete $DATABASE{ ref $schema }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | eval { $schema->storage->disconnect; 1 }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | ▶ | return unless ref $namespace eq 'HASH' and $namespace->{created}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $namespace eq "HASH" and $namespace->{"created"}
MC/DC0%0/2
ref $namespace eq "HASH" and $namespace->{"created"}
ref $namespace eq "HASH"
$namespace->{"created"}
Truth table0%0/3
A and B
A= ref $namespace eq "HASH"B= $namespace->{"created"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | my $name = $namespace->{name}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | my $admin = $class->_admin_dbh; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | my $ok = eval { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | $admin->do("IF DB_ID('$name') IS NOT NULL BEGIN " | |||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | . "ALTER DATABASE [$name] SET SINGLE_USER WITH ROLLBACK IMMEDIATE; " | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | . "DROP DATABASE [$name] END"); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | my $err = $@; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | $admin->disconnect; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | ▶ | DBIO::Exception->throw("conformance: cleanup of database $name failed: $err") | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | unless $ok; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | ▶ | sub conformance_diff_is_empty { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
conformance_diff_is_empty: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | my ($class, $schema, $case) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | my $diff = DBIO::MSSQL::Deploy->new(schema => $schema)->diff; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | ▶ | return $diff->has_changes ? 0 : 1; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | ▶ | sub conformance_upgrade { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
conformance_upgrade: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | my ($class, $schema, $to_class, $case) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | my $to = $class->_connect_target($schema, $to_class); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | DBIO::MSSQL::Deploy->new(schema => $to)->upgrade(allow_destructive => 1); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | return $to; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | ▶ | sub conformance_deploy { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
conformance_deploy: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | my ($class, $schema, $to_class, $case) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | my $to = $class->_connect_target($schema, $to_class); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | return DBIO::MSSQL::Deploy->new(schema => $to); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | # The target class, connected to the database of the installed schema. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | ▶ | sub _connect_target { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_connect_target: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | my ($class, $schema, $to_class) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | ▶ | my $server = $class->_server | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | or DBIO::Exception->throw('conformance: no SQL Server configured'); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | my $name = $class->_database_of($schema); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | $to_class->load_components('MSSQL'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | $DATABASE{$to_class} = $name; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | my ($dsn, $user, $pass) = @$server; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | return $to_class->connect($class->_dsn_for($dsn, $name), $user, $pass, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | { AutoCommit => 1, RaiseError => 1, PrintError => 0, PrintWarn => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | $class->_long_read_len($dsn) }); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 6 | ▶ | sub conformance_answered_through { { DDL => 2, Diff => 4, Bind => 1 } } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
conformance_answered_through: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 3 | ▶ | sub conformance_refusals { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
conformance_refusals: called CC=3 SCAR=12.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 3 | my ($class) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 3 | my $refusals = { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 'ddl-enum-value-apostrophe' => { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | kind => 'server', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | reason => qr/type 'enum'.*is refused: SQL Server has no enum type/s, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 'ddl-type-size-bit' => { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | kind => 'server', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | reason => qr/size '8' on type 'bit'.*is refused: bit has no length in SQL Server/s, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 'ddl-default-digit-string' => { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | kind => 'deviation', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | fact => qr/expected '007', read back '007 +'/, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | reason => 'a char(n) column pads the value with blanks to its length', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | # Diff list (karr k81) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 'diff-column-added-not-null-populated' => { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | kind => 'server', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | reason => qr/refuses to add the column base\.code: it is NOT NULL without a default/, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 'diff-not-null-over-nulls' => { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | kind => 'server', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | reason => qr/refuses to make the column opt\.c NOT NULL: table opt holds rows where it is NULL/, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | # Bind list (karr k81) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 'bind-empty-string' => { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | kind => 'deviation', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | fact => qr/the server accepted a row it must reject/, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | reason => "SQL Server converts the empty string to 0 for an integer column " | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | . "(Transact-SQL data type conversion: '' to int is 0), so n => '' is " | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | . 'stored as 0, not rejected; the empty string itself round-trips ' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | . 'exactly', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | # Over DBD::Sybase a bound string beyond ASCII is refused before it is sent | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | # (karr k49): FreeTDS would send it as a fixed-length CHAR and the server pad | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | # it. The case is a refusal there, a deviation over DBD::ODBC. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 3 | my $server = $class->_server; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 3 | ▶ | if ($server and $server->[0] =~ /^dbi:Sybase:/i) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$server and $server->[0] =~ /^dbi:Sybase:/i
MC/DC0%0/2
$server and $server->[0] =~ /^dbi:Sybase:/i
$server
$server->[0] =~ /^dbi:Sybase:/i
Truth table33%1/3
A and B
A= $serverB= $server->[0] =~ /^dbi:Sybase:/i
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 0 | $refusals->{'bind-non-ascii'} = { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | kind => 'server', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | reason => qr/has a character beyond ASCII.*Connect through DBD::ODBC/s, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 3 | return $refusals; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 0 | ▶ | sub conformance_fact { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
conformance_fact: not called CC=25 SCAR=64.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 0 | my ($class, $schema, $name, $args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | my $dbh = $schema->storage->dbh; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 0 | ▶ | if ($name eq 'table_in_namespace') { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | my ($n) = $dbh->selectrow_array( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 'SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES ' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | . 'WHERE table_schema = ? AND table_name = ?', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 0 | undef, $args->{namespace}, $args->{unqualified}); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 0 | ▶ | return $n ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | # a table "schema.table" is read from that schema (karr k72) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 0 | my $table = $args->{table}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 0 | ▶ | my @schemas = defined $table && $table =~ /\A([^.]+)\./ ? ($1) : (); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $table and $table =~ /\A([^.]+)\./
MC/DC0%0/2
defined $table and $table =~ /\A([^.]+)\./
defined $table
$table =~ /\A([^.]+)\./
Truth table0%0/3
A and B
A= defined $tableB= $table =~ /\A([^.]+)\./
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 0 | my $model = DBIO::MSSQL::Introspect->new(dbh => $dbh, schemas => \@schemas)->model; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 0 | my $entry = $model->{tables}{$table}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | ▶ | my @cols = @{ $args->{columns} || [] }; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$args->{'columns'} || []
MC/DC0%0/1
$args->{'columns'} || []
$args->{'columns'}
Truth table0%0/2
A
A= $args->{'columns'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 0 | ▶ | my $same = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 0 | my ($got) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 0 | ▶ | return 0 unless @$got == @cols; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 0 | ▶ | return (join("\0", map { $_ // '' } @$got) eq join("\0", @cols)) ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$_ // ""
MC/DC0%0/1
$_ // ""
$_
Truth table0%0/2
A
A= $_
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 0 | ▶ | if ($name eq 'object_kind') { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | ▶ | return $entry ? $entry->{kind} : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 0 | ▶ | if ($name eq 'table_name') { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 0 | ▶ | return $entry ? $entry->{table_name} : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 0 | ▶ | my $columns = $model->{columns}{$table} || []; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$model->{'columns'}{$table} || []
MC/DC0%0/1
$model->{'columns'}{$table} || []
$model->{'columns'}{$table}
Truth table0%0/2
A
A= $model->{'columns'}{$table}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 0 | ▶ | if ($name eq 'column_names') { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 0 | return [ map { $_->{column_name} } @$columns ]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 0 | ▶ | if ($name eq 'column_size') { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 0 | my ($col) = grep { $_->{column_name} eq $args->{column} } @$columns; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 0 | ▶ | return $col ? $col->{size} : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | ▶ | if ($name eq 'column_auto_increment') { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 0 | my ($col) = grep { $_->{column_name} eq $args->{column} } @$columns; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 0 | ▶ | return $col && $col->{is_identity} ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$col and $col->{"is_identity"}
MC/DC0%0/2
$col and $col->{"is_identity"}
$col
$col->{"is_identity"}
Truth table0%0/3
A and B
A= $colB= $col->{"is_identity"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 0 | ▶ | if ($name eq 'primary_key_columns') { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 0 | return [ map { $_->{column_name} } | |||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 0 | sort { $a->{pk_position} <=> $b->{pk_position} } | |||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 0 | grep { $_->{is_pk} } @$columns ]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 0 | ▶ | my $indexes = $model->{indexes}{$table} || {}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$model->{'indexes'}{$table} || {}
MC/DC0%0/1
$model->{'indexes'}{$table} || {}
$model->{'indexes'}{$table}
Truth table0%0/2
A
A= $model->{'indexes'}{$table}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 0 | ▶ | if ($name eq 'unique_exists') { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 0 | ▶ | return (grep { $_->{is_unique} and $same->($_->{columns}) } values %$indexes) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$_->{'is_unique'} && &$same($_->{'columns'})
MC/DC0%0/2
$_->{'is_unique'} && &$same($_->{'columns'})
$_->{'is_unique'}
&$same($_->{'columns'})
Truth table0%0/3
A && B
A= $_->{'is_unique'}B= &$same($_->{'columns'})
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 0 | ▶ | if ($name eq 'foreign_key_count') { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 0 | ▶ | return scalar @{ $model->{foreign_keys}{$table} || [] }; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$model->{'foreign_keys'}{$table} || []
MC/DC0%0/1
$model->{'foreign_keys'}{$table} || []
$model->{'foreign_keys'}{$table}
Truth table0%0/2
A
A= $model->{'foreign_keys'}{$table}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 0 | ▶ | if ($name eq 'index_count') { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 0 | return scalar grep { $same->($_->{columns}) } values %$indexes; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 0 | DBIO::Exception->throw("unknown conformance fact '$name'"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 6 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||