Skip Menu |

This queue is for tickets about the SQL-Translator CPAN distribution.

Report information
The Basics
Id: 44420
Status: resolved
Priority: 0/
Queue: SQL-Translator

People
Owner: Nobody in particular
Requestors: wdhawes [...] gmail.com (daily)
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.09004
Fixed in: 0.09007



Subject: ON DELETE and ON UPDATE constraints may produce invalid SQL in SQL::Translator::Producer::SQLServer
If the variables $on_update and $on_delete contain empty strings in SQL::Translator::Producer::SQLServer, invalid SQL is produced as follows: CONSTRAINT ... ON DELETE ON UPDATE , Below is a simple patch that skips the ON DELETE and ON UPDATE clauses under these circumstances, so SQL Server can parse the output and set both actions to the default: Show quoted text
>diff -u C:\Perl\site\lib\SQL\Translator\Producer\SQLServer.pm
lib\SQL\Translator\Producer\SQLServer.pm --- C:\Perl\site\lib\SQL\Translator\Producer\SQLServer.pm Mon Mar 02 14:24:24 2009 +++ lib\SQL\Translator\Producer\SQLServer.pm Thu Mar 19 12:07:12 2009 @@ -297,11 +297,11 @@ $constraint->reference_table. ' (' . join( ', ', @rfields ) . ')'; my $on_delete = $constraint->on_delete; - if ( defined $on_delete && $on_delete ne "NO ACTION") { + if ( defined $on_delete && $on_delete ne '' && $on_delete ne "NO ACTION") { $c_def .= " ON DELETE $on_delete"; } my $on_update = $constraint->on_update; - if ( defined $on_update && $on_update ne "NO ACTION") { + if ( defined $on_update && $on_update ne '' && $on_update ne "NO ACTION") { $c_def .= " ON UPDATE $on_update"; } }
This issue has been resolved, although with a slightly different code change.