-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Description
I am trying to parse a query which contains columns qualified with their table name, which has been aliased. However, the parser seems to choke at random instances of aliases. For example:
SELECT d.id, d.uuid, d.name, d.amount, d.percentage, d.modified_time FROM discount d LEFT OUTER JOIN discount_category dc ON d.id = dc.discount_id WHERE merchant_id=? AND deleted=? AND dc.discount_id IS NULL AND modified_time<? AND modified_time>=? ORDER BY modified_time
gives me the following error:
Caused by: net.sf.jsqlparser.parser.ParseException: Encountered " <S_IDENTIFIER> "dc "" at line 1, column 186.
Was expecting one of:
"NOT" ...
"(" ...
"(" ...
"NOT" ...
"NOT" ...
"NOT" ...
"NOT" ...
"(" ...
"(" ...
"(" ...
+about 40 more of the same line
Any ideas here? My first guess would be maybe when aliasing the table, I have LEFT OUTER JOIN discount_category dc instead of LEFT OUTER JOIN discount_category AS dc, so since the AS is missing the parser does not know what alias to look for...however, it successfully got through the first instance of the alias (d.id = dc.discount_id) so I'm not sure why it would be failing later.