Skip Menu |

This queue is for tickets about the DBD-SQLite CPAN distribution.

Report information
The Basics
Id: 50655
Status: resolved
Priority: 0/
Queue: DBD-SQLite

People
Owner: Nobody in particular
Requestors: dwheeler [...] cpan.org
Cc:
AdminCc:

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



Subject: Feature Request: Add Explicit Foreign Key Support
Date: Mon, 19 Oct 2009 10:17:02 -0700
To: bug-DBD-SQLite [...] rt.cpan.org
From: "David E. Wheeler" <dwheeler [...] cpan.org>
In the short term, 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, }, Longer term, it'd be ideal if there was a database handle attribute one could set to turn this on: $dbh->{sqlite_foreign_keys} = 1; It's be useable in connect() too, of course. Is there a C api call to do this, so you could bypass the PRAGMA SQL call? Best, David
As of 1.26_06, foreign key support is enabled by default. Marked as resolved. On Mon Oct 19 13:17:29 2009, DWHEELER wrote: Show quoted text
> In the short term, 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, }, > > Longer term, it'd be ideal if there was a database handle attribute > one could set to turn this on: > > $dbh->{sqlite_foreign_keys} = 1; > > It's be useable in connect() too, of course. Is there a C api call
to Show quoted text
> do this, so you could bypass the PRAGMA SQL call? > > Best, > > David >