Subject: | DBIx::RunSQL v0.08 cannot handle TRIGGERs of SQLite |
Date: | Wed, 23 May 2012 09:24:43 +0300 |
To: | bug-dbix-runsql [...] rt.cpan.org |
From: | Gabor Szabo <gabor [...] szabgab.com> |
hi Corion,
using the following sample script I juts tried to create
a database that has a TRIGGER in it. Unfortunately TRIGGERS
have semi-colons inside the statement as well which seem to
break the module.
======================================
use strict;
use warnings;
use DBIx::RunSQL;
my $dsn = "dbi:SQLite:dbname=t.db";
DBIx::RunSQL->create(
verbose => 0,
dsn => $dsn,
sql => 't.sql',
);
======================================
CREATE TABLE user (
id INTEGER PRIMARY KEY,
name VARCHAR(255)
);
CREATE TABLE emails (
uid INTEGER NOT NULL,
name VARCHAR(255) UNIQUE NOT NULL,
FOREIGN KEY (uid) REFERENCES user(id)
);
CREATE TRIGGER user_cleanup
BEFORE DELETE ON user FOR EACH ROW
BEGIN
DELETE FROM email WHERE uid=OLD.id;
END;
=====================================
The error I get:
DBD::SQLite::db do failed: near "id": syntax error at
/home/gabor/perl-5.14.2-desktop/lib/site_perl/5.14.2/DBIx/RunSQL.pm
line 169.
[SQL ERROR]: CREATE TRIGGER user_cleanup
BEFORE DELETE ON user FOR EACH ROW
BEGIN
DELETE FROM subscription WHERE uid=OLD.id
=====================================
regards
Gabor