Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(column_info): use show columns to describe #440

Merged
merged 1 commit into from
Sep 17, 2024
Merged

fix(column_info): use show columns to describe #440

merged 1 commit into from
Sep 17, 2024

Conversation

johnjelinek
Copy link
Contributor

Resolves this error: You have an error in your SQL syntax
Fixes #439

Resolves this error: `You have an error in your SQL syntax`
@dveeden
Copy link
Collaborator

dveeden commented Aug 23, 2024

This looks fine. Could you add a test for this?

DBD-mysql/t/40catalog.t

Lines 258 to 303 in 8d671d1

#
# column_info() tests
#
SKIP: {
ok($dbh->do(qq{DROP TABLE IF EXISTS t1}), "cleaning up");
ok($dbh->do(qq{CREATE TABLE t1 (a INT PRIMARY KEY AUTO_INCREMENT,
b INT,
`a_` INT,
`a'b` INT,
bar INT
)}), "creating table");
#
# Bug #26603: (one part) add mysql_is_autoincrement
#
$sth= $dbh->column_info(undef, undef, "t1", 'a');
my ($info)= $sth->fetchall_arrayref({});
is($info->[0]->{mysql_is_auto_increment}, 1);
$sth= $dbh->column_info(undef, undef, "t1", 'b');
($info)= $sth->fetchall_arrayref({});
is($info->[0]->{mysql_is_auto_increment}, 0);
#
# Test that wildcards and odd names are handled correctly
#
$sth= $dbh->column_info(undef, undef, "t1", "a%");
($info)= $sth->fetchall_arrayref({});
is(scalar @$info, 3);
$sth= $dbh->column_info(undef, undef, "t1", "a" . $dbh->get_info(14) . "_");
($info)= $sth->fetchall_arrayref({});
is(scalar @$info, 1);
$sth= $dbh->column_info(undef, undef, "t1", "a'b");
($info)= $sth->fetchall_arrayref({});
is(scalar @$info, 1);
#
# The result set is ordered by TABLE_CAT, TABLE_SCHEM, TABLE_NAME and ORDINAL_POSITION.
#
$sth= $dbh->column_info(undef, undef, "t1", undef);
($info)= $sth->fetchall_arrayref({});
is(join(' ++ ', map { $_->{COLUMN_NAME} } @{$info}), "a ++ b ++ a_ ++ a'b ++ bar");
ok($dbh->do(qq{DROP TABLE IF EXISTS t1}), "cleaning up");
$dbh->disconnect();
};

@dveeden dveeden merged commit 6d56330 into perl5-dbi:master Sep 17, 2024
7 of 8 checks passed
@johnjelinek johnjelinek deleted the patch-1 branch September 17, 2024 11:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

You have an error in your SQL syntax
2 participants