mirror of
https://github.com/DBD-SQLite/DBD-SQLite
synced 2025-06-07 14:19:10 -04:00
error cases
This commit is contained in:
parent
d0cad62012
commit
5e7eda37c4
2 changed files with 20 additions and 4 deletions
4
dbdimp.c
4
dbdimp.c
|
@ -1422,11 +1422,11 @@ HV* sqlite_db_table_column_metadata(pTHX_ SV *dbh, SV *dbname, SV *tablename, SV
|
|||
/* dbname may be NULL but (table|column)name may not be NULL */
|
||||
if (!tablename || !SvPOK(tablename)) {
|
||||
sqlite_error(dbh, -2, "table_column_metadata requires a table name");
|
||||
return FALSE;
|
||||
return metadata;
|
||||
}
|
||||
if (!columnname || !SvPOK(columnname)) {
|
||||
sqlite_error(dbh, -2, "table_column_metadata requires a column name");
|
||||
return FALSE;
|
||||
return metadata;
|
||||
}
|
||||
|
||||
#ifdef SQLITE_ENABLE_COLUMN_METADATA
|
||||
|
|
|
@ -10,9 +10,9 @@ use t::lib::Test qw/connect_ok @CALL_FUNCS/;
|
|||
use Test::More;
|
||||
use Test::NoWarnings;
|
||||
|
||||
plan tests => 11 * @CALL_FUNCS + 1;
|
||||
plan tests => 15 * @CALL_FUNCS + 1;
|
||||
for my $call_func (@CALL_FUNCS) {
|
||||
my $dbh = connect_ok();
|
||||
my $dbh = connect_ok(RaiseError => 1);
|
||||
$dbh->do('create table foo (id integer primary key autoincrement, "name space", unique_col integer unique)');
|
||||
|
||||
{
|
||||
|
@ -32,4 +32,20 @@ for my $call_func (@CALL_FUNCS) {
|
|||
ok !$data->{primary}, "name space is not a primary key";
|
||||
ok !$data->{not_null}, "name space is not null";
|
||||
}
|
||||
|
||||
# exceptions
|
||||
{
|
||||
local $SIG{__WARN__} = sub {};
|
||||
eval { $dbh->$call_func(undef, undef, 'name space', 'table_column_metadata') };
|
||||
ok $@, "successfully died when tablename is undef";
|
||||
|
||||
eval { $dbh->$call_func(undef, '', 'name space', 'table_column_metadata') };
|
||||
ok !$@, "not died when tablename is an empty string";
|
||||
|
||||
eval { $dbh->$call_func(undef, 'foo', undef, 'table_column_metadata') };
|
||||
ok $@, "successfully died when columnname is undef";
|
||||
|
||||
eval { $dbh->$call_func(undef, 'foo', '', 'table_column_metadata') };
|
||||
ok !$@, "not died when columnname is an empty string";
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue