Repository navigation
docs: the Inspecting SQL guide page (#767) - #833
Conversation
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ecting-sql-guide-page
0x054
left a comment
There was a problem hiding this comment.
Spec: PASS
- Minor · [ticket#Acceptance criteria] · docs/pages/guide/inspecting-sql.md:150 at a50121c · Missing · the caplog fence is
{test=compile ...}, so the docs harness never runs that block (itsdbfixture, itscaplog.at_level(..., logger="ferro.sql")call, the[record] = ...unpacking). The AC says every Python block is a snippet or a{test=run prelude=...}fence. The behaviour it shows is pinned elsewhere (tests/test_statement_log.pyassertsrecord.operation/record.paramsunder caplog), so this is not a correctness hole. The fence reason is also inaccurate: the conventions provide{test=pytest path=...}for exactly this case, but today it is wired only to the testing how-to (tests/test_docs_testing_fixtures.py, whosetesting_models.pyhas noAccount). Accept the deviation, or file a follow-up that extends that harness to this page. - Minor · [ticket#What to build] · docs/pages/guide/schema/data-steps.md:251 at a50121c · Misunderstood · the ticket asks the page to turn the statement log on "with two lines of
logging", and the data-steps note sends readers to Inspecting SQL "for the two lines". The page has no two-line setup. Its section (inspecting-sql.md:64-72) shows an 8-line collecting handler and links to Connections forlogging.basicConfig. Put the twobasicConfig/setLevellines on the page, or point the data-steps link at../connections.md#logging.
Cannot verify: none
Quality: FAIL
- Important · [none] · docs/pages/guide/inspecting-sql.md:69-72,130-140 at a50121c · the page shows the regions in a different order from the script that captures their output, so two printed results cannot be reproduced in page order, and the prose contradicts itself. The
statement-loghandler is shown at line 69, after thefirstblock (line 26) has already runconnect(...), yet line 72 says "Every statement from here on, the schema workconnect()does included, lands inrecords". Theoperationsblock (line 133) prints['migrate', 'save']for "each record so far". In page order the handler was attached afterconnect(), so there is nomigraterecord. Thesecretsblock (line 115) comes earlier on the page and runsrecords.clear()followed by a fetch, so "so far" would print['fetch']. In the script the order is statement-log → first → … → operations → count-and-update → secrets, and theprints:blocks come from that order. A reader who follows the page, or pastes its blocks in sequence, gets different output from what the page prints, and themigrateexplanation at line 142 does not match. Fix: show the statement-log section before the firstconnectblock, and reorder the script regions so the page order and the execution order are the same (or move theoperationsregion's "so far" print ahead ofsecretson the page). - Minor · [none] · docs/examples/inspecting_sql.py:5-6 at a50121c · the module docstring says the page's SQL blocks are regenerated by
tests/test_docs_sql.py. The page has no SQL fences andPAGESis unchanged, as the PR body says. The comment is false and points a maintainer at a test that does not cover this page. Drop the clause.
Checked and accepted: the see-also lines in queries.md / raw-sql.md (outside Files owned, named by the ticket's Produces line). The prose operation list ['migrate', 'catalog', 'save'] and the "only $1/$2 and dialect change on PostgreSQL" claim (verified by running the example against Postgres 18 in a fresh schema: output matches the SQLite blocks apart from placeholders and dialect, and the first list is ['migrate', 'catalog', 'save']). I-7 tabs with a generated twin. I-8 account lambdas (lint exit 0). I-10 CHANGELOG untouched. The ## Laws section and Verify block corrected: no match the ticket's Verify.
Verify: PR head a50121c passed (zensical build --clean --strict; the four docs test files with --db-backends=sqlite,postgres, 417 passed; python -m tests._docs_checks over the six paths, exit 0; also tests/test_docs_output.py -k inspecting, 12 passed)
Trial merge: not run (base unchanged; the head already contains origin/main cf1ee43)
#767) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
0x054
left a comment
There was a problem hiding this comment.
Re-review: a50121c..79da0d1
- Important (page order not the run order): ADDRESSED · docs/examples/inspecting_sql.py:44-100 and docs/pages/guide/inspecting-sql.md:69-143 at 79da0d1 · the regions now run in page order: first, count-and-update, statement-log, a-record, attributes, operations, secrets, then the test. The
operationsregion clears the list before its transaction, so its single printed line depends on nothing earlier. Line 72 now says the program above already calledconnect()and tells the reader to put the lines beforeconnect()to get themigraterecords. Keeping the setup after the firstconnect()is acceptable because the page states what that costs and how to avoid it. I ran the fixed example on Postgres 18 with every record listed:['save']after theINSERT, then['transaction', 'save', 'fetch', 'transaction'], with nocatalogrecord. That matches the new prose that the.sql()call touchedAccountbefore the log was on. - Minor (caplog fence compile-only): NOT ADDRESSED · docs/pages/guide/inspecting-sql.md:150 at 79da0d1 · the fence is still
test=compile. The deviation is now declared in the PR body, and follow-up #835 (Docs harness: run test=pytest fences from pages other than the testing how-to) is open. Accepted as a declared deviation; it does not block. - Minor (data-steps "two lines"): ADDRESSED · docs/pages/guide/schema/data-steps.md:251 at 79da0d1 · now points at
../connections.md#loggingfor the two lines and at Inspecting SQL for what they record. - Minor (example docstring names test_docs_sql.py): ADDRESSED · docs/examples/inspecting_sql.py:3-6 at 79da0d1.
No new Critical or Important breakage in the fix diff.
Spec: PASS
Cannot verify: none
Quality: PASS
Verify: PR head 79da0d1 passed (zensical build --clean --strict; the four docs test files with --db-backends=sqlite,postgres, 417 passed; tests/test_docs_output.py -k inspecting, 12 passed; python -m tests._docs_checks over the six paths, exit 0)
Trial merge: not run (base unchanged; the head contains origin/main cf1ee43)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ecting-sql-guide-page
Closes #767
What
Adds the Inspecting SQL guide page under Guide after Raw SQL:
.sql()oncountandupdate, theferro.sqllog turned on, a record as a message and as attributes,***for a secret column, thecatalogandtransactionrecords, and acaplogtest. Every output block is regenerated fromdocs/examples/inspecting_sql.py(and its generated_annotatedtwin). The data-steps, auto-migrate, Connections, Queries and Raw SQL guides link to it.Verify
Ran the ticket's Verify block on
cbec99bd(a formatter-only commit after79da0d10; main merged at cf1ee43): passed (strict build clean; the four docs test files plustest_docs_output.pyandtest_docs_twins.py, 847 tests on SQLite + Postgres 18; docs lint exit 0).TDD: RED the docs lint command named the page and both examples, which did not exist on main; GREEN the same command, the strict build and the four docs test files passed after the edit. Output blocks are checked by
tests/test_docs_output.py(1077 passed across the wider docs suite).Verify block corrected: no
Interfaces
Interfaces changed: none
Laws
tests/_docs_twins.pyaccount; docs lint passesprints:-backed, none typed; one running example; lead-in and result sentencesNotes for the reviewer
Outside Files owned:
docs/pages/guide/queries.mdanddocs/pages/guide/raw-sql.mdeach gain one see-also line (the ticket's Produces names them).Fix round: the example's regions now run in the order the page shows them, so every printed result is reproducible by following the page. I kept the log setup after the first
connect()rather than before it: the opening program stays short, and the page says plainly that a reader who wants themigraterecords puts those lines beforeconnect(). The operations block therefore prints only the transaction's records, and thecatalogrecord is explained in prose (the earlier.sql()call already touched the table).Declared deviations:
test=compile, not a runnable fence:test=pytestfences build only from the testing how-to. Follow-up filed as Docs harness: run test=pytest fences from pages other than the testing how-to #835 (needs-triage). The same logic runs as theassert-on-recordsregion in the example.catalogrecord is prose, not a(postgres)prints block, which would need an argv-driven connect in the example.tests/test_docs_sql.pyPAGESis unchanged; the example docstring now says so.logginglines, and at this page for what they record.🤖 Generated with Claude Code