Skip Menu |
 

This queue is for tickets about the Class-DBI-DDL CPAN distribution.

Report information
The Basics
Id: 13428
Status: resolved
Priority: 0/
Queue: Class-DBI-DDL

People
Owner: hanenkamp [...] cpan.org
Requestors: linux [...] johannes-niess.de
Cc:
AdminCc:

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



Subject: SQLite needs special treatment for auto_increment
Download (untitled) / with headers
text/plain 495b
Andrew, SQLite does support triggers, but somehow they don't work with Class::DBI::SQLite. The attachment is a hack around. It disables precreate_table. The create_table function was overloaded to skip adding the primary key line. Use is now: use Class::DBI::DDL::SQLite; __PACKAGE__->column_definitions([ [ primary => 'integer PRIMARY KEY AUTOINCREMENT' ] ]); The real solution would be making triggers work with Class::DBI::SQLite. Thank you for the great DDL packages! Johannes
Download SQLite.pm
text/x-perl 4k
package Class::DBI::DDL::SQLite; use 5.008; use strict; use warnings; our $VERSION = '1.01'; use base qw(Class::DBI::DDL); =head1 NAME Class::DBI::DDL::SQLite - Perform driver dependent work for SQLite =head1 DESCRIPTION Do not use this package directly. Intead, it will automatically be imported and used by L<Class::DBI::DDL> when the underlying database uses the L<DBD::mysql> driver. The only method here that works different from the default is C<pre_create_table>. This method is defined to do nothing since auto_increment works normally with the notation we've chosen and C<Class::DBI> is best written toward MySQL. =cut sub pre_create_table { } sub post_create_table { } sub pre_drop_table { } sub post_drop_table { } sub create_table { my $class = shift; my $on_create = shift; my $dbh = $class->db_Main; my $table = $class->table; my @tables = $class->_list_tables; if (!grep /^$table$/, @tables) { $class->_load_driver_specifics; $class->__ddl_helper->pre_create_table($class); my @decls; for my $column (@{ $class->column_definitions }) { push @decls, join(' ', @$column); } # my @primary = $class->primary_columns; # push @decls, sprintf('PRIMARY KEY (%s)', join(',', @primary)); for my $index (@{ $class->index_definitions }) { my $type = $$index[0]; if ($type =~ /unique/i) { if (ref $$index[1]) { push @decls, sprintf('UNIQUE (%s)', join(',', @{$$index[1]})); } else { push @decls, sprintf('UNIQUE (%s)', join(',', @$index[1 .. $#$index])); } } elsif ($type =~ /foreign/i) { my @from = ref $$index[1] ? @{$$index[1]} : ($$index[1]); my $table = $$index[2]; my @to = ref $$index[3] ? @{$$index[3]} : ($$index[3]); push @decls, sprintf('FOREIGN KEY (%s) REFERENCES %s (%s)', join(',', @from), $table->table, join(',', @to)); } else { Class::DBI::_croak "Unknown index type $type."; } } $class->sql_create_table(join(', ', @decls))->execute; $class->__ddl_helper->post_create_table($class); if (defined $on_create and ref $on_create eq 'CODE') { &$on_create; } } } =head1 SEE ALSO L<Class::DBI>, L<DBI>, L<Class::DBI::DDL>, L<DBD::SQLite> =head1 AUTHOR Johannes Niess =head1 LICENSE AND COPYRIGHT Copyright 2005 Johannes Niess. All Rights Reserved. This module is free software and is distributed under the same license as Perl itself. =cut 1
Download (untitled) / with headers
text/plain 1.1k
I just uploaded Class::DBI::DDL 1.02 to the PAUSE server. The new version includes tests for SQLite. I ran into no problems running the tests and I'm not sure I understand your report. Can you give me a test case that will allow me to repeat your error? Also, I tested with SQLite version 3.1.3, if that makes a difference. I also do not have Class::DBI::SQLite installed as the Class::DBI::{mysql,PG,SQLite,etc.} aren't necessary to use Class::DBI::DDL. I'm beginning to take an interest in Class::DBI again, so I could make another release soon if you can get me details. Cheers, Sterling [guest - Sun Jun 26 16:13:55 2005]: Show quoted text
> Andrew, > > SQLite does support triggers, but somehow they don't work with > Class::DBI::SQLite. The attachment is a hack around. It disables > precreate_table. The create_table function was overloaded to skip > adding the primary key line. Use is now: > > use Class::DBI::DDL::SQLite; > __PACKAGE__->column_definitions([ > [ primary => 'integer PRIMARY KEY AUTOINCREMENT' ] > ]); > > > The real solution would be making triggers work with > Class::DBI::SQLite. > Thank you for the great DDL packages! > > Johannes


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.