Skip to content

feat: add AfterScanner hook for post-scan field hydration#44

Closed
klaidliadon wants to merge 4 commits intomasterfrom
feat/after-scan-hook
Closed

feat: add AfterScanner hook for post-scan field hydration#44
klaidliadon wants to merge 4 commits intomasterfrom
feat/after-scan-hook

Conversation

@klaidliadon
Copy link
Copy Markdown
Contributor

Summary

  • Adds AfterScanner interface: structs implementing AfterScan() error get called automatically after scan in Table methods
  • Hook points: Get, List, ListPaged, Iter — zero reflection, pure generic type assertions
  • Zero cost for types that don't implement the interface

Refs #43

Test plan

  • Get with AfterScanner — verifies hook runs and modifies fields
  • List with AfterScanner — verifies hook runs on each element
  • Get without AfterScanner — verifies no-op (existing behavior preserved)
  • Error propagation — Get and List surface AfterScan errors
  • Full existing test suite passes

Returns all records even when some AfterScan calls fail.
AfterScanError carries a map[int]error keyed by index and
implements Unwrap() []error for errors.Is transitivity.

Refs #43
Errors map keyed by record ID instead of slice index.
Error message lists each failing ID and its error.

Refs #43
@klaidliadon
Copy link
Copy Markdown
Contributor Author

Closing per Vojtech's feedback — hooks make pgkit too ORM-like. Moving the presentation logic to the OMSX RPC layer instead.

@klaidliadon klaidliadon closed this Apr 9, 2026
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