The RDBO docs claim that:

    CREATE TABLE mytable
    (
      id   INTEGER PRIMARY KEY AUTOINCREMENT,
      ...
    );

is the supported syntax for auto-detecting a serial column in SQLite. The test
case below fails to prove this out however.

I'd love to know if the test is wrong, or something is amiss with
Rose::DBx::TestDB, or the sqlite version, or if this really is a bug. Or...


----------------
use Test::More tests => 5;

use Rose::DB::Object::Loader;
use Rose::DBx::TestDB;

my $db = Rose::DBx::TestDB->new;

ok( $db->dbh->do(
        qq{
CREATE TABLE foo (
  id       integer primary key autoincrement, /* docs say == serial */
  name     varchar(16)
  );
}
    ),
    "table foo created"
);

{

    package MyMetadata;
    use base qw( Rose::DB::Object::Metadata );

    # we override just this method since we don't actually need/want to
    # connect to the db, as the standard init_db() would. We need to
    # re-use our existing $db.
    sub init_db {
        my ($self) = shift;
        $self->{'db_id'} = $db->{'id'};
        return $db;
    }

    package MyRDBO;
    use base qw( Rose::DB::Object );

    sub meta_class {'MyMetadata'}
}

ok( my $loader = Rose::DB::Object::Loader->new(
        db            => $db,
        base_class    => 'MyRDBO',
        class_prefix  => 'MyRDBO',
        with_managers => 0,
    ),
    "loader obj created"
);

ok( $loader->make_classes, "make classes" );

ok( my $foo = MyRDBO::Foo->new, "new Foo" );

is( $foo->meta->column('id')->type, 'serial', "Foo id is a serial column" );


-- 
Peter Karman  .  [EMAIL PROTECTED]  .  http://peknet.com/


-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object

Reply via email to