I'm not to be trusted with the chainsaw
Fabien Wernli [Thu, 25 Feb 2010 09:13:29 +0000 (09:13 +0000)]
lib/SQL/Translator/Producer/Oracle.pm
t/51-xml-to-oracle.t
t/51-xml-to-oracle_quoted.t
t/data/oracle/schema_diff_a.yaml
t/data/oracle/schema_diff_b.yaml
t/data/oracle/schema_diff_c.yaml

index 0844dc6..a52ee1b 100644 (file)
@@ -625,6 +625,16 @@ sub create_field {
         undef @size;
     }
 
+    #
+    # Fixes ORA-00906: missing right parenthesis
+               # if size is 0 or undefined
+    #
+    for (qw/varchar2/) {
+        if ( $data_type =~ /^($_)$/i ) {
+            $size[0] ||= $max_size{$_};
+        }
+    }
+
     $field_def .= " $data_type";
     if ( defined $size[0] && $size[0] > 0 ) {
         $field_def .= '(' . join( ',', @size ) . ')';
index d7cff87..06776a9 100644 (file)
@@ -48,9 +48,9 @@ my $want = [
   title varchar2(100) DEFAULT \'hello\' NOT NULL,
   description clob DEFAULT \'\',
   email varchar2(500),
-  explicitnulldef varchar2,
-  explicitemptystring varchar2 DEFAULT \'\',
-  emptytagdef varchar2 DEFAULT \'\',
+  explicitnulldef varchar2(4000),
+  explicitemptystring varchar2(4000) DEFAULT \'\',
+  emptytagdef varchar2(4000) DEFAULT \'\',
   another_id number(10) DEFAULT \'2\',
   timest date,
   PRIMARY KEY (id),
@@ -112,9 +112,9 @@ CREATE TABLE Basic (
   title varchar2(100) DEFAULT 'hello' NOT NULL,
   description clob DEFAULT '',
   email varchar2(500),
-  explicitnulldef varchar2,
-  explicitemptystring varchar2 DEFAULT '',
-  emptytagdef varchar2 DEFAULT '',
+  explicitnulldef varchar2(4000),
+  explicitemptystring varchar2(4000) DEFAULT '',
+  emptytagdef varchar2(4000) DEFAULT '',
   another_id number(10) DEFAULT '2',
   timest date,
   PRIMARY KEY (id),
index c5dddd7..292882d 100644 (file)
@@ -48,9 +48,9 @@ my $want = [
   "title" varchar2(100) DEFAULT \'hello\' NOT NULL,
   "description" clob DEFAULT \'\',
   "email" varchar2(500),
-  "explicitnulldef" varchar2,
-  "explicitemptystring" varchar2 DEFAULT \'\',
-  "emptytagdef" varchar2 DEFAULT \'\',
+  "explicitnulldef" varchar2(4000),
+  "explicitemptystring" varchar2(4000) DEFAULT \'\',
+  "emptytagdef" varchar2(4000) DEFAULT \'\',
   "another_id" number(10) DEFAULT \'2\',
   "timest" date,
   PRIMARY KEY ("id"),
@@ -112,9 +112,9 @@ CREATE TABLE "Basic" (
   "title" varchar2(100) DEFAULT 'hello' NOT NULL,
   "description" clob DEFAULT '',
   "email" varchar2(500),
-  "explicitnulldef" varchar2,
-  "explicitemptystring" varchar2 DEFAULT '',
-  "emptytagdef" varchar2 DEFAULT '',
+  "explicitnulldef" varchar2(4000),
+  "explicitemptystring" varchar2(4000) DEFAULT '',
+  "emptytagdef" varchar2(4000) DEFAULT '',
   "another_id" number(10) DEFAULT '2',
   "timest" date,
   PRIMARY KEY ("id"),
index 9b66596..fefb46d 100644 (file)
@@ -30,7 +30,7 @@ schema:
           size:
             - 0
         name:
-          data_type: varchar2(10)
+          data_type: varchar2
           default_value: ~
           extra: {}
           is_nullable: 0
@@ -39,9 +39,9 @@ schema:
           name: name
           order: 59
           size:
-            - 0
+            - 10
         other:
-          data_type: varchar2(10)
+          data_type: varchar2
           default_value: ~
           extra: {}
           is_nullable: 1
@@ -50,6 +50,6 @@ schema:
           name: other
           order: 59
           size:
-            - 0
+            - 10
       name: d_operator
       order: 11
index 9f050c5..1b9c898 100644 (file)
@@ -30,7 +30,7 @@ schema:
           size:
             - 0
         name:
-          data_type: nvarchar2(10)
+          data_type: nvarchar2
           default_value: ~
           extra: {}
           is_nullable: 0
@@ -39,9 +39,9 @@ schema:
           name: name
           order: 59
           size:
-            - 0
+            - 10
         other:
-          data_type: nvarchar2(10)
+          data_type: nvarchar2
           default_value: ~
           extra: {}
           is_nullable: 0
@@ -50,6 +50,6 @@ schema:
           name: other
           order: 59
           size:
-            - 0
+            - 10
       name: d_operator
       order: 11
index 78f2e5f..f565ce3 100644 (file)
@@ -30,7 +30,7 @@ schema:
           size:
             - 0
         name:
-          data_type: nvarchar2(10)
+          data_type: nvarchar2
           default_value: ~
           extra: {}
           is_nullable: 0
@@ -39,9 +39,9 @@ schema:
           name: name
           order: 59
           size:
-            - 0
+            - 10
         foo:
-          data_type: nvarchar2(10)
+          data_type: nvarchar2
           default_value: ~
           extra: {}
           is_nullable: 0
@@ -50,9 +50,9 @@ schema:
           name: foo
           order: 59
           size:
-            - 0
+            - 10
         other:
-          data_type: nvarchar2(10)
+          data_type: nvarchar2
           default_value: ~
           extra: {}
           is_nullable: 0
@@ -61,6 +61,6 @@ schema:
           name: other
           order: 59
           size:
-            - 0
+            - 10
       name: d_operator
       order: 11