use SQL::Translator::Schema::Constants;
BEGIN {
- maybe_plan(9,
+ maybe_plan(12,
'SQL::Translator::Parser::SQLite');
}
SQL::Translator::Parser::SQLite->import('parse');
my $t1 = shift @tables;
is( $t1->name, 'person', "'Person' table" );
+ my @fields = $t1->get_fields;
+ is( scalar @fields, 6, 'Six fields in "person" table');
+ my $fld1 = shift @fields;
+ is( $fld1->name, 'person_id', 'First field is "person_id"');
+ is( $fld1->is_auto_increment, 1, 'Is an autoincrement field');
+
my $t2 = shift @tables;
is( $t2->name, 'pet', "'Pet' table" );
create table person (
- person_id INTEGER PRIMARY KEY,
- name varchar(20) not null,
- age integer,
+ person_id INTEGER PRIMARY KEY AUTOINCREMENT,
+ 'name' varchar(20) not null,
+ 'age' integer,
weight double(11,2),
iq tinyint default '0',
description text
create unique index u_name on person (name);
create table pet (
- pet_id int,
- person_id int references person (person_id),
- name varchar(30),
- age int,
+ "pet_id" int,
+ "person_id" int references person (person_id),
+ "name" varchar(30),
+ "age" int,
check ( age < 100 ),
primary key (pet_id, person_id)
);