Refactoring ExternArgs -> SQL gen for type safety #690
Labels
enhancement
New feature or request
refactor
Changes would be considered a refactor of existing functionality.
sql-gen
As noted during discussion in #683, there's currently situations where we are using purely programmatic logic with vectors of enums rather than type-driven logic, when types are fairly good at encoding logical invariants. This results in errors like the one mentioned in #640, unfortunately.
I believe we should start with tokenizing the
ExternArgs
more or less read off "as-is", and then use them to buildstruct CreateFn
or similar that can onlyfmt::Display
into a valid SQL statement. By taking in the ExternArgs "directly", and only verifying they are valid arguments in the first step, we effectively "lex" them, and then parse them in a separate step that will discern if the combined arguments can logically parse into a correct SQL statement. This is good compiler design (and PGX is more and more that: a compiler) and allows distinguishing between individually invalid and combined invalid inputs, providing more precise and useful error messages.The text was updated successfully, but these errors were encountered: