[Maypole] [ANNOUNCE] Class::DBI::Loader 0.12

From: Sebastian Riedel (sri at oook.de)
Date: Thu Jan 27 2005 - 07:11:40 GMT


Hi,

I just uploaded a new version of Class::DBI::Loader to CPAN.

It now supports automatic relationships for all three databases
(PostgreSQL, MySQL and SQLite)!

The code for MySQL was contributed by Adam Anderson is completely
untested by me, so i count on your feedback!

SQLite needs this small patch to be applied to Class::DBI::SQLite. (Lets
hope Tatsuhiku applies it soon to the CPAN version)
It bypasses a limitation in SQL::Parser.

35a36,38
> # sri: Needed for auto relationships with Class::DBI::Loader
> $sql =~ s/REFERENCES\s+\w+//gsi;
>

And the obligatory example:

use DBI;
use Class::DBI::Loader;

unlink 'test.db' if -e 'test.db';

my $dbh = DBI->connect('dbi:SQLite2:test.db');

$dbh->do(<<"");
CREATE TABLE foo (
    id INTEGER PRIMARY KEY,
    test TEXT
);

$dbh->do(<<"");
CREATE TABLE bar (
    id INTEGER PRIMARY KEY,
    test TEXT
);

$dbh->do(<<"");
CREATE TABLE yada (
    id INTEGER PRIMARY KEY,
    foo INTEGER REFERENCES foo,
    bar INTEGER REFERENCES bar
);

$dbh->disconnect;

my $loader = Class::DBI::Loader->new(
    dsn => 'dbi:SQLite2:test.db',
    namespace => 'Data',
    relationships => 1,
    debug => 1
);

Yes i'm exploiting things a bit, but who cares when you get automatic
relationships, right?

And welcome to a new highly dynamic world! ;)

-- 
sebastian

_______________________________________________ maypole mailing list maypole at lists.netthink.co.uk http://lists.netthink.co.uk/listinfo/maypole



This archive was generated by hypermail 2.1.3 : Thu Feb 24 2005 - 22:25:57 GMT