-
1. Re: keyword DECIMAL provokes error
rhauch Feb 10, 2015 10:10 AM (in response to vobson)1 of 1 people found this helpfulParsing DDL is very context-sensitive, so we'd need to see some sample DDL with information about the type of DDL (what DBMS is it for, and is it one of the grammars that ModeShape supports) and where in the DDL file the parser is failing. A more complete stack trace would be nice so we could help isolate the problem (if there is one).
Of course, our community's code is open source, so you could always step through the parsing code and try to find the problem and suggest a fix.
-
2. Re: Re: keyword DECIMAL provokes error
vobson Feb 10, 2015 11:37 AM (in response to rhauch)Yes, I'll get and debug the sources.
The input file contains
--- First line follows:
CREATE TABLE TEST (FIELD_1 CHAR(3) NOT NULL
,FIELD_2 DECIMAL(9,2) NOT NULL
,FIELD_3 CHAR(3) NOT NULL
,PRIMARY KEY (FIELD1
FIELD2)
) IN Tablespace;
--- first line not in file
If it is a bug in the parser it should occur with this statement. The critical literal ist coloured red in line 2
The error
Error: java.lang.Integer cannot be cast to java.lang.Long
is printed by
protected static void printError(int exitCode, String message) { System.err.println("Error: " + message); System.err.println(); printUsage(System.out); System.exit(exitCode); }
which is part of the parser. The parser itself is copied from an example parser where literals were translated.
I'll keep you up to date about my debugging results.
-
3. Re: Re: keyword DECIMAL provokes error
rhauch Feb 10, 2015 11:46 AM (in response to vobson)We have quite a few unit tests for various parsers in our codebase. You may find it pretty easy to create a new test method (or multiple ones) in the class for the appropriate dialect (e.g., PostgresDdlParserTest.java for the PostgreSQL parser, etc.); it might be easy to debug when just running the parser. Doing this also makes it very easy for you to create a pull-request with your additions, allowing us to directly re-use your tests and incorporate them into our codebase. And, if it turns out there is a bug in the code, then these tests would likely be either sufficient to prevent regressions or at the very least a great start.
BTW, if you happen to find a bug and fix it locally, then log an issue in our JIRA and include the fix in your pull-request. We'll review and, if we have no questions or concerns, merge it into the codebase.
-
4. Re: keyword DECIMAL provokes error
vobson Feb 11, 2015 11:41 AM (in response to vobson)I got it.
In the parser sample I copied was code like
Object prop = node.getProperty(DATATYPE_LENGTH);
if (prop != null)
column.length = (int) number(prop);
where number was a "if value != null return (Long) value;"
This worked fine a few times and threw an exception.
I changed it to
coloumn.length = Integer.valueof(prop.toString());
and it works fine now.
Thank you for your patience. If a noob diploma confirms beeing a noob this may be one.
Sorry.
Martin