From 7bb0ca44907f8ea88d0678f6e628cedae278d7c0 Mon Sep 17 00:00:00 2001 From: Rauno Moisto Date: Wed, 16 Aug 2023 16:02:56 +0300 Subject: [PATCH] Force uppercase SQL keywords --- src/Tokenizer.php | 8 ++-- tests/clihighlight.html | 94 ++++++++++++++++++------------------- tests/compress.html | 25 +++++----- tests/format-highlight.html | 94 ++++++++++++++++++------------------- tests/format.html | 94 ++++++++++++++++++------------------- tests/highlight.html | 92 ++++++++++++++++++------------------ tests/sql.sql | 4 +- 7 files changed, 206 insertions(+), 205 deletions(-) diff --git a/src/Tokenizer.php b/src/Tokenizer.php index a679eaf..ac9fb7a 100644 --- a/src/Tokenizer.php +++ b/src/Tokenizer.php @@ -909,7 +909,7 @@ private function createNextToken(string $string, ?Token $previous = null): Token ) { return new Token( Token::TOKEN_TYPE_RESERVED_TOPLEVEL, - substr($string, 0, strlen($matches[1])) + substr($upper, 0, strlen($matches[1])) ); } @@ -923,7 +923,7 @@ private function createNextToken(string $string, ?Token $previous = null): Token ) { return new Token( Token::TOKEN_TYPE_RESERVED_NEWLINE, - substr($string, 0, strlen($matches[1])) + substr($upper, 0, strlen($matches[1])) ); } @@ -937,7 +937,7 @@ private function createNextToken(string $string, ?Token $previous = null): Token ) { return new Token( Token::TOKEN_TYPE_RESERVED, - substr($string, 0, strlen($matches[1])) + substr($upper, 0, strlen($matches[1])) ); } } @@ -949,7 +949,7 @@ private function createNextToken(string $string, ?Token $previous = null): Token if (preg_match('/^(' . $this->regexFunction . '[(]|\s|[)])/', $upper, $matches)) { return new Token( Token::TOKEN_TYPE_RESERVED, - substr($string, 0, strlen($matches[1]) - 1) + substr($upper, 0, strlen($matches[1]) - 1) ); } diff --git a/tests/clihighlight.html b/tests/clihighlight.html index 9dd59ad..d81ca08 100755 --- a/tests/clihighlight.html +++ b/tests/clihighlight.html @@ -1,7 +1,7 @@ SELECT customer_id, customer_name, - COUNT(order_id) as total + COUNT(order_id) AS total FROM customers INNER JOIN orders ON customers.customer_id = orders.customer_id @@ -21,12 +21,12 @@ ( SELECT customer_id, - count(order_id) As total + COUNT(order_id) AS total FROM orders GROUP BY customer_id - ) As ordersummary + ) AS ordersummary WHERE customers.customer_id = ordersummary.customer_id --- @@ -44,30 +44,30 @@ NAMES 'utf8'; --- CREATE TABLE `PREFIX_address` ( - `id_address` int(10) unsigned NOT NULL auto_increment, - `id_country` int(10) unsigned NOT NULL, - `id_state` int(10) unsigned default NULL, - `id_customer` int(10) unsigned NOT NULL default '0', - `id_manufacturer` int(10) unsigned NOT NULL default '0', - `id_supplier` int(10) unsigned NOT NULL default '0', - `id_warehouse` int(10) unsigned NOT NULL default '0', + `id_address` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, + `id_country` int(10) UNSIGNED NOT NULL, + `id_state` int(10) UNSIGNED DEFAULT NULL, + `id_customer` int(10) UNSIGNED NOT NULL DEFAULT '0', + `id_manufacturer` int(10) UNSIGNED NOT NULL DEFAULT '0', + `id_supplier` int(10) UNSIGNED NOT NULL DEFAULT '0', + `id_warehouse` int(10) UNSIGNED NOT NULL DEFAULT '0', `alias` varchar(32) NOT NULL, - `company` varchar(64) default NULL, + `company` varchar(64) DEFAULT NULL, `lastname` varchar(32) NOT NULL, `firstname` varchar(32) NOT NULL, `address1` varchar(128) NOT NULL, - `address2` varchar(128) default NULL, - `postcode` varchar(12) default NULL, + `address2` varchar(128) DEFAULT NULL, + `postcode` varchar(12) DEFAULT NULL, `city` varchar(64) NOT NULL, `other` text, - `phone` varchar(16) default NULL, - `phone_mobile` varchar(16) default NULL, - `vat_number` varchar(32) default NULL, + `phone` varchar(16) DEFAULT NULL, + `phone_mobile` varchar(16) DEFAULT NULL, + `vat_number` varchar(32) DEFAULT NULL, `dni` varchar(16) DEFAULT NULL, `date_add` datetime NOT NULL, `date_upd` datetime NOT NULL, - `active` tinyint(1) unsigned NOT NULL default '1', - `deleted` tinyint(1) unsigned NOT NULL default '0', + `active` tinyint(1) UNSIGNED NOT NULL DEFAULT '1', + `deleted` tinyint(1) UNSIGNED NOT NULL DEFAULT '0', PRIMARY KEY (`id_address`), KEY `address_customer` (`id_customer`), KEY `id_country` (`id_country`), @@ -78,31 +78,31 @@ ) ENGINE = ENGINE_TYPE DEFAULT CHARSET = utf8 --- CREATE TABLE `PREFIX_alias` ( - `id_alias` int(10) unsigned NOT NULL auto_increment, + `id_alias` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, `alias` varchar(255) NOT NULL, `search` varchar(255) NOT NULL, - `active` tinyint(1) NOT NULL default '1', + `active` tinyint(1) NOT NULL DEFAULT '1', PRIMARY KEY (`id_alias`), UNIQUE KEY `alias` (`alias`) ) ENGINE = ENGINE_TYPE DEFAULT CHARSET = utf8 --- CREATE TABLE `PREFIX_carrier` ( - `id_carrier` int(10) unsigned NOT NULL AUTO_INCREMENT, - `id_reference` int(10) unsigned NOT NULL, - `id_tax_rules_group` int(10) unsigned DEFAULT '0', + `id_carrier` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, + `id_reference` int(10) UNSIGNED NOT NULL, + `id_tax_rules_group` int(10) UNSIGNED DEFAULT '0', `name` varchar(64) NOT NULL, `url` varchar(255) DEFAULT NULL, - `active` tinyint(1) unsigned NOT NULL DEFAULT '0', - `deleted` tinyint(1) unsigned NOT NULL DEFAULT '0', - `shipping_handling` tinyint(1) unsigned NOT NULL DEFAULT '1', - `range_behavior` tinyint(1) unsigned NOT NULL DEFAULT '0', - `is_module` tinyint(1) unsigned NOT NULL DEFAULT '0', - `is_free` tinyint(1) unsigned NOT NULL DEFAULT '0', - `shipping_external` tinyint(1) unsigned NOT NULL DEFAULT '0', - `need_range` tinyint(1) unsigned NOT NULL DEFAULT '0', + `active` tinyint(1) UNSIGNED NOT NULL DEFAULT '0', + `deleted` tinyint(1) UNSIGNED NOT NULL DEFAULT '0', + `shipping_handling` tinyint(1) UNSIGNED NOT NULL DEFAULT '1', + `range_behavior` tinyint(1) UNSIGNED NOT NULL DEFAULT '0', + `is_module` tinyint(1) UNSIGNED NOT NULL DEFAULT '0', + `is_free` tinyint(1) UNSIGNED NOT NULL DEFAULT '0', + `shipping_external` tinyint(1) UNSIGNED NOT NULL DEFAULT '0', + `need_range` tinyint(1) UNSIGNED NOT NULL DEFAULT '0', `external_module_name` varchar(64) DEFAULT NULL, `shipping_method` int(2) NOT NULL DEFAULT '0', - `position` int(10) unsigned NOT NULL default '0', + `position` int(10) UNSIGNED NOT NULL DEFAULT '0', `max_width` int(10) DEFAULT 0, `max_height` int(10) DEFAULT 0, `max_depth` int(10) DEFAULT 0, @@ -114,13 +114,13 @@ ) ENGINE = ENGINE_TYPE DEFAULT CHARSET = utf8 --- CREATE TABLE IF NOT EXISTS `PREFIX_specific_price_rule` ( - `id_specific_price_rule` int(10) unsigned NOT NULL AUTO_INCREMENT, + `id_specific_price_rule` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, `name` VARCHAR(255) NOT NULL, - `id_shop` int(11) unsigned NOT NULL DEFAULT '1', - `id_currency` int(10) unsigned NOT NULL, - `id_country` int(10) unsigned NOT NULL, - `id_group` int(10) unsigned NOT NULL, - `from_quantity` mediumint(8) unsigned NOT NULL, + `id_shop` int(11) UNSIGNED NOT NULL DEFAULT '1', + `id_currency` int(10) UNSIGNED NOT NULL, + `id_country` int(10) UNSIGNED NOT NULL, + `id_group` int(10) UNSIGNED NOT NULL, + `from_quantity` mediumint(8) UNSIGNED NOT NULL, `price` DECIMAL(20, 6), `reduction` decimal(20, 6) NOT NULL, `reduction_type` enum('amount', 'percentage') NOT NULL, @@ -454,7 +454,7 @@ ALTER TABLE `PREFIX_employee` ADD - `bo_color` varchar(32) default NULL AFTER `stats_date_to` + `bo_color` varchar(32) DEFAULT NULL AFTER `stats_date_to` --- INSERT INTO `PREFIX_cms_category_lang` VALUES @@ -779,16 +779,16 @@ 2, 3 WHERE - a in (1, 2, 3, 4, 5) - and b = 5; + a IN (1, 2, 3, 4, 5) + AND b = 5; --- SELECT - count - 50 + `count` - 50 WHERE a - 50 = b WHERE 1 - and -50 + AND -50 WHERE -50 = a WHERE @@ -799,11 +799,11 @@ -50 WHERE 1 - and -50; + AND -50; --- SELECT @ - and b; + AND b; --- SELECT @"weird variable name"; @@ -823,7 +823,7 @@ a FROM b - LEFT OUTER JOIN c on (d = f); + LEFT OUTER JOIN c ON (d = f); --- WITH cte AS ( @@ -831,7 +831,7 @@ a, b FROM - table + `table` ), RECURSIVE fibonacci (n, fib_n, next_fib_n) AS ( SELECT diff --git a/tests/compress.html b/tests/compress.html index 70266fa..214fc50 100755 --- a/tests/compress.html +++ b/tests/compress.html @@ -1,24 +1,25 @@ -SELECT customer_id, customer_name, COUNT(order_id) as total FROM customers INNER JOIN orders ON customers.customer_id = orders.customer_id GROUP BY customer_id, customer_name HAVING COUNT(order_id) > 5 ORDER BY COUNT(order_id) DESC; +SELECT customer_id, customer_name, COUNT(order_id) AS total FROM customers INNER JOIN orders ON customers.customer_id = orders.customer_id GROUP BY customer_id, customer_name HAVING COUNT(order_id) > 5 ORDER BY COUNT(order_id) DESC; --- -UPDATE customers SET totalorders = ordersummary.total FROM (SELECT customer_id, count(order_id) As total FROM orders GROUP BY customer_id) As ordersummary WHERE customers.customer_id = ordersummary.customer_id +UPDATE customers SET totalorders = ordersummary.total FROM (SELECT customer_id, COUNT(order_id) AS total FROM orders GROUP BY customer_id) AS ordersummary WHERE customers.customer_id = ordersummary.customer_id --- SELECT * FROM sometable UNION ALL SELECT * FROM someothertable; --- SET NAMES 'utf8'; --- -CREATE TABLE `PREFIX_address` ( `id_address` int(10) unsigned NOT NULL auto_increment, `id_country` int(10) unsigned NOT NULL, `id_state` int(10) unsigned default NULL, `id_customer` int(10) unsigned NOT NULL default '0', `id_manufacturer` int(10) unsigned NOT NULL default '0', `id_supplier` int(10) unsigned NOT NULL default '0', `id_warehouse` int(10) unsigned NOT NULL default '0', `alias` varchar(32) NOT NULL, `company` varchar(64) default NULL, `lastname` varchar(32) NOT NULL, `firstname` varchar(32) NOT NULL, `address1` varchar(128) NOT NULL, `address2` varchar(128) default NULL, `postcode` varchar(12) default NULL, `city` varchar(64) NOT NULL, `other` text, `phone` varchar(16) default NULL, `phone_mobile` varchar(16) default NULL, `vat_number` varchar(32) default NULL, `dni` varchar(16) DEFAULT NULL, `date_add` datetime NOT NULL, `date_upd` datetime NOT NULL, `active` tinyint(1) unsigned NOT NULL default '1', `deleted` tinyint(1) unsigned NOT NULL default '0', PRIMARY KEY (`id_address`), KEY `address_customer` (`id_customer`), KEY `id_country` (`id_country`), KEY `id_state` (`id_state`), KEY `id_manufacturer` (`id_manufacturer`), KEY `id_supplier` (`id_supplier`), KEY `id_warehouse` (`id_warehouse`) ) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8 +CREATE TABLE `PREFIX_address` ( `id_address` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, `id_country` int(10) UNSIGNED NOT NULL, `id_state` int(10) UNSIGNED DEFAULT NULL, `id_customer` int(10) UNSIGNED NOT NULL DEFAULT '0', `id_manufacturer` int(10) UNSIGNED NOT NULL DEFAULT '0', `id_supplier` int(10) UNSIGNED NOT NULL DEFAULT '0', `id_warehouse` int(10) UNSIGNED NOT NULL DEFAULT '0', `alias` varchar(32) NOT NULL, `company` varchar(64) DEFAULT NULL, `lastname` varchar(32) NOT NULL, `firstname` varchar(32) NOT NULL, `address1` varchar(128) NOT NULL, `address2` varchar(128) DEFAULT NULL, `postcode` varchar(12) DEFAULT NULL, `city` varchar(64) NOT NULL, `other` text, `phone` varchar(16) DEFAULT NULL, `phone_mobile` varchar(16) DEFAULT NULL, `vat_number` varchar(32) DEFAULT NULL, `dni` varchar(16) DEFAULT NULL, `date_add` datetime NOT NULL, `date_upd` datetime NOT NULL, `active` tinyint(1) UNSIGNED NOT NULL DEFAULT '1', `deleted` tinyint(1) UNSIGNED NOT NULL DEFAULT '0', PRIMARY KEY (`id_address`), KEY `address_customer` (`id_customer`), KEY `id_country` (`id_country`), KEY `id_state` (`id_state`), KEY `id_manufacturer` (`id_manufacturer`), KEY `id_supplier` (`id_supplier`), KEY `id_warehouse` (`id_warehouse`) ) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8 --- -CREATE TABLE `PREFIX_alias` ( `id_alias` int(10) unsigned NOT NULL auto_increment, `alias` varchar(255) NOT NULL, `search` varchar(255) NOT NULL, `active` tinyint(1) NOT NULL default '1', PRIMARY KEY (`id_alias`), UNIQUE KEY `alias` (`alias`) ) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8 +CREATE TABLE `PREFIX_alias` ( `id_alias` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, `alias` varchar(255) NOT NULL, `search` varchar(255) NOT NULL, `active` tinyint(1) NOT NULL DEFAULT '1', PRIMARY KEY (`id_alias`), UNIQUE KEY `alias` (`alias`) ) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8 --- -CREATE TABLE `PREFIX_carrier` ( `id_carrier` int(10) unsigned NOT NULL AUTO_INCREMENT, `id_reference` int(10) unsigned NOT NULL, `id_tax_rules_group` int(10) unsigned DEFAULT '0', `name` varchar(64) NOT NULL, `url` varchar(255) DEFAULT NULL, `active` tinyint(1) unsigned NOT NULL DEFAULT '0', `deleted` tinyint(1) unsigned NOT NULL DEFAULT '0', `shipping_handling` tinyint(1) unsigned NOT NULL DEFAULT '1', `range_behavior` tinyint(1) unsigned NOT NULL DEFAULT '0', `is_module` tinyint(1) unsigned NOT NULL DEFAULT '0', `is_free` tinyint(1) unsigned NOT NULL DEFAULT '0', `shipping_external` tinyint(1) unsigned NOT NULL DEFAULT '0', `need_range` tinyint(1) unsigned NOT NULL DEFAULT '0', `external_module_name` varchar(64) DEFAULT NULL, `shipping_method` int(2) NOT NULL DEFAULT '0', `position` int(10) unsigned NOT NULL default '0', `max_width` int(10) DEFAULT 0, `max_height` int(10) DEFAULT 0, `max_depth` int(10) DEFAULT 0, `max_weight` int(10) DEFAULT 0, `grade` int(10) DEFAULT 0, PRIMARY KEY (`id_carrier`), KEY `deleted` (`deleted`,`active`), KEY `id_tax_rules_group` (`id_tax_rules_group`) ) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8 +CREATE TABLE `PREFIX_carrier` ( `id_carrier` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, `id_reference` int(10) UNSIGNED NOT NULL, `id_tax_rules_group` int(10) UNSIGNED DEFAULT '0', `name` varchar(64) NOT NULL, `url` varchar(255) DEFAULT NULL, `active` tinyint(1) UNSIGNED NOT NULL DEFAULT '0', `deleted` tinyint(1) UNSIGNED NOT NULL DEFAULT '0', `shipping_handling` tinyint(1) UNSIGNED NOT NULL DEFAULT '1', `range_behavior` tinyint(1) UNSIGNED NOT NULL DEFAULT '0', `is_module` tinyint(1) UNSIGNED NOT NULL DEFAULT '0', `is_free` tinyint(1) UNSIGNED NOT NULL DEFAULT '0', `shipping_external` tinyint(1) UNSIGNED NOT NULL DEFAULT '0', `need_range` tinyint(1) UNSIGNED NOT NULL DEFAULT '0', `external_module_name` varchar(64) DEFAULT NULL, `shipping_method` int(2) NOT NULL DEFAULT '0', `position` int(10) UNSIGNED NOT NULL DEFAULT '0', `max_width` int(10) DEFAULT 0, `max_height` int(10) DEFAULT 0, `max_depth` int(10) DEFAULT 0, `max_weight` int(10) DEFAULT 0, `grade` int(10) DEFAULT 0, PRIMARY KEY (`id_carrier`), KEY `deleted` (`deleted`,`active`), KEY `id_tax_rules_group` (`id_tax_rules_group`) ) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8 --- -CREATE TABLE IF NOT EXISTS `PREFIX_specific_price_rule` ( `id_specific_price_rule` int(10) unsigned NOT NULL AUTO_INCREMENT, `name` VARCHAR(255) NOT NULL, `id_shop` int(11) unsigned NOT NULL DEFAULT '1', `id_currency` int(10) unsigned NOT NULL, `id_country` int(10) unsigned NOT NULL, `id_group` int(10) unsigned NOT NULL, `from_quantity` mediumint(8) unsigned NOT NULL, `price` DECIMAL(20,6), `reduction` decimal(20,6) NOT NULL, `reduction_type` enum('amount','percentage') NOT NULL, `from` datetime NOT NULL, `to` datetime NOT NULL, PRIMARY KEY (`id_specific_price_rule`), KEY `id_product` (`id_shop`,`id_currency`,`id_country`,`id_group`,`from_quantity`,`from`,`to`) ) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8 +CREATE TABLE IF NOT EXISTS `PREFIX_specific_price_rule` ( `id_specific_price_rule` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, `name` VARCHAR(255) NOT NULL, `id_shop` int(11) UNSIGNED NOT NULL DEFAULT '1', `id_currency` int(10) UNSIGNED NOT NULL, `id_country` int(10) UNSIGNED NOT NULL, `id_group` int(10) UNSIGNED NOT NULL, `from_quantity` mediumint(8) UNSIGNED NOT NULL, `price` DECIMAL(20,6), `reduction` decimal(20,6) NOT NULL, `reduction_type` enum('amount','percentage') NOT NULL, `from` datetime NOT NULL, `to` datetime NOT NULL, PRIMARY KEY (`id_specific_price_rule`), KEY `id_product` (`id_shop`,`id_currency`,`id_country`,`id_group`,`from_quantity`,`from`,`to`) ) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8 --- UPDATE `PREFIX_configuration` SET value = '6' WHERE name = 'PS_SEARCH_WEIGHT_PNAME' --- UPDATE `PREFIX_hook_module` SET position = 1 WHERE id_hook = (SELECT id_hook FROM `PREFIX_hook` WHERE name = 'displayPayment') AND id_module = (SELECT id_module FROM `PREFIX_module` WHERE name = 'cheque') OR id_hook = (SELECT id_hook FROM `PREFIX_hook` WHERE name = 'displayPaymentReturn') AND id_module = (SELECT id_module FROM `PREFIX_module` WHERE name = 'cheque') OR id_hook = (SELECT id_hook FROM `PREFIX_hook` WHERE name = 'displayHome') AND id_module = (SELECT id_module FROM `PREFIX_module` WHERE name = 'homeslider') OR id_hook = (SELECT id_hook FROM `PREFIX_hook` WHERE name = 'actionAuthentication') AND id_module = (SELECT id_module FROM `PREFIX_module` WHERE name = 'statsdata') OR id_hook = (SELECT id_hook FROM `PREFIX_hook` WHERE name = 'actionShopDataDuplication') AND id_module = (SELECT id_module FROM `PREFIX_module` WHERE name = 'homeslider') OR id_hook = (SELECT id_hook FROM `PREFIX_hook` WHERE name = 'displayTop') AND id_module = (SELECT id_module FROM `PREFIX_module` WHERE name = 'blocklanguages') OR id_hook = (SELECT id_hook FROM `PREFIX_hook` WHERE name = 'actionCustomerAccountAdd') AND id_module = (SELECT id_module FROM `PREFIX_module` WHERE name = 'statsdata') OR id_hook = (SELECT id_hook FROM `PREFIX_hook` WHERE name = 'displayCustomerAccount') AND id_module = (SELECT id_module FROM `PREFIX_module` WHERE name = 'favoriteproducts') OR id_hook = (SELECT id_hook FROM `PREFIX_hook` WHERE name = 'displayAdminStatsModules') AND id_module = (SELECT id_module FROM `PREFIX_module` WHERE name = 'statsvisits') OR id_hook = (SELECT id_hook FROM `PREFIX_hook` WHERE name = 'displayAdminStatsGraphEngine') AND id_module = (SELECT id_module FROM `PREFIX_module` WHERE name = 'graphvisifire') OR id_hook = (SELECT id_hook FROM `PREFIX_hook` WHERE name = 'displayAdminStatsGridEngine') AND id_module = (SELECT id_module FROM `PREFIX_module` WHERE name = 'gridhtml') OR id_hook = (SELECT id_hook FROM `PREFIX_hook` WHERE name = 'displayLeftColumnProduct') AND id_module = (SELECT id_module FROM `PREFIX_module` WHERE name = 'blocksharefb') OR id_hook = (SELECT id_hook FROM `PREFIX_hook` WHERE name = 'actionSearch') AND id_module = (SELECT id_module FROM `PREFIX_module` WHERE name = 'statssearch') OR id_hook = (SELECT id_hook FROM `PREFIX_hook` WHERE name = 'actionCategoryAdd') AND id_module = (SELECT id_module FROM `PREFIX_module` WHERE name = 'blockcategories') OR id_hook = (SELECT id_hook FROM `PREFIX_hook` WHERE name = 'actionCategoryUpdate') AND id_module = (SELECT id_module FROM `PREFIX_module` WHERE name = 'blockcategories') OR id_hook = (SELECT id_hook FROM `PREFIX_hook` WHERE name = 'actionCategoryDelete') AND id_module = (SELECT id_module FROM `PREFIX_module` WHERE name = 'blockcategories') OR id_hook = (SELECT id_hook FROM `PREFIX_hook` WHERE name = 'actionAdminMetaSave') AND id_module = (SELECT id_module FROM `PREFIX_module` WHERE name = 'blockcategories') OR id_hook = (SELECT id_hook FROM `PREFIX_hook` WHERE name = 'displayMyAccountBlock') AND id_module = (SELECT id_module FROM `PREFIX_module` WHERE name = 'favoriteproducts') OR id_hook = (SELECT id_hook FROM `PREFIX_hook` WHERE name = 'displayFooter') AND id_module = (SELECT id_module FROM `PREFIX_module` WHERE name = 'blockreinsurance') --- -ALTER TABLE `PREFIX_employee` ADD `bo_color` varchar(32) default NULL AFTER `stats_date_to` + +ALTER TABLE `PREFIX_employee` ADD `bo_color` varchar(32) DEFAULT NULL AFTER `stats_date_to` --- INSERT INTO `PREFIX_cms_category_lang` VALUES(1, 3, 'Inicio', '', 'home', NULL, NULL, NULL) --- @@ -70,11 +71,11 @@ --- ALTER TABLE `test_change` CHANGE `id` `_id` BIGINT(20) UNSIGNED NULL; --- -SELECT * LIMIT 1; SELECT a,b,c,d FROM e LIMIT 1, 2; SELECT 1,2,3 WHERE a in (1,2,3,4,5) and b=5; +SELECT * LIMIT 1; SELECT a,b,c,d FROM e LIMIT 1, 2; SELECT 1,2,3 WHERE a IN (1,2,3,4,5) AND b=5; --- -SELECT count - 50 WHERE a-50 = b WHERE 1 and - 50 WHERE -50 = a WHERE a = -50 WHERE 1 - 50 WHERE 1 and -50; +SELECT `count` - 50 WHERE a-50 = b WHERE 1 AND - 50 WHERE -50 = a WHERE a = -50 WHERE 1 - 50 WHERE 1 AND -50; --- -SELECT @ and b; +SELECT @ AND b; --- SELECT @"weird variable name"; --- @@ -84,9 +85,9 @@ --- SELECT [sqlserver] FROM [escap[e]]d style]; --- -SELECT a FROM b LEFT OUTER JOIN c on (d=f); +SELECT a FROM b LEFT OUTER JOIN c ON (d=f); --- -WITH cte AS (SELECT a, b FROM table), RECURSIVE fibonacci (n, fib_n, next_fib_n) AS ( SELECT 1, 0, 1 UNION ALL SELECT n + 1, next_fib_n, fib_n + next_fib_n FROM fibonacci WHERE n < 10 ) SELECT * FROM fibonacci; +WITH cte AS (SELECT a, b FROM `table`), RECURSIVE fibonacci (n, fib_n, next_fib_n) AS ( SELECT 1, 0, 1 UNION ALL SELECT n + 1, next_fib_n, fib_n + next_fib_n FROM fibonacci WHERE n < 10 ) SELECT * FROM fibonacci; --- WITH cte1 AS (SELECT a, b FROM table1), cte2 AS (SELECT c, d FROM table2) SELECT b, d FROM cte1 JOIN cte2 WHERE cte1.a = cte2.c; --- diff --git a/tests/format-highlight.html b/tests/format-highlight.html index 13adc70..a0c660e 100755 --- a/tests/format-highlight.html +++ b/tests/format-highlight.html @@ -1,7 +1,7 @@
SELECT
   customer_id,
   customer_name,
-  COUNT(order_id) as total
+  COUNT(order_id) AS total
 FROM
   customers
   INNER JOIN orders ON customers.customer_id = orders.customer_id
@@ -21,12 +21,12 @@
   (
     SELECT
       customer_id,
-      count(order_id) As total
+      COUNT(order_id) AS total
     FROM
       orders
     GROUP BY
       customer_id
-  ) As ordersummary
+  ) AS ordersummary
 WHERE
   customers.customer_id = ordersummary.customer_id
--- @@ -44,30 +44,30 @@ NAMES 'utf8'; ---
CREATE TABLE `PREFIX_address` (
-  `id_address` int(10) unsigned NOT NULL auto_increment,
-  `id_country` int(10) unsigned NOT NULL,
-  `id_state` int(10) unsigned default NULL,
-  `id_customer` int(10) unsigned NOT NULL default '0',
-  `id_manufacturer` int(10) unsigned NOT NULL default '0',
-  `id_supplier` int(10) unsigned NOT NULL default '0',
-  `id_warehouse` int(10) unsigned NOT NULL default '0',
+  `id_address` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
+  `id_country` int(10) UNSIGNED NOT NULL,
+  `id_state` int(10) UNSIGNED DEFAULT NULL,
+  `id_customer` int(10) UNSIGNED NOT NULL DEFAULT '0',
+  `id_manufacturer` int(10) UNSIGNED NOT NULL DEFAULT '0',
+  `id_supplier` int(10) UNSIGNED NOT NULL DEFAULT '0',
+  `id_warehouse` int(10) UNSIGNED NOT NULL DEFAULT '0',
   `alias` varchar(32) NOT NULL,
-  `company` varchar(64) default NULL,
+  `company` varchar(64) DEFAULT NULL,
   `lastname` varchar(32) NOT NULL,
   `firstname` varchar(32) NOT NULL,
   `address1` varchar(128) NOT NULL,
-  `address2` varchar(128) default NULL,
-  `postcode` varchar(12) default NULL,
+  `address2` varchar(128) DEFAULT NULL,
+  `postcode` varchar(12) DEFAULT NULL,
   `city` varchar(64) NOT NULL,
   `other` text,
-  `phone` varchar(16) default NULL,
-  `phone_mobile` varchar(16) default NULL,
-  `vat_number` varchar(32) default NULL,
+  `phone` varchar(16) DEFAULT NULL,
+  `phone_mobile` varchar(16) DEFAULT NULL,
+  `vat_number` varchar(32) DEFAULT NULL,
   `dni` varchar(16) DEFAULT NULL,
   `date_add` datetime NOT NULL,
   `date_upd` datetime NOT NULL,
-  `active` tinyint(1) unsigned NOT NULL default '1',
-  `deleted` tinyint(1) unsigned NOT NULL default '0',
+  `active` tinyint(1) UNSIGNED NOT NULL DEFAULT '1',
+  `deleted` tinyint(1) UNSIGNED NOT NULL DEFAULT '0',
   PRIMARY KEY (`id_address`),
   KEY `address_customer` (`id_customer`),
   KEY `id_country` (`id_country`),
@@ -78,31 +78,31 @@
 ) ENGINE = ENGINE_TYPE DEFAULT CHARSET = utf8
---
CREATE TABLE `PREFIX_alias` (
-  `id_alias` int(10) unsigned NOT NULL auto_increment,
+  `id_alias` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
   `alias` varchar(255) NOT NULL,
   `search` varchar(255) NOT NULL,
-  `active` tinyint(1) NOT NULL default '1',
+  `active` tinyint(1) NOT NULL DEFAULT '1',
   PRIMARY KEY (`id_alias`),
   UNIQUE KEY `alias` (`alias`)
 ) ENGINE = ENGINE_TYPE DEFAULT CHARSET = utf8
---
CREATE TABLE `PREFIX_carrier` (
-  `id_carrier` int(10) unsigned NOT NULL AUTO_INCREMENT,
-  `id_reference` int(10) unsigned NOT NULL,
-  `id_tax_rules_group` int(10) unsigned DEFAULT '0',
+  `id_carrier` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
+  `id_reference` int(10) UNSIGNED NOT NULL,
+  `id_tax_rules_group` int(10) UNSIGNED DEFAULT '0',
   `name` varchar(64) NOT NULL,
   `url` varchar(255) DEFAULT NULL,
-  `active` tinyint(1) unsigned NOT NULL DEFAULT '0',
-  `deleted` tinyint(1) unsigned NOT NULL DEFAULT '0',
-  `shipping_handling` tinyint(1) unsigned NOT NULL DEFAULT '1',
-  `range_behavior` tinyint(1) unsigned NOT NULL DEFAULT '0',
-  `is_module` tinyint(1) unsigned NOT NULL DEFAULT '0',
-  `is_free` tinyint(1) unsigned NOT NULL DEFAULT '0',
-  `shipping_external` tinyint(1) unsigned NOT NULL DEFAULT '0',
-  `need_range` tinyint(1) unsigned NOT NULL DEFAULT '0',
+  `active` tinyint(1) UNSIGNED NOT NULL DEFAULT '0',
+  `deleted` tinyint(1) UNSIGNED NOT NULL DEFAULT '0',
+  `shipping_handling` tinyint(1) UNSIGNED NOT NULL DEFAULT '1',
+  `range_behavior` tinyint(1) UNSIGNED NOT NULL DEFAULT '0',
+  `is_module` tinyint(1) UNSIGNED NOT NULL DEFAULT '0',
+  `is_free` tinyint(1) UNSIGNED NOT NULL DEFAULT '0',
+  `shipping_external` tinyint(1) UNSIGNED NOT NULL DEFAULT '0',
+  `need_range` tinyint(1) UNSIGNED NOT NULL DEFAULT '0',
   `external_module_name` varchar(64) DEFAULT NULL,
   `shipping_method` int(2) NOT NULL DEFAULT '0',
-  `position` int(10) unsigned NOT NULL default '0',
+  `position` int(10) UNSIGNED NOT NULL DEFAULT '0',
   `max_width` int(10) DEFAULT 0,
   `max_height` int(10) DEFAULT 0,
   `max_depth` int(10) DEFAULT 0,
@@ -114,13 +114,13 @@
 ) ENGINE = ENGINE_TYPE DEFAULT CHARSET = utf8
---
CREATE TABLE IF NOT EXISTS `PREFIX_specific_price_rule` (
-  `id_specific_price_rule` int(10) unsigned NOT NULL AUTO_INCREMENT,
+  `id_specific_price_rule` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
   `name` VARCHAR(255) NOT NULL,
-  `id_shop` int(11) unsigned NOT NULL DEFAULT '1',
-  `id_currency` int(10) unsigned NOT NULL,
-  `id_country` int(10) unsigned NOT NULL,
-  `id_group` int(10) unsigned NOT NULL,
-  `from_quantity` mediumint(8) unsigned NOT NULL,
+  `id_shop` int(11) UNSIGNED NOT NULL DEFAULT '1',
+  `id_currency` int(10) UNSIGNED NOT NULL,
+  `id_country` int(10) UNSIGNED NOT NULL,
+  `id_group` int(10) UNSIGNED NOT NULL,
+  `from_quantity` mediumint(8) UNSIGNED NOT NULL,
   `price` DECIMAL(20, 6),
   `reduction` decimal(20, 6) NOT NULL,
   `reduction_type` enum('amount', 'percentage') NOT NULL,
@@ -454,7 +454,7 @@
 
ALTER TABLE
   `PREFIX_employee`
 ADD
-  `bo_color` varchar(32) default NULL AFTER `stats_date_to`
+ `bo_color` varchar(32) DEFAULT NULL AFTER `stats_date_to`
---
INSERT INTO `PREFIX_cms_category_lang`
 VALUES
@@ -779,16 +779,16 @@
   2,
   3
 WHERE
-  a in (1, 2, 3, 4, 5)
-  and b = 5;
+ a IN (1, 2, 3, 4, 5) + AND b = 5; ---
SELECT
-  count - 50
+  `count` - 50
 WHERE
   a - 50 = b
 WHERE
   1
-  and -50
+  AND -50
 WHERE
   -50 = a
 WHERE
@@ -799,11 +799,11 @@
   -50
 WHERE
   1
-  and -50;
+ AND -50; ---
SELECT
   @
-  and b;
+ AND b; ---
SELECT
   @"weird variable name";
@@ -823,7 +823,7 @@ a FROM b - LEFT OUTER JOIN c on (d = f); + LEFT OUTER JOIN c ON (d = f); ---
WITH
   cte AS (
@@ -831,7 +831,7 @@
       a,
       b
     FROM
-      table
+      `table`
   ),
   RECURSIVE fibonacci (n, fib_n, next_fib_n) AS (
     SELECT
diff --git a/tests/format.html b/tests/format.html
index ce89928..8f5a671 100755
--- a/tests/format.html
+++ b/tests/format.html
@@ -1,7 +1,7 @@
 SELECT
   customer_id,
   customer_name,
-  COUNT(order_id) as total
+  COUNT(order_id) AS total
 FROM
   customers
   INNER JOIN orders ON customers.customer_id = orders.customer_id
@@ -21,12 +21,12 @@
   (
     SELECT
       customer_id,
-      count(order_id) As total
+      COUNT(order_id) AS total
     FROM
       orders
     GROUP BY
       customer_id
-  ) As ordersummary
+  ) AS ordersummary
 WHERE
   customers.customer_id = ordersummary.customer_id
 ---
@@ -44,30 +44,30 @@
   NAMES 'utf8';
 ---
 CREATE TABLE `PREFIX_address` (
-  `id_address` int(10) unsigned NOT NULL auto_increment,
-  `id_country` int(10) unsigned NOT NULL,
-  `id_state` int(10) unsigned default NULL,
-  `id_customer` int(10) unsigned NOT NULL default '0',
-  `id_manufacturer` int(10) unsigned NOT NULL default '0',
-  `id_supplier` int(10) unsigned NOT NULL default '0',
-  `id_warehouse` int(10) unsigned NOT NULL default '0',
+  `id_address` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
+  `id_country` int(10) UNSIGNED NOT NULL,
+  `id_state` int(10) UNSIGNED DEFAULT NULL,
+  `id_customer` int(10) UNSIGNED NOT NULL DEFAULT '0',
+  `id_manufacturer` int(10) UNSIGNED NOT NULL DEFAULT '0',
+  `id_supplier` int(10) UNSIGNED NOT NULL DEFAULT '0',
+  `id_warehouse` int(10) UNSIGNED NOT NULL DEFAULT '0',
   `alias` varchar(32) NOT NULL,
-  `company` varchar(64) default NULL,
+  `company` varchar(64) DEFAULT NULL,
   `lastname` varchar(32) NOT NULL,
   `firstname` varchar(32) NOT NULL,
   `address1` varchar(128) NOT NULL,
-  `address2` varchar(128) default NULL,
-  `postcode` varchar(12) default NULL,
+  `address2` varchar(128) DEFAULT NULL,
+  `postcode` varchar(12) DEFAULT NULL,
   `city` varchar(64) NOT NULL,
   `other` text,
-  `phone` varchar(16) default NULL,
-  `phone_mobile` varchar(16) default NULL,
-  `vat_number` varchar(32) default NULL,
+  `phone` varchar(16) DEFAULT NULL,
+  `phone_mobile` varchar(16) DEFAULT NULL,
+  `vat_number` varchar(32) DEFAULT NULL,
   `dni` varchar(16) DEFAULT NULL,
   `date_add` datetime NOT NULL,
   `date_upd` datetime NOT NULL,
-  `active` tinyint(1) unsigned NOT NULL default '1',
-  `deleted` tinyint(1) unsigned NOT NULL default '0',
+  `active` tinyint(1) UNSIGNED NOT NULL DEFAULT '1',
+  `deleted` tinyint(1) UNSIGNED NOT NULL DEFAULT '0',
   PRIMARY KEY (`id_address`),
   KEY `address_customer` (`id_customer`),
   KEY `id_country` (`id_country`),
@@ -78,31 +78,31 @@
 ) ENGINE = ENGINE_TYPE DEFAULT CHARSET = utf8
 ---
 CREATE TABLE `PREFIX_alias` (
-  `id_alias` int(10) unsigned NOT NULL auto_increment,
+  `id_alias` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
   `alias` varchar(255) NOT NULL,
   `search` varchar(255) NOT NULL,
-  `active` tinyint(1) NOT NULL default '1',
+  `active` tinyint(1) NOT NULL DEFAULT '1',
   PRIMARY KEY (`id_alias`),
   UNIQUE KEY `alias` (`alias`)
 ) ENGINE = ENGINE_TYPE DEFAULT CHARSET = utf8
 ---
 CREATE TABLE `PREFIX_carrier` (
-  `id_carrier` int(10) unsigned NOT NULL AUTO_INCREMENT,
-  `id_reference` int(10) unsigned NOT NULL,
-  `id_tax_rules_group` int(10) unsigned DEFAULT '0',
+  `id_carrier` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
+  `id_reference` int(10) UNSIGNED NOT NULL,
+  `id_tax_rules_group` int(10) UNSIGNED DEFAULT '0',
   `name` varchar(64) NOT NULL,
   `url` varchar(255) DEFAULT NULL,
-  `active` tinyint(1) unsigned NOT NULL DEFAULT '0',
-  `deleted` tinyint(1) unsigned NOT NULL DEFAULT '0',
-  `shipping_handling` tinyint(1) unsigned NOT NULL DEFAULT '1',
-  `range_behavior` tinyint(1) unsigned NOT NULL DEFAULT '0',
-  `is_module` tinyint(1) unsigned NOT NULL DEFAULT '0',
-  `is_free` tinyint(1) unsigned NOT NULL DEFAULT '0',
-  `shipping_external` tinyint(1) unsigned NOT NULL DEFAULT '0',
-  `need_range` tinyint(1) unsigned NOT NULL DEFAULT '0',
+  `active` tinyint(1) UNSIGNED NOT NULL DEFAULT '0',
+  `deleted` tinyint(1) UNSIGNED NOT NULL DEFAULT '0',
+  `shipping_handling` tinyint(1) UNSIGNED NOT NULL DEFAULT '1',
+  `range_behavior` tinyint(1) UNSIGNED NOT NULL DEFAULT '0',
+  `is_module` tinyint(1) UNSIGNED NOT NULL DEFAULT '0',
+  `is_free` tinyint(1) UNSIGNED NOT NULL DEFAULT '0',
+  `shipping_external` tinyint(1) UNSIGNED NOT NULL DEFAULT '0',
+  `need_range` tinyint(1) UNSIGNED NOT NULL DEFAULT '0',
   `external_module_name` varchar(64) DEFAULT NULL,
   `shipping_method` int(2) NOT NULL DEFAULT '0',
-  `position` int(10) unsigned NOT NULL default '0',
+  `position` int(10) UNSIGNED NOT NULL DEFAULT '0',
   `max_width` int(10) DEFAULT 0,
   `max_height` int(10) DEFAULT 0,
   `max_depth` int(10) DEFAULT 0,
@@ -114,13 +114,13 @@
 ) ENGINE = ENGINE_TYPE DEFAULT CHARSET = utf8
 ---
 CREATE TABLE IF NOT EXISTS `PREFIX_specific_price_rule` (
-  `id_specific_price_rule` int(10) unsigned NOT NULL AUTO_INCREMENT,
+  `id_specific_price_rule` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
   `name` VARCHAR(255) NOT NULL,
-  `id_shop` int(11) unsigned NOT NULL DEFAULT '1',
-  `id_currency` int(10) unsigned NOT NULL,
-  `id_country` int(10) unsigned NOT NULL,
-  `id_group` int(10) unsigned NOT NULL,
-  `from_quantity` mediumint(8) unsigned NOT NULL,
+  `id_shop` int(11) UNSIGNED NOT NULL DEFAULT '1',
+  `id_currency` int(10) UNSIGNED NOT NULL,
+  `id_country` int(10) UNSIGNED NOT NULL,
+  `id_group` int(10) UNSIGNED NOT NULL,
+  `from_quantity` mediumint(8) UNSIGNED NOT NULL,
   `price` DECIMAL(20, 6),
   `reduction` decimal(20, 6) NOT NULL,
   `reduction_type` enum('amount', 'percentage') NOT NULL,
@@ -454,7 +454,7 @@
 ALTER TABLE
   `PREFIX_employee`
 ADD
-  `bo_color` varchar(32) default NULL AFTER `stats_date_to`
+  `bo_color` varchar(32) DEFAULT NULL AFTER `stats_date_to`
 ---
 INSERT INTO `PREFIX_cms_category_lang`
 VALUES
@@ -777,16 +777,16 @@
   2,
   3
 WHERE
-  a in (1, 2, 3, 4, 5)
-  and b = 5;
+  a IN (1, 2, 3, 4, 5)
+  AND b = 5;
 ---
 SELECT
-  count - 50
+  `count` - 50
 WHERE
   a - 50 = b
 WHERE
   1
-  and -50
+  AND -50
 WHERE
   -50 = a
 WHERE
@@ -797,11 +797,11 @@
   -50
 WHERE
   1
-  and -50;
+  AND -50;
 ---
 SELECT
   @
-  and b;
+  AND b;
 ---
 SELECT
   @"weird variable name";
@@ -821,7 +821,7 @@
   a
 FROM
   b
-  LEFT OUTER JOIN c on (d = f);
+  LEFT OUTER JOIN c ON (d = f);
 ---
 WITH
   cte AS (
@@ -829,7 +829,7 @@
       a,
       b
     FROM
-      table
+      `table`
   ),
   RECURSIVE fibonacci (n, fib_n, next_fib_n) AS (
     SELECT
diff --git a/tests/highlight.html b/tests/highlight.html
index 86c2dad..7fc5c9b 100755
--- a/tests/highlight.html
+++ b/tests/highlight.html
@@ -1,4 +1,4 @@
-
SELECT customer_id, customer_name, COUNT(order_id) as total
+
SELECT customer_id, customer_name, COUNT(order_id) AS total
 FROM customers INNER JOIN orders ON customers.customer_id = orders.customer_id
 GROUP BY customer_id, customer_name
 HAVING COUNT(order_id) > 5
@@ -6,8 +6,8 @@
 ---
 
UPDATE customers
         SET totalorders = ordersummary.total
-        FROM (SELECT customer_id, count(order_id) As total
-FROM orders GROUP BY customer_id) As ordersummary
+        FROM (SELECT customer_id, COUNT(order_id) AS total
+FROM orders GROUP BY customer_id) AS ordersummary
         WHERE customers.customer_id = ordersummary.customer_id
---
SELECT * FROM sometable
@@ -17,30 +17,30 @@
 
SET NAMES 'utf8';
---
CREATE TABLE `PREFIX_address` (
-  `id_address` int(10) unsigned NOT NULL auto_increment,
-  `id_country` int(10) unsigned NOT NULL,
-  `id_state` int(10) unsigned default NULL,
-  `id_customer` int(10) unsigned NOT NULL default '0',
-  `id_manufacturer` int(10) unsigned NOT NULL default '0',
-  `id_supplier` int(10) unsigned NOT NULL default '0',
-  `id_warehouse` int(10) unsigned NOT NULL default '0',
+  `id_address` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
+  `id_country` int(10) UNSIGNED NOT NULL,
+  `id_state` int(10) UNSIGNED DEFAULT NULL,
+  `id_customer` int(10) UNSIGNED NOT NULL DEFAULT '0',
+  `id_manufacturer` int(10) UNSIGNED NOT NULL DEFAULT '0',
+  `id_supplier` int(10) UNSIGNED NOT NULL DEFAULT '0',
+  `id_warehouse` int(10) UNSIGNED NOT NULL DEFAULT '0',
   `alias` varchar(32) NOT NULL,
-  `company` varchar(64) default NULL,
+  `company` varchar(64) DEFAULT NULL,
   `lastname` varchar(32) NOT NULL,
   `firstname` varchar(32) NOT NULL,
   `address1` varchar(128) NOT NULL,
-  `address2` varchar(128) default NULL,
-  `postcode` varchar(12) default NULL,
+  `address2` varchar(128) DEFAULT NULL,
+  `postcode` varchar(12) DEFAULT NULL,
   `city` varchar(64) NOT NULL,
   `other` text,
-  `phone` varchar(16) default NULL,
-  `phone_mobile` varchar(16) default NULL,
-  `vat_number` varchar(32) default NULL,
+  `phone` varchar(16) DEFAULT NULL,
+  `phone_mobile` varchar(16) DEFAULT NULL,
+  `vat_number` varchar(32) DEFAULT NULL,
   `dni` varchar(16) DEFAULT NULL,
   `date_add` datetime NOT NULL,
   `date_upd` datetime NOT NULL,
-  `active` tinyint(1) unsigned NOT NULL default '1',
-  `deleted` tinyint(1) unsigned NOT NULL default '0',
+  `active` tinyint(1) UNSIGNED NOT NULL DEFAULT '1',
+  `deleted` tinyint(1) UNSIGNED NOT NULL DEFAULT '0',
   PRIMARY KEY (`id_address`),
   KEY `address_customer` (`id_customer`),
   KEY `id_country` (`id_country`),
@@ -51,31 +51,31 @@
 ) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8
---
CREATE TABLE `PREFIX_alias` (
-  `id_alias` int(10) unsigned NOT NULL auto_increment,
+  `id_alias` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
   `alias` varchar(255) NOT NULL,
   `search` varchar(255) NOT NULL,
-  `active` tinyint(1) NOT NULL default '1',
+  `active` tinyint(1) NOT NULL DEFAULT '1',
   PRIMARY KEY (`id_alias`),
   UNIQUE KEY `alias` (`alias`)
 ) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8
---
CREATE TABLE `PREFIX_carrier` (
-  `id_carrier` int(10) unsigned NOT NULL AUTO_INCREMENT,
-  `id_reference` int(10) unsigned NOT NULL,
-  `id_tax_rules_group` int(10) unsigned DEFAULT '0',
+  `id_carrier` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
+  `id_reference` int(10) UNSIGNED NOT NULL,
+  `id_tax_rules_group` int(10) UNSIGNED DEFAULT '0',
   `name` varchar(64) NOT NULL,
   `url` varchar(255) DEFAULT NULL,
-  `active` tinyint(1) unsigned NOT NULL DEFAULT '0',
-  `deleted` tinyint(1) unsigned NOT NULL DEFAULT '0',
-  `shipping_handling` tinyint(1) unsigned NOT NULL DEFAULT '1',
-  `range_behavior` tinyint(1) unsigned NOT NULL DEFAULT '0',
-  `is_module` tinyint(1) unsigned NOT NULL DEFAULT '0',
-  `is_free` tinyint(1) unsigned NOT NULL DEFAULT '0',
-  `shipping_external` tinyint(1) unsigned NOT NULL DEFAULT '0',
-  `need_range` tinyint(1) unsigned NOT NULL DEFAULT '0',
+  `active` tinyint(1) UNSIGNED NOT NULL DEFAULT '0',
+  `deleted` tinyint(1) UNSIGNED NOT NULL DEFAULT '0',
+  `shipping_handling` tinyint(1) UNSIGNED NOT NULL DEFAULT '1',
+  `range_behavior` tinyint(1) UNSIGNED NOT NULL DEFAULT '0',
+  `is_module` tinyint(1) UNSIGNED NOT NULL DEFAULT '0',
+  `is_free` tinyint(1) UNSIGNED NOT NULL DEFAULT '0',
+  `shipping_external` tinyint(1) UNSIGNED NOT NULL DEFAULT '0',
+  `need_range` tinyint(1) UNSIGNED NOT NULL DEFAULT '0',
   `external_module_name` varchar(64) DEFAULT NULL,
   `shipping_method` int(2) NOT NULL DEFAULT '0',
-  `position` int(10) unsigned NOT NULL default '0',
+  `position` int(10) UNSIGNED NOT NULL DEFAULT '0',
   `max_width` int(10) DEFAULT 0,
   `max_height` int(10)  DEFAULT 0,
   `max_depth` int(10)  DEFAULT 0,
@@ -87,13 +87,13 @@
 ) ENGINE=ENGINE_TYPE  DEFAULT CHARSET=utf8
---
CREATE TABLE IF NOT EXISTS `PREFIX_specific_price_rule` (
-	`id_specific_price_rule` int(10) unsigned NOT NULL AUTO_INCREMENT,
+	`id_specific_price_rule` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
 	`name` VARCHAR(255) NOT NULL,
-	`id_shop` int(11) unsigned NOT NULL DEFAULT '1',
-	`id_currency` int(10) unsigned NOT NULL,
-	`id_country` int(10) unsigned NOT NULL,
-	`id_group` int(10) unsigned NOT NULL,
-	`from_quantity` mediumint(8) unsigned NOT NULL,
+	`id_shop` int(11) UNSIGNED NOT NULL DEFAULT '1',
+	`id_currency` int(10) UNSIGNED NOT NULL,
+	`id_country` int(10) UNSIGNED NOT NULL,
+	`id_group` int(10) UNSIGNED NOT NULL,
+	`from_quantity` mediumint(8) UNSIGNED NOT NULL,
 	`price` DECIMAL(20,6),
 	`reduction` decimal(20,6) NOT NULL,
 	`reduction_type` enum('amount','percentage') NOT NULL,
@@ -145,7 +145,7 @@
 	OR
 	id_hook = (SELECT id_hook FROM `PREFIX_hook` WHERE name = 'displayFooter') AND id_module = (SELECT id_module FROM `PREFIX_module` WHERE name = 'blockreinsurance')
--- -
ALTER TABLE `PREFIX_employee` ADD `bo_color` varchar(32) default NULL AFTER `stats_date_to`
+
ALTER TABLE `PREFIX_employee` ADD `bo_color` varchar(32) DEFAULT NULL AFTER `stats_date_to`
---
INSERT INTO `PREFIX_cms_category_lang` VALUES(1, 3, 'Inicio', '', 'home', NULL, NULL, NULL)
--- @@ -249,17 +249,17 @@ ---
ALTER TABLE `test_change` CHANGE `id` `_id` BIGINT(20) UNSIGNED NULL;
--- -
SELECT * LIMIT 1; SELECT a,b,c,d FROM e LIMIT 1, 2; SELECT 1,2,3 WHERE a in (1,2,3,4,5) and b=5;
+
SELECT * LIMIT 1; SELECT a,b,c,d FROM e LIMIT 1, 2; SELECT 1,2,3 WHERE a IN (1,2,3,4,5) AND b=5;
--- -
SELECT count - 50
+
SELECT `count` - 50
 WHERE a-50 = b
-WHERE 1 and - 50
+WHERE 1 AND - 50
 WHERE -50 = a
 WHERE a = -50
 WHERE 1 /*test*/ - 50
-WHERE 1 and -50;
+WHERE 1 AND -50;
--- -
SELECT @ and b;
+
SELECT @ AND b;
---
SELECT @"weird variable name";
--- @@ -271,9 +271,9 @@ ---
SELECT a FROM b LEFT
 OUTER
-JOIN c on (d=f);
+JOIN c ON (d=f);
--- -
WITH cte AS (SELECT a, b FROM table),
+
WITH cte AS (SELECT a, b FROM `table`),
 RECURSIVE fibonacci (n, fib_n, next_fib_n) AS (
   SELECT 1, 0, 1
   UNION ALL
diff --git a/tests/sql.sql b/tests/sql.sql
index 8e4a025..bda9509 100755
--- a/tests/sql.sql
+++ b/tests/sql.sql
@@ -251,7 +251,7 @@ ALTER TABLE `test_change` CHANGE `id` `_id` BIGINT(20) UNSIGNED NULL;
 ---
 SELECT * LIMIT 1; SELECT a,b,c,d FROM e LIMIT 1, 2; SELECT 1,2,3 WHERE a in (1,2,3,4,5) and b=5;
 ---
-SELECT count - 50
+SELECT `count` - 50
 WHERE a-50 = b
 WHERE 1 and - 50
 WHERE -50 = a
@@ -273,7 +273,7 @@ SELECT a FROM b LEFT
 OUTER
 JOIN c on (d=f);
 ---
-WITH cte AS (SELECT a, b FROM table),
+WITH cte AS (SELECT a, b FROM `table`),
 RECURSIVE fibonacci (n, fib_n, next_fib_n) AS (
   SELECT 1, 0, 1
   UNION ALL