docs: document param-ordering, agg-validation, and Attr dataclass invariants - #9
Merged
Conversation
…ariants Comment-only pass; no behavior change. - compiler.py: ADD a third hard invariant to the module header — params are appended in the same left-to-right order their placeholders appear in the SQL text (required by positional paramstyles like qmark/format), with Division called out as the subtle case. - aggregates.py: EXTEND output_domain to record the cross-file invariant that Grouping.__post_init__ pre-validates aggregate attrs, so the schema lookup cannot raise in normal flow. - predicates.py: EXTEND the Attr.__hash__ note explaining why a hand-written __eq__/__hash__ coexists with @DataClass(frozen=True), and how the relation nodes take the opposite eq=False route.
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.
Comment-only pass
No behavior change. Documents three invariants that were load-bearing but
undocumented; the rest of the tree was left as-is (it is already densely and
accurately commented).
are appended to
self.paramsin the same left-to-right order theirplaceholders appear in the emitted SQL. Positional paramstyles (qmark
?,format
%s) bind the Nth value to the Nth placeholder, so any multi-sourcecompile method must visit sources in textual order; Division is the subtle
case (outer dividend FROM → divisor → re-visited inner dividend).
output_domainto record the cross-file invariantthat
Grouping.__post_init__pre-validates aggregate attrs, so theschema[self.attr]lookup cannot raise in normal flow.Attr.__hash__note: a hand-written__eq__/__hash__coexists with@dataclass(frozen=True)because dataclassonly fills in dunders not already defined; the relation nodes take the
opposite
eq=Falseroute.Not addressed here (flagged for a later decision)
tests/test_postgres.pycomments describe psycopg as using theformatparamstyle (
%s), but psycopg 3.x reportspyformat(%(pN)s+ dict params) —as
engine.py's own corrected comment already notes. The tests pass; only thecomments misdescribe the mechanism. Left untouched (comment/code mismatch to
correct deliberately, not paper over).
Local gate green:
ruff,mypy,pytest(119 passed, 15 skipped).