fix up is_nullable and is_unique being wrong at times
[dbsrgits/SQL-Translator-2.0-ish.git] / lib / SQL / Translator / Constants.pm
index e553816..3683f27 100644 (file)
@@ -1,20 +1,30 @@
 package SQL::Translator::Constants;
 use DBI qw(:sql_types);
-use Exporter ();
+use Sub::Exporter -setup => {
+    exports => [ @{$DBI::EXPORT_TAGS{sql_types}}, CHECK_C, FOREIGN_KEY, FULL_TEXT, SPATIAL, NOT_NULL, NORMAL, NULL, PRIMARY_KEY, UNIQUE, DEFAULT_PARSER_VERSION ],
+    groups => {
+        sqlt_types => [ @{$DBI::EXPORT_TAGS{sql_types}} ],
+        sqlt_fk_actions => [ qw(SQLT_FK_CASCADE SQLT_FK_RESTRICT SQLT_FK_SET_NULL SQLT_FK_NO_ACTION SQLT_FK_SET_DEFAULT) ],
+        sqlt_constants => [ qw(CHECK_C FOREIGN_KEY FULL_TEXT SPATIAL NOT_NULL NORMAL NULL PRIMARY_KEY UNIQUE DEFAULT_PARSER_VERSION) ],
+    }
+};
 
-BEGIN {
-    @ISA = qw(Exporter);
+use constant SQLT_FK_CASCADE     => 0;
+use constant SQLT_FK_RESTRICT    => 1;
+use constant SQLT_FK_SET_NULL    => 2;
+use constant SQLT_FK_NO_ACTION   => 3;
+use constant SQLT_FK_SET_DEFAULT => 4;
 
-    @EXPORT    = ();
-    @EXPORT_OK = ();
-    %EXPORT_TAGS = (
-        sqlt_types => [
-            qw(),
-            @{$DBI::EXPORT_TAGS{sql_types}}
-        ]
-    );
+use constant CHECK_C => 'CHECK';
+use constant FOREIGN_KEY => 'FOREIGN KEY';
+use constant FULL_TEXT => 'FULLTEXT';
+use constant SPATIAL => 'SPATIAL';
+use constant NOT_NULL => 'NOT NULL';
+use constant NORMAL => 'NORMAL';
+use constant NULL => 'NULL';
+use constant PRIMARY_KEY => 'PRIMARY KEY';
+use constant UNIQUE => 'UNIQUE';
 
-    Exporter::export_ok_tags(keys %EXPORT_TAGS);
-}
+use constant DEFAULT_PARSER_VERSION => 30000;
 
 1;