sqlt-diff option to quote names
[dbsrgits/SQL-Translator.git] / script / sqlt-diff
index f2ee1fb..03da501 100755 (executable)
@@ -53,6 +53,8 @@ Options:
   --ignore-proc-sql    Ignore procedure SQL differences
   --no-batch-alters    Do not clump multile alters to the same table into a
                        single ALTER TABLE statement where possible.
+  --quote=<character>  Use <character> to quote all table and field
+                       names in statements
 
 =head1 DESCRIPTION
 
@@ -115,7 +117,8 @@ $VERSION = '1.59';
 
 my ( @input, $list, $help, $debug, $trace, $caseopt, $ignore_index_names,
     $ignore_constraint_names, $output_db, $mysql_parser_version,
-    $ignore_view_sql, $ignore_proc_sql, $no_batch_alters );
+    $ignore_view_sql, $ignore_proc_sql, $no_batch_alters, $quote
+);
 for my $arg ( @ARGV ) {
     if ( $arg =~ m/^-?-l(ist)?$/ ) {
         $list = 1;
@@ -150,18 +153,21 @@ for my $arg ( @ARGV ) {
     elsif ( $arg =~ m/^--ignore-proc-sql$/ ) {
         $ignore_proc_sql = 1;
     }
+    elsif ( $arg =~ m/^--quote=(.)$/ ) {
+        $quote = $1;
+    }
     elsif ( $arg =~ m/^([^=]+)=(.+)$/ ) {
         push @input, { file => $1, parser => $2 };
     }
     elsif ( $arg =~ m/^--no-batch-alters$/ ) {
-      $no_batch_alters = 1;
+        $no_batch_alters = 1;
     }
     else {
         pod2usage( msg => "Unknown argument '$arg'" );
     }
 }
 
-print STDERR <<'EOM';
+print STDERR <<'EOM' unless $ENV{SQLT_NEWDIFF_NOWARN};
 This code is experimental, currently the new code only supports MySQL or
 SQLite diffing. To add support for other databases, please patch the relevant
 SQL::Translator::Producer:: module.  If you need compatibility with the old
@@ -214,7 +220,12 @@ my $result = SQL::Translator::Diff::schema_diff($source_schema, $source_db,
                                                   output_db               => $output_db,
                                                   no_batch_alters         => $no_batch_alters,
                                                   debug                   => $debug,
-                                                  trace                   => $trace });
+                                                  trace                   => $trace,
+                                                  producer_args => {
+                                                      quote_table_names   => $quote,
+                                                      quote_field_names   => $quote,
+                                                  },
+                                                  });
 if($result)
 {
     print $result;