Improve trigger 'scope' attribute support (RT#119997)
[dbsrgits/SQL-Translator.git] / lib / SQL / Translator / Parser / SQLite.pm
index 259c0cf..251c97b 100644 (file)
@@ -447,10 +447,10 @@ cascade_def : cascade_update_def cascade_delete_def(?)
     cascade_delete_def cascade_update_def(?)
     { $return = {  on_delete => $item[1], on_update => $item[2][0] } }
 
-cascade_delete_def : /on\s+delete\s+(\w+)/i
+cascade_delete_def : /on\s+delete\s+(set null|set default|cascade|restrict|no action)/i
     { $return = $1}
 
-cascade_update_def : /on\s+update\s+(\w+)/i
+cascade_update_def : /on\s+update\s+(set null|set default|cascade|restrict|no action)/i
     { $return = $1}
 
 table_name : qualified_name
@@ -619,18 +619,20 @@ UNIQUE : /unique/i { 1 }
 
 SEMICOLON : ';'
 
-NAME : /["']?(\w+)["']?/ { $return = $1 }
+NAME : /\w+/
+    | DQSTRING
+    | SQSTRING
 
-VALUE : /[-+]?\.?\d+(?:[eE]\d+)?/
+DQSTRING : '"' <skip: ''> /((?:[^"]|"")+)/ '"'
+    { ($return = $item[3]) =~ s/""/"/g }
+
+SQSTRING : "'" <skip: ''> /((?:[^']|'')*)/ "'"
+    { ($return = $item[3]) =~ s/''/'/g }
+
+VALUE : /[-+]?\d*\.?\d+(?:[eE]\d+)?/
     { $item[1] }
-    | /'.*?'/
-    {
-        # remove leading/trailing quotes
-        my $val = $item[1];
-        $val    =~ s/^['"]|['"]$//g;
-        $return = $val;
-    }
-    | /NULL/
+    | SQSTRING
+    | /NULL/i
     { 'NULL' }
     | /CURRENT_TIMESTAMP/i
     { 'CURRENT_TIMESTAMP' }
@@ -728,6 +730,7 @@ sub parse {
             database_events     => $def->{'db_events'},
             action              => $def->{'action'},
             on_table            => $def->{'on_table'},
+            scope               => 'row', # SQLite only supports row triggers
         );
     }
 
@@ -737,7 +740,7 @@ sub parse {
 1;
 
 # -------------------------------------------------------------------
-# All wholsome food is caught without a net or a trap.
+# All wholesome food is caught without a net or a trap.
 # William Blake
 # -------------------------------------------------------------------