mirror of
https://github.com/DBD-SQLite/DBD-SQLite
synced 2025-06-07 14:19:10 -04:00
dequote primary key info to resolve #45113
This commit is contained in:
parent
6b5460c83a
commit
a5971edfab
2 changed files with 28 additions and 0 deletions
|
@ -360,6 +360,7 @@ sub primary_key_info {
|
|||
}
|
||||
my $key_seq = 0;
|
||||
foreach my $pk_field (@pk) {
|
||||
$pk_field =~ s/(["'`])(.+)\1/$2/; # dequote
|
||||
push @pk_info, {
|
||||
TABLE_SCHEM => $row->{TABLE_SCHEM},
|
||||
TABLE_NAME => $row->{TABLE_NAME},
|
||||
|
|
27
t/42_primary_key_info.t
Normal file
27
t/42_primary_key_info.t
Normal file
|
@ -0,0 +1,27 @@
|
|||
#!/usr/bin/perl
|
||||
|
||||
use strict;
|
||||
BEGIN {
|
||||
$| = 1;
|
||||
$^W = 1;
|
||||
}
|
||||
|
||||
use t::lib::Test qw/connect_ok/;
|
||||
use Test::More;
|
||||
use Test::NoWarnings;
|
||||
|
||||
plan tests => 4 * 5 + 1;
|
||||
|
||||
for my $quote ('', qw/' " `/) {
|
||||
my $dbh = connect_ok( RaiseError => 1 );
|
||||
ok $dbh->do(
|
||||
"create table ${quote}foo${quote} (${quote}id${quote} integer primary key)"
|
||||
);
|
||||
my $sth = $dbh->primary_key_info(undef, undef, 'foo');
|
||||
my $pk = $sth->fetchrow_hashref;
|
||||
ok $pk->{TABLE_NAME} eq 'foo'; # dequoted
|
||||
ok $pk->{COLUMN_NAME} eq 'id'; # dequoted
|
||||
|
||||
($pk) = $dbh->primary_key(undef, undef, 'foo');
|
||||
ok $pk eq 'id';
|
||||
}
|
Loading…
Add table
Reference in a new issue