- Notifications
You must be signed in to change notification settings - Fork 77
#475: Improve error message for unsupported named parameters #476
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
Open
JKDingwall wants to merge 3 commits into perl5-dbi:master Choose a base branch from JKDingwall:JKDingwall/475-named-parameter-error-message
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline, and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits Select commit Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
| @@ -1725,6 +1725,10 @@ parameter value and C<execute> the statement again, with other values | |||||
unchanged. The attribute remains properly populated after the C<finish> | ||||||
method is called, with the values from the last execution. | ||||||
| ||||||
MySQL does not support named place holders in C<bind_param>. If a | ||||||
string is passed to C<bind_param> as the parameter index then a | ||||||
"named parameters are unsupported" error is reported. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggested change
btw. I think | ||||||
| ||||||
=item mysql_gtids | ||||||
| ||||||
Returns GTID(s) if GTID session tracking is ensabled in the server via | ||||||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
use strict; | ||
use warnings; | ||
| ||
use Test::More; | ||
use DBI; | ||
use vars qw($test_dsn $test_user $test_password); | ||
use lib 't', '.'; | ||
require 'lib.pl'; | ||
| ||
my $dbh; | ||
eval {$dbh = DBI->connect($test_dsn, $test_user, $test_password, | ||
{ RaiseError => 1, AutoCommit => 1}) or ServerError();}; | ||
| ||
if ($@) { | ||
plan skip_all => "no database connection"; | ||
} | ||
plan tests => 11; | ||
| ||
SKIP: { | ||
skip 'SET @@auto_increment_offset needs MySQL >= 5.0.2', 2 unless $dbh->{mysql_serverversion} >= 50002; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. DBD::mysql needs MySQL 8.0 or newer, so this shouldn't be needed. But on the other hand... it doesn't hurt either. | ||
ok $dbh->do('SET @@auto_increment_offset = 1'); | ||
ok $dbh->do('SET @@auto_increment_increment = 1'); | ||
} | ||
| ||
my $create= <<EOT; | ||
CREATE TEMPORARY TABLE dbd_mysql_t45bindnamedparam ( | ||
id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, | ||
num INT(3)) | ||
EOT | ||
| ||
ok $dbh->do($create), "create table dbd_mysql_t45bindnamedparam"; | ||
| ||
ok $dbh->do("INSERT INTO dbd_mysql_t45bindnamedparam VALUES(NULL, 1)"), "insert into dbd_mysql_t45bindnamedparam (null, 1)"; | ||
| ||
my $rows; | ||
ok ($rows= $dbh->selectall_arrayref("SELECT * FROM dbd_mysql_t45bindnamedparam")); | ||
| ||
is $rows->[0][1], 1, "\$rows->[0][1] == 1"; | ||
| ||
ok (my $sth = $dbh->prepare("SELECT * FROM dbd_mysql_t45bindnamedparam WHERE num = :num")); | ||
| ||
$dbh->{PrintError} = 0; | ||
$dbh->{PrintWarn} = 0; | ||
eval {($sth->bind_param(":num", 1, SQL_INTEGER()));}; | ||
$dbh->{PrintError} = 1; | ||
$dbh->{PrintWarn} = 1; | ||
ok defined($DBI::errstr); | ||
| ||
like($DBI::errstr, qr/named parameters are unsupported/, 'bind_param reports exepcted error with named parameter'); | ||
| ||
ok ($sth->finish()); | ||
| ||
ok ($dbh->disconnect()); |
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a test for this error?
What if there are multiple params. Does it indicate which one is the issue? Could/should it?