Skip to content

Commit 875680d

Browse files
authored
Support SQL parsing of Oracle not equals operators containing spaces (#34721)
1 parent 89f0a92 commit 875680d

File tree

3 files changed

+56
-1
lines changed

3 files changed

+56
-1
lines changed

parser/sql/dialect/oracle/src/main/antlr4/imports/oracle/BaseRule.g4

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -694,7 +694,7 @@ booleanPrimary
694694
;
695695

696696
comparisonOperator
697-
: EQ_ | GTE_ | GT_ | LTE_ | LT_ | NEQ_ | (GT_ | LT_) EQ_
697+
: EQ_ | GTE_ | GT_ | LTE_ | LT_ | NEQ_ | (GT_ | LT_) EQ_ | LT_ GT_ | (NOT_ | CARET_) EQ_
698698
;
699699

700700
predicate

test/it/parser/src/main/resources/case/dml/select.xml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10106,4 +10106,58 @@
1010610106
</expr>
1010710107
</where>
1010810108
</select>
10109+
10110+
<select sql-case-id="select_with_not_equal_comparison_with_space">
10111+
<projections start-index="7" stop-index="7">
10112+
<shorthand-projection start-index="7" stop-index="7"/>
10113+
</projections>
10114+
<from start-index="14" stop-index="17">
10115+
<simple-table name="test" start-index="14" stop-index="17"/>
10116+
</from>
10117+
<where start-index="19" stop-index="62">
10118+
<expr start-index="25" stop-index="62">
10119+
<binary-operation-expression start-index="25" stop-index="62">
10120+
<left start-index="25" stop-index="49">
10121+
<binary-operation-expression start-index="25" stop-index="49">
10122+
<left start-index="25" stop-index="33">
10123+
<binary-operation-expression start-index="25" stop-index="33">
10124+
<left start-index="25" stop-index="26">
10125+
<column name="id" start-index="25" stop-index="26"/>
10126+
</left>
10127+
<operator>&lt;&gt;</operator>
10128+
<right start-index="33" stop-index="33">
10129+
<literal-expression value="1" start-index="33" stop-index="33"/>
10130+
</right>
10131+
</binary-operation-expression>
10132+
</left>
10133+
<operator>and</operator>
10134+
<right start-index="39" stop-index="49">
10135+
<binary-operation-expression start-index="39" stop-index="49">
10136+
<left start-index="39" stop-index="42">
10137+
<column name="name" start-index="39" stop-index="42"/>
10138+
</left>
10139+
<operator>!=</operator>
10140+
<right start-index="49" stop-index="49">
10141+
<literal-expression value="1" start-index="49" stop-index="49"/>
10142+
</right>
10143+
</binary-operation-expression>
10144+
</right>
10145+
</binary-operation-expression>
10146+
</left>
10147+
<operator>and</operator>
10148+
<right start-index="55" stop-index="62">
10149+
<binary-operation-expression start-index="55" stop-index="62">
10150+
<left start-index="55" stop-index="56">
10151+
<column name="id" start-index="55" stop-index="56"/>
10152+
</left>
10153+
<operator>^=</operator>
10154+
<right start-index="62" stop-index="62">
10155+
<literal-expression value="3" start-index="62" stop-index="62"/>
10156+
</right>
10157+
</binary-operation-expression>
10158+
</right>
10159+
</binary-operation-expression>
10160+
</expr>
10161+
</where>
10162+
</select>
1010910163
</sql-parser-test-cases>

test/it/parser/src/main/resources/sql/supported/dml/select.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,4 +316,5 @@
316316
<sql-case id="select_with_mixed_single_double_quoted_literals" value="SELECT 'x' &quot;x&quot; 'x' FROM t_order WHERE status LIKE &quot;%&quot; '123' &quot;%&quot;" db-types="MySQL"/>
317317
<sql-case id="select_is_not_nan" value="SELECT COUNT(*) FROM employees WHERE commission_pct IS NOT NAN" db-types="Oracle"/>
318318
<sql-case id="select_with_comparison_with_space" value="select * from test where id &gt; = 1 or name &lt; = 2" db-types="Oracle"/>
319+
<sql-case id="select_with_not_equal_comparison_with_space" value="select * from test where id &lt; &gt; 1 and name ! = 1 and id ^ = 3 " db-types="Oracle"/>
319320
</sql-cases>

0 commit comments

Comments
 (0)