[DBD-SQLite] Re: test DBD::SQLite 1.26_05 - foreign keys!
David E. Wheeler
david at kineticode.com
Thu Oct 15 15:56:49 GMT 2009
On Oct 14, 2009, at 11:39 PM, Darren Duncan wrote:
> Also be sure to look at the section http://sqlite.org/foreignkeys.html#fk_enable
> , because you have to enable a pragma on each connect to use the
> foreign keys feature; it isn't yet on by default for backwards
> compatibility purposes.
I suggest you add something to the documentation showing how to always
enable this using a callback. Something like
my $enable_fks = sub { shift->do('PRAGMA foreign_keys = ON') };
my $dbh = DBI->connect($dsn, '', '', {
Callbacks => { connect => $enable_fks, },
});
If the user uses connect_cached, she should use this instead:
Callbacks => { 'connect_cached.reused' => $enable_fks, },
Best,
David
More information about the DBD-SQLite
mailing list