X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FSQL%2FTranslator%2FProducer%2FSQLite.pm;h=9cc92aff71c05b126aae1b800e2019b0c29ff3c1;hb=4384692aca82fb49ad4a49c08d7ddbde85bc4ecb;hp=9a2c49244a71aa1ef4bd3b80f4c5a2ad15289c7e;hpb=e533bcddea14f0d8a2c58ce6bdc06ec82ea1de8e;p=dbsrgits%2FSQL-Translator.git diff --git a/lib/SQL/Translator/Producer/SQLite.pm b/lib/SQL/Translator/Producer/SQLite.pm index 9a2c492..9cc92af 100644 --- a/lib/SQL/Translator/Producer/SQLite.pm +++ b/lib/SQL/Translator/Producer/SQLite.pm @@ -236,6 +236,9 @@ sub create_table if ($c->type eq "FOREIGN KEY") { push @field_defs, create_foreignkey($c); } + elsif ($c->type eq "CHECK") { + push @field_defs, create_check_constraint($c); + } next unless $c->type eq UNIQUE; push @constraint_defs, create_constraint($c); } @@ -245,6 +248,14 @@ sub create_table return (@create, $create_table, @index_defs, @constraint_defs ); } +sub create_check_constraint { + my $c = shift; + my $check = ''; + $check .= 'CONSTRAINT ' . _generator->quote( $c->name ) . ' ' if $c->name; + $check .= 'CHECK(' . $c->expression . ')'; + return $check; +} + sub create_foreignkey { my $c = shift;