[interchange] Fix error creating indexes in MySQL and other dbs when QUOTE_IDENTIFIERS is set

Peter Ajamian interchange-cvs at icdevgroup.org
Mon Apr 25 08:34:40 UTC 2016


commit c15c57cf4b973ad0978daf634c373b066588dd00
Author: Peter Ajamian <peter at pajamian.dhs.org>
Date:   Mon Apr 25 20:28:23 2016 +1200

    Fix error creating indexes in MySQL and other dbs when QUOTE_IDENTIFIERS is set
    
    The problem was that Vend::Table::DBI was assembling an index name based on the
    quoted table name plus '_' plus quoted column name, resulting in a syntactically
    invalid name like `variants`_`sku`, leading to errors.  Instead assemble the
    name unquoted, and quote the final result.
    
    This is related to commit 86fbcb14c402efda89b2329b73270ae513715ddf which fixes
    the same issue for PostgreSQL, the error also needed correcting for the other db
    types as well.

 lib/Vend/Table/DBI.pm |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
---
diff --git a/lib/Vend/Table/DBI.pm b/lib/Vend/Table/DBI.pm
index 06b4791..de2e7e4 100644
--- a/lib/Vend/Table/DBI.pm
+++ b/lib/Vend/Table/DBI.pm
@@ -176,9 +176,9 @@ my %known_capability = (
 		Pg => 'ALTER TABLE _TABLE_ ADD COLUMN _COLUMN_ _DEF_',
 	},
 	ALTER_INDEX	 => { 
-		mysql => 'CREATE _UNIQUE_ INDEX $TABLE$_$COLUMN$ ON _TABLE_ (_COLUMN_)',
+		mysql => 'CREATE _UNIQUE_ INDEX $TABLE_COLUMN$ ON _TABLE_ (_COLUMN_)',
 		Pg => 'CREATE _UNIQUE_ INDEX $TABLE_COLUMN$ ON _TABLE_ (_COLUMN_)',
-		default => 'CREATE _UNIQUE_ INDEX $TABLE$_$COLUMN$ ON _TABLE_ (_COLUMN_)',
+		default => 'CREATE _UNIQUE_ INDEX $TABLE_COLUMN$ ON _TABLE_ (_COLUMN_)',
 	},
 	LIST_FIELDS_QUERY => { 
 		mysql => 'SELECT * FROM `_TABLE_` WHERE 2 = 1',



More information about the interchange-cvs mailing list