Re: test DBD::SQLite 1.26_05 - foreign keys!

"David E. Wheeler" <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.dbi.sybase.devel,gmane.comp.lang.perl.modules.dbd-sqlite
Message-ID <[email protected]>
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.