Skip to content

docs: document param-ordering, agg-validation, and Attr dataclass invariants - #9

Merged
Xof merged 1 commit into
mainfrom
docs/comment-pass
Jun 21, 2026
Merged

docs: document param-ordering, agg-validation, and Attr dataclass invariants#9
Xof merged 1 commit into
mainfrom
docs/comment-pass

Conversation

@Xof

@Xof Xof commented Jun 21, 2026

Copy link
Copy Markdown
Collaborator

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).

  • compiler.py — ADD a third hard invariant to the module header: parameters
    are appended to self.params in the same left-to-right order their
    placeholders appear in the emitted SQL. Positional paramstyles (qmark ?,
    format %s) bind the Nth value to the Nth placeholder, so any multi-source
    compile method must visit sources in textual order; Division is the subtle
    case (outer dividend FROM → divisor → re-visited inner dividend).
  • aggregates.py — EXTEND output_domain to record the cross-file invariant
    that Grouping.__post_init__ pre-validates aggregate attrs, so the
    schema[self.attr] lookup cannot raise in normal flow.
  • predicates.py — EXTEND the Attr.__hash__ note: a hand-written
    __eq__/__hash__ coexists with @dataclass(frozen=True) because dataclass
    only fills in dunders not already defined; the relation nodes take the
    opposite eq=False route.

Not addressed here (flagged for a later decision)

tests/test_postgres.py comments describe psycopg as using the format
paramstyle (%s), but psycopg 3.x reports pyformat (%(pN)s + dict params) —
as engine.py's own corrected comment already notes. The tests pass; only the
comments misdescribe the mechanism. Left untouched (comment/code mismatch to
correct deliberately, not paper over).

Local gate green: ruff, mypy, pytest (119 passed, 15 skipped).

…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.
@Xof
Xof merged commit 1cfe974 into main Jun 21, 2026
6 checks passed
@Xof
Xof deleted the docs/comment-pass branch June 21, 2026 16:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant