-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ScriptUtils parsing failed when using field name with 'end' keyword #1547
Comments
I've digged a little deeper and figured that the key is naming. There's field named |
If we modify the CREATE TABLE bar (
end_time VARCHAR(255)
); The test is broken. Seems to me the |
Hey @skyline75489, thanks a lot for digging into this. There are indeed different quirks like this in Can you please point use to a more robust solution we could use if you know one that supports different vendor specific SQL? The |
I agree However, for |
I analysed the problem and the following two ifs are the problem: if (!inLiteral && !inComment && containsSubstringAtOffset(lowerCaseScriptContent, "BEGIN", i)) {
compoundStatementDepth++;
}
if (!inLiteral && !inComment && containsSubstringAtOffset(lowerCaseScriptContent, "END", i) && compoundStatementDepth > 0) {
compoundStatementDepth--;
}
final boolean inCompoundStatement = compoundStatementDepth != 0; Inside the method I will create a pull request with the fix when it is ready. I have to find a better way to check if its the beginning or end of a procedure. |
I agree. This is, I think, the way I'd prefer to go - I spent some time looking for a splitter/parser that we could use, but keep coming back to:
All the parsers I've seen would push us towards a parser/configuration-per-dialect, which I fear would be just be a lot of work given the number of DBs we have to support. Additionally, any cases where the parser has bugs or is overly strict would cause an unnecessary rejection. We just want to split the script, not validate it. I think that #1627 fixes this particular issue, and seems to be solid at splitting very messy or malformed scripts correctly. |
Fix was released in 1.12.0. |
Glad to see it shipped 🥂 You guys are awesome! |
I'm using
runInitScript
and it seems to falsely parse the sql:I've stepped into the code and found that
splitSqlScript
inScriptUtils
thinks there are 3 statements:create database
,use
and combined 2create table
. The last statement, of course, throws sql syntax error.The text was updated successfully, but these errors were encountered: