Whole file
David-Wobrock/sqlvalidator
The author described this change as “Fix Alias.known_fields for aliased subqueries with specific fields”. It counts as a record because the check below fails on the code as it stood at 67334fc9d and passes on 00eab4924, with nothing else changed between the two runs.
ProjectDavid-Wobrock/sqlvalidator
Fix saved2021-11-14
Sharing licenceMIT · LICENSE
Change size+4 −1
What the code was meant to do, written into the code itself as a save note
Fix Alias.known_fields for aliased subqueries with specific fields
The change
| 1037 | 1037 | ||
| 1038 | 1038 | @property | |
| 1039 | 1039 | def known_fields(self) -> Set[str]: | |
| 1040 | - | return self.expression.known_fields | |
| 1040 | + | return { | |
| 1041 | + | "{}.{}".format(transform(self.alias), f) | |
| 1042 | + | for f in self.expression.known_fields | |
| 1043 | + | } | |
| 1041 | 1044 | ||
| 1042 | 1045 | ||
| 1043 | 1046 | class Index(Expression): |
The check that tells the two apart
fail→pass·tests/integration/test_validation.py::test_specified_field_from_alias_subquery
Check file tests/integration/test_validation.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.
Origin and history
The code before it67334fc9dcc4b7fb166433e0789e6b06ab36d8ef
Broken version dated2021-11-14
Modulesqlvalidator.grammar.sql
Units changedAlias
Fingerprint9cef8029aa365355
Checked2026-08-18 by goldset/0.1
Every field above is generated by our program. None of it is written by hand.
Other bugs found in David-Wobrock/sqlvalidator
- 2022-04-15Fix #38 -- Handle nested case expressions
- 2021-12-22Fix #29 -- Handle strings containing others quotes
- 2021-12-22Fix #35 -- Handle index based access on function call
- 2021-12-22Fix #34 -- Handle parsing a function with a single comma string
- 2021-11-15Fix validating between predicate conditions
- 2021-11-15Fix handling Any return type as invalid WHERE/HAVING condition