- Geoff Cant <geoff@catalyst.net.nz>
- Gudmundur A. Thorisson <mummi@cshl.org>
- Guillermo Roditi <groditi@cpan.org>
+- Ivan Baidakou (basiliscos) <dmol@cpan.org>
- Jaime Soriano Pastor <jsoriano@tuenti.com>
- Jason Williams <smdwilliams@users.sourceforge.net>
- Johan Viklund <viklund@cpan.org>
Changes for SQL::Translator
+ * Add support for monotonically increasing SQLite autoincs (GH#47)
+
0.11021 2015-01-29
* Fix Oracle producer generating an unnecessary / at the end in case there
( $field->data_type =~ /^number?$/i && $field->size !~ /,/ ) )
}
+sub field_autoinc {
+ my ($self, $field) = @_;
+
+ return (
+ (
+ ($field->extra->{auto_increment_type}||'') eq 'monotonic'
+ and
+ $self->_ipk($field)
+ and
+ $field->is_auto_increment
+ )
+ ? 'AUTOINCREMENT'
+ : ''
+ );
+}
+
sub field {
my ($self, $field) = @_;
? ( 'INTEGER PRIMARY KEY' )
: ( $self->field_type($field) )
),
+ ( $self->field_autoinc($field) || () ),
$self->field_nullable($field),
$self->field_default($field, {
NULL => 1,
}
{
+ my $table = SQL::Translator::Schema::Table->new(
+ name => 'some_table',
+ );
+ $table->add_field(
+ name => 'id',
+ data_type => 'integer',
+ is_auto_increment => 1,
+ is_nullable => 0,
+ extra => {
+ auto_increment_type => 'monotonic',
+ },
+ );
+ $table->primary_key('id');
+ my $expected = [ qq<CREATE TABLE "some_table" (\n "id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL\n)>];
+ my $result = [SQL::Translator::Producer::SQLite::create_table($table, { no_comments => 1 })];
+ is_deeply($result, $expected, 'correctly built monotonicly autoincremened PK');
+}
+
+{
my $table = SQL::Translator::Schema::Table->new( name => 'foobar', fields => ['foo'] );
{