Repository navigation
Parse NOT IN in sql parser - #1832
Draft
agusaldasoro wants to merge 1 commit into
Draft
agusaldasoro wants to merge 1 commit into
agusaldasoro wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
JSqlVisitor.visit(InExpression)ignoredinExpression.isNot(), soNOT INwas parsed into the sameSqlInConditionasIN. Each consumer then translated the condition into its opposite:SMTConditionVisitor):status NOT IN ('A', 'B')became(or (= STATUS "A") (= STATUS "B")). The formula is satisfiable, but the generated rows never satisfy the query. With aCHECK (... NOT IN ...)in the schema, the generated row violates the constraint and the database rejects theINSERT.SqlConditionTranslator):CHECK (status NOT IN ('A', 'B'))became anEnumConstraintwith valuesAandB. The column was restricted to exactly the forbidden values.Fix
SqlInConditiongets anegatedflag, included inequals/hashCodeand printed bytoSql()asNOT IN. The existing two-argument constructor keepsnegated = false.JSqlVisitorpassesinExpression.isNot().SMTConditionVisitortranslates a negated list as a conjunction of inequalities:(and (distinct STATUS "A") (distinct STATUS "B")), or a singledistinctfor a one-element list.SqlConditionTranslatorthrowsSqlCannotBeTranslatedExceptionfor a negated list. There is no "any value but these" constraint, soTableConstraintBuildernow reports the check as anUnsupportedTableConstraintinstead of inverting it, as it already does for other untranslatable checks.ALLwas already excluded from theANY/SOMEmembership rewrite, so<> ALL (ARRAY[...])is not affected.