From 6cc9d9b5c9543b5a696e24c32c41ed27de5cc48d Mon Sep 17 00:00:00 2001 From: Yako Date: Fri, 1 Aug 2014 15:28:05 +0800 Subject: [PATCH] support create table ... UNSIGNED ZEROFILL --- .../druid/sql/dialect/mysql/parser/MySqlExprParser.java | 7 ++++++- .../sql/dialect/mysql/visitor/MySqlOutputVisitor.java | 9 +++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/alibaba/druid/sql/dialect/mysql/parser/MySqlExprParser.java b/src/main/java/com/alibaba/druid/sql/dialect/mysql/parser/MySqlExprParser.java index deef36e75f..ecfea5f794 100644 --- a/src/main/java/com/alibaba/druid/sql/dialect/mysql/parser/MySqlExprParser.java +++ b/src/main/java/com/alibaba/druid/sql/dialect/mysql/parser/MySqlExprParser.java @@ -578,7 +578,12 @@ protected SQLDataType parseDataTypeRest(SQLDataType dataType) { if (identifierEquals("UNSIGNED")) { lexer.nextToken(); - dataType.getAttributes().put("unsigned", true); + dataType.getAttributes().put("UNSIGNED", true); + } + + if (identifierEquals("ZEROFILL")) { + lexer.nextToken(); + dataType.getAttributes().put("ZEROFILL", true); } return dataType; diff --git a/src/main/java/com/alibaba/druid/sql/dialect/mysql/visitor/MySqlOutputVisitor.java b/src/main/java/com/alibaba/druid/sql/dialect/mysql/visitor/MySqlOutputVisitor.java index d6b9a74894..79787870aa 100644 --- a/src/main/java/com/alibaba/druid/sql/dialect/mysql/visitor/MySqlOutputVisitor.java +++ b/src/main/java/com/alibaba/druid/sql/dialect/mysql/visitor/MySqlOutputVisitor.java @@ -343,9 +343,14 @@ public boolean visit(SQLDataType x) { print(")"); } - if (Boolean.TRUE == x.getAttribute("unsigned")) { - print(" unsigned"); + if (Boolean.TRUE == x.getAttribute("UNSIGNED")) { + print(" UNSIGNED"); } + + if (Boolean.TRUE == x.getAttribute("ZEROFILL")) { + print(" ZEROFILL"); + } + if (x instanceof SQLCharactorDataType) { SQLCharactorDataType charType = (SQLCharactorDataType) x;