Skip Menu |

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

Report information
The Basics
Id: 48688
Status: resolved
Worked: 1 min
Priority: 0/
Queue: SQL-Translator

People
Owner: kclark [...] cpan.org
Requestors: ddascalescu+perl [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.09007
Fixed in: (no value)



Subject: sqlite_version => 3.3 has no effect on generating IF EXISTS
I'm trying to deploy a schema to a SQLite database that may exist already or not. To do that, I'm passing to deploy() these arguments: { add_drop_table => 1, sqlite_version => 3.3 # for DROP TABLE *IF EXISTS* } With Producer::SQLite 1.59, passing that hashref to deploy() does not generate "DROP TABLE IF EXISTS" statements. It only generates "DROP TABLE". When generating the statements, in SQLite::Producer::create_table, sqlite_version is 0. I've traced the source of it becoming 0 to SQL::Translator::init, which appears to do nothing with this parameter, so that the line my $tr = SQL::Translator->new(%$sqltargs); in DBIx::Class::Storage::deployment_statements() is where sqlite_version is lost.
Dan, I'm not sure what to fix. Where (i.e., what package) is the "deploy" method you refer to? Can you recommend a fix or submit a patch (and tests)? ky
Show quoted text
> I'm not sure what to fix. Where (i.e., what package) is the "deploy" > method you refer to? Can you recommend a fix or submit a patch (and > tests)?
Hi Ken, Sorry for no test case (no tuits right now). This is an example of where I had to catch the exception caused by the lack of "IF EXISTS": http://github.com/marcusramberg/mojomojo/blob/276b48e5c2fcad276b6a3874a732d689d6bfe3fd/t/lib/MojoMojoTestSchema.pm#L88
This works. my $tr = SQL::Translator->new( from => 'MySQL', to => 'SQLite', add_drop_table => 1, no_comments => 1, producer_args => { sqlite_version => '3.3' }); my $file = 'db.sql'; my @commands = $tr->translate(filename => $file);
On Fri Dec 16 20:22:43 2011, SKNPP wrote: Show quoted text
> This works. > > my $tr = SQL::Translator->new( > from => 'MySQL', > to => 'SQLite', > add_drop_table => 1, > no_comments => 1, > producer_args => { > sqlite_version => '3.3' > }); > my $file = 'db.sql'; > my @commands = $tr->translate(filename => $file);
Right, my thought as well. Closing this bug as "looks like we fixed it in the meantime". Feel free to reopen it if the problem still persists.