You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by du...@apache.org on 2023/05/10 11:40:35 UTC
[shardingsphere] branch master updated: Support the precision of the column as a decimal. (#25555)
This is an automated email from the ASF dual-hosted git repository.
duanzhengqiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new 3c3b9b56c9b Support the precision of the column as a decimal. (#25555)
3c3b9b56c9b is described below
commit 3c3b9b56c9bec6afdc47da3a82862ec548796035
Author: Cong Hu <ia...@qq.com>
AuthorDate: Wed May 10 19:40:27 2023 +0800
Support the precision of the column as a decimal. (#25555)
---
.../parser/mysql/visitor/statement/MySQLStatementVisitor.java | 3 ++-
test/it/parser/src/main/resources/case/ddl/alter-table.xml | 9 +++++++++
.../parser/src/main/resources/sql/supported/ddl/alter-table.xml | 1 +
3 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/parser/sql/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/visitor/statement/MySQLStatementVisitor.java b/parser/sql/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/visitor/statement/MySQLStatementVisitor.java
index c84321eb2dd..c489af917b6 100644
--- a/parser/sql/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/visitor/statement/MySQLStatementVisitor.java
+++ b/parser/sql/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/visitor/statement/MySQLStatementVisitor.java
@@ -221,6 +221,7 @@ import org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.dml.MySQ
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.dml.MySQLSelectStatement;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.dml.MySQLUpdateStatement;
+import java.math.BigDecimal;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedList;
@@ -1139,7 +1140,7 @@ public abstract class MySQLStatementVisitor extends MySQLStatementBaseVisitor<AS
DataTypeLengthSegment result = new DataTypeLengthSegment();
result.setStartIndex(ctx.start.getStartIndex());
result.setStopIndex(ctx.stop.getStartIndex());
- result.setPrecision(Integer.parseInt(ctx.length.getText()));
+ result.setPrecision(new BigDecimal(ctx.length.getText()).intValue());
return result;
}
diff --git a/test/it/parser/src/main/resources/case/ddl/alter-table.xml b/test/it/parser/src/main/resources/case/ddl/alter-table.xml
index 87716c9fbfe..7a5246918f4 100644
--- a/test/it/parser/src/main/resources/case/ddl/alter-table.xml
+++ b/test/it/parser/src/main/resources/case/ddl/alter-table.xml
@@ -1233,4 +1233,13 @@
<alter-table sql-case-id="alter_table_drop_expression">
<table name="t_order" start-index="12" stop-index="18" />
</alter-table>
+
+ <alter-table sql-case-id="alter_table_modify_column_precision_with_decimal">
+ <table name="t_order" start-index="12" stop-index="18" />
+ <modify-column>
+ <column-definition type="VARCHAR" start-index="34" stop-index="59">
+ <column name="a" stop-index="34" start-index="34" />
+ </column-definition>
+ </modify-column>
+ </alter-table>
</sql-parser-test-cases>
diff --git a/test/it/parser/src/main/resources/sql/supported/ddl/alter-table.xml b/test/it/parser/src/main/resources/sql/supported/ddl/alter-table.xml
index 7d006444525..c46a37d8b35 100644
--- a/test/it/parser/src/main/resources/sql/supported/ddl/alter-table.xml
+++ b/test/it/parser/src/main/resources/sql/supported/ddl/alter-table.xml
@@ -154,4 +154,5 @@
<sql-case id="alter_table_reset" value="ALTER TABLE t_order RESET (fillfactor = 12)" db-types="PostgreSQL" />
<sql-case id="alter_table_set_access_method" value="ALTER TABLE t_order SET ACCESS METHOD heap, SET ACCESS METHOD heap2" db-types="PostgreSQL" />
<sql-case id="alter_table_drop_expression" value="ALTER TABLE t_order ALTER COLUMN a DROP EXPRESSION;" db-types="PostgreSQL" />
+ <sql-case id="alter_table_modify_column_precision_with_decimal" value="ALTER TABLE t_order MODIFY COLUMN a VARCHAR(10.000000000001)" db-types="MySQL" />
</sql-cases>