alibaba / cobar

a proxy for sharding databases and tables
Apache License 2.0
3.21k stars 1.22k forks source link

SQLParserDelegate不能解析DDL语句中的FOREIGN KEY #83

Open long187 opened 7 years ago

long187 commented 7 years ago
CREATE TABLE IF NOT EXISTS `test_table_normal`(  
scoreID INTEGER NOT NULL PRIMARY KEY,  
stuID     INTEGER NOT NULL,  
KEMUID     INTEGER NOT NULL,  
score     FLOAT,  
FOREIGN KEY SCORE_ID_FK (stuID) REFERENCES students (stuid),  
CONSTRAINT CHK_SCORE_ZIP CHECK (SCORE > 0)  
);  
ALTER TABLE test_table_normal
ADD FOREIGN KEY (stuID)
REFERENCES Persons(stuID);

报错:

java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; Error occurs around this fragment: {FLOAT,  
FOREIGN KEY SCORE}. Error cause: unsupportted column definition
    at com.alibaba.cobar.parser.recognizer.SQLParserDelegate.parse(SQLParserDelegate.java:155)
    at com.alibaba.cobar.parser.recognizer.SQLParserDelegate.parse(SQLParserDelegate.java:160)
    at com.alibaba.cobar.parser.recognizer.SQLParserDelegate.parse(SQLParserDelegate.java:164)
    at com.alibaba.cobar.parser.recognizer.SQLParserDelegateTest.testCreateAndDropTable(SQLParserDelegateTest.java:157)