From: Peter Rabbitson Date: Wed, 24 Feb 2010 08:13:08 +0000 (+0000) Subject: Oracle fix primarily to have it not capitalize but quote instead X-Git-Tag: v0.11008~62 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=62a64f6c26dd9b02fc8e78c0b010b8b64b187fca;p=dbsrgits%2FSQL-Translator.git Oracle fix primarily to have it not capitalize but quote instead test I'm not committing to trunk instead initial things don't look at this yet text -> varchar2(4000) instead of clob, get rid of reserved keywords, import oracle_version from DBD::Oracle missed some quotes and added tests to avoid that missed some quotes and added tests to avoid that Cleanup tabs/whitespace Changes Changes2 r1654@Thesaurus (orig r1653): faxm0dem | 2010-02-10 14:01:28 +0100 r1655@Thesaurus (orig r1654): faxm0dem | 2010-02-10 14:06:17 +0100 r1656@Thesaurus (orig r1655): faxm0dem | 2010-02-10 14:07:08 +0100 r1658@Thesaurus (orig r1657): faxm0dem | 2010-02-10 19:16:08 +0100 r1659@Thesaurus (orig r1658): faxm0dem | 2010-02-11 12:53:59 +0100 r1660@Thesaurus (orig r1659): faxm0dem | 2010-02-11 12:54:54 +0100 r1670@Thesaurus (orig r1669): rabbit | 2010-02-23 12:14:25 +0100 r1672@Thesaurus (orig r1671): rabbit | 2010-02-24 09:09:21 +0100 r1673@Thesaurus (orig r1672): rabbit | 2010-02-24 09:12:36 +0100 --- diff --git a/lib/SQL/Translator/Parser/MySQL.pm b/lib/SQL/Translator/Parser/MySQL.pm index fdd27a2..1f73b23 100644 --- a/lib/SQL/Translator/Parser/MySQL.pm +++ b/lib/SQL/Translator/Parser/MySQL.pm @@ -641,40 +641,41 @@ foreign_key_def_begin : /constraint/i /foreign key/i WORD /foreign key/i { $return = '' } -primary_key_def : primary_key index_name(?) '(' name_with_opt_paren(s /,/) ')' index_type(?) +primary_key_def : primary_key index_name_not_using(?) index_type(?) '(' name_with_opt_paren(s /,/) ')' index_type(?) { $return = { supertype => 'constraint', - name => $item{'index_name(?)'}[0], + name => $item[2][0], type => 'primary_key', - fields => $item[4], - options => $item[6][0], + fields => $item[5], + options => $item[3][0] || $item[7][0], }; } -unique_key_def : UNIQUE KEY(?) index_name(?) '(' name_with_opt_paren(s /,/) ')' +unique_key_def : UNIQUE KEY(?) index_name_not_using(?) index_type(?) '(' name_with_opt_paren(s /,/) ')' index_type(?) { $return = { supertype => 'constraint', - name => $item{'index_name(?)'}[0], + name => $item[3][0], type => 'unique', - fields => $item[5], + fields => $item[6], + options => $item[4][0] || $item[8][0], } } -normal_index : KEY index_name_not_using(?) index_type(?) '(' name_with_opt_paren(s /,/) ')' +normal_index : KEY index_name_not_using(?) index_type(?) '(' name_with_opt_paren(s /,/) ')' index_type(?) { $return = { supertype => 'index', type => 'normal', name => $item[2][0], fields => $item[5], - options => $item[3][0], - } + options => $item[3][0] || $item[7][0], + } } index_name_not_using : QUOTED_NAME - | /(\b(?!using)\w+\b)/ { $return = $1 } + | /(\b(?!using)\w+\b)/ { $return = ($1 =~ /^using/i) ? undef : $1 } index_type : /using (btree|hash|rtree)/i { $return = uc $1 } diff --git a/t/02mysql-parser.t b/t/02mysql-parser.t index 2e1fa45..5565308 100644 --- a/t/02mysql-parser.t +++ b/t/02mysql-parser.t @@ -83,7 +83,7 @@ BEGIN { date timestamp, time_stamp2 timestamp, KEY (i1), - UNIQUE (date, i1), + UNIQUE (date, i1) USING BTREE, KEY date_idx (date), KEY name_idx (name(10)) ) TYPE=MyISAM PACK_KEYS=1; @@ -235,8 +235,8 @@ BEGIN { shipping_charge decimal(8,2), price_paid decimal(8,2), PRIMARY KEY (order_id) USING BTREE, - KEY (status), - KEY (billing_address_id), + KEY (status) USING BTREE, + KEY USING BTREE (billing_address_id), KEY (shipping_address_id), KEY (member_id, store_id), FOREIGN KEY (status) REFERENCES order_status(id) MATCH FULL ON DELETE CASCADE ON UPDATE CASCADE,