CC: | Roland Meier <roland [...] meier69.de> |
Subject: | Error if SQL Server table name contains "'" |
Date: | Fri, 17 Jan 2020 12:05:30 +0000 |
To: | "bug-SQL-Translator [...] rt.cpan.org." <bug-SQL-Translator [...] rt.cpan.org> |
From: | "Meier, Roland" <roland.meier [...] continental-corporation.com> |
Hi,
SQL\Translator\Parser\SQLServer.pm
fails with the error message below if the parsed SQL Server DB contains a table with an <’> (apostrophe) char in its name.
* Distribution name and version (For example, "DBIx-SearchBuilder-0.46")
SQL-Translator 1.60
* Perl version (Find this by running the command perl -v)
ActiveState Perl
This is perl 5, version 12, subversion 4 (v5.12.4) built for MSWin32-x86-multi-thread
(with 9 registered patches, see perl -V for more detail)
* Operating System vendor and version (Find this by running the command uname -a)
Windows 10
MINGW32_NT-6.2 1.0.17(0.48/3/2) 2011-04-24 23:39 i686 Msys
* Exact cut and pasted error or warning messages
DBD::ODBC::db selectall_hashref failed: [Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near 'AD'. (SQL-42000)
Error: translate: Error with parser 'SQL::Translator::Parser::DBI': DBD::ODBC::db selectall_hashref failed: [Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near 'AD'. (SQL-42000)
[Microsoft][ODBC SQL Server Driver][SQL Server]Statement(s) could not be prepared. (SQL-42000) at D:/Tool/Common/Perl/v5.12.4.1205/site/lib/SQL/Translator/Parser/DBI/SQLServer.pm line 229.
* The shortest, clearest code you can manage to write which reproduces the bug described.
Working:
sp_fkeys @fktable_name = ['AD Portfolio$']
Not Working:
sp_fkeys @fktable_name = '['AD Portfolio$']'
* A patch against the latest released version of this distribution which fixes this bug.
Line 229 change
$h = $dbh->selectall_hashref("sp_fkeys NULL, \@fktable_name = '[$table_info->{TABLE_NAME}]'", 'FK_NAME');
to
$h = $dbh->selectall_hashref("sp_fkeys NULL, \@fktable_name = [$table_info->{TABLE_NAME}]", 'FK_NAME');
--
Mit freundlichen Grüßen, best regards
Roland Meier
\|||/
(o o)
==ooO==U==Ooo==
Continental Automotive GmbH, VNI HMI AE ASW IDDI 2
VDO-Straße 1, 64832 Babenhausen, Germany
Message body is not shown because it is too large.