Skip Menu |
 

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

Report information
The Basics
Id: 92968
Status: new
Priority: 0/
Queue: SQL-Translator

People
Owner: Nobody in particular
Requestors: chisel [...] chizography.net
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 0.11018
Fixed in: (no value)



Subject: sqlite->mysql stringifies hashrefs in CREATE TRIGGER
MIME-Version: 1.0
X-Mailer: MIME-tools 5.504 (Entity 5.504)
X-RT-Interface: Web
Message-ID: <rt-4.0.18-29685-1392222462-1631.0-0-0 [...] rt.cpan.org>
X-RT-Original-Encoding: utf-8
Content-Type: multipart/mixed; boundary="----------=_1392222462-29685-3"
X-RT-Encrypt: 0
X-RT-Sign: 0
Content-Length: 0
Content-Disposition: inline
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: binary
Content-Length: 982
Download (untitled) / with headers
text/plain 982b
::Parser::SQLite returns a hashref for 'trigger_action': https://metacpan.org/source/FREW/SQL-Translator-0.11018/lib/SQL/Translator/Parser/SQLite.pm#L519 ::Producer::MySQL expects $action->trigger to be a string: https://metacpan.org/source/FREW/SQL-Translator-0.11018/lib/SQL/Translator/Producer/MySQL.pm#L345 Giving output similar to the following when there's a multi-step trigger in SQLite: CREATE TRIGGER `delete_movie` after delete ON `movie` FOR EACH ROW BEGIN HASH(0x2fea3d0); END; I've attached a demo/failing test. It's not clear what the correct format of ->action() should be. If you give some direction I'm happy to investigate: * making ::Parser::SQLite return a string * making ::Producer::MySQL handle strings and SQLite-esque hashrefs similar to: https://metacpan.org/source/FREW/SQL-Translator-0.11018/lib/SQL/Translator/Producer/SQLite.pm#L344 * making ->action stringify automatically (this is slightly outside my experience and comfort zone)
Subject: 99.sqlite-to-mysql.t
MIME-Version: 1.0
Content-Type: application/octet-stream; name="99.sqlite-to-mysql.t"
X-Mailer: MIME-tools 5.504 (Entity 5.504)
Content-Disposition: inline; filename="99.sqlite-to-mysql.t"
Content-Transfer-Encoding: base64
Content-Length: 1342
#!/usr/bin/env perl use strict; use warnings; use SQL::Translator; use Test::More; # This is a hugely cut down schema source to illustrate the issue reported in # RT#xxxxxx # It's taken from a '.dump' of the XBMC sqlite schema my $sqlite_in =<<EOSCHEMA; CREATE TABLE movie ( idMovie integer PRIMARY KEY, idFile integer, c00 text, c01 text, -- and so on c22 text, c23 text, idSet integer); CREATE TABLE art(art_id INTEGER PRIMARY KEY, media_id INTEGER, media_type TEXT, TYPE TEXT, url TEXT); CREATE TRIGGER delete_movie AFTER DELETE ON movie FOR EACH ROW BEGIN DELETE FROM art WHERE media_id=old.idMovie AND media_type='movie'; DELETE FROM taglinks WHERE idMedia=old.idMovie AND media_type='movie'; END; EOSCHEMA my $sqlt = SQL::Translator->new( show_warnings => 1, no_comments => 1, from => "SQLite", quote_table_names => 1, quote_field_names => 1, ); # make sure we report/choose a MySQL version that produces VIEWs $sqlt->producer('MySQL', mysql_version => 5.5); my $out = $sqlt->translate(\$sqlite_in) or die "Translate error:".$sqlt->error; ok $out ne "", "Produced something!"; # we should NOT see a CREATE TRIGGER with a hashref-address in it unlike( $out, qr/FOR EACH ROW BEGIN HASH\(0x[0-9a-f]+\); END/ ); done_testing;


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.