Blog
sqlx
Technical notes on web development, DevOps, and AI integration.
2 articles
- 16:10backend
One Transaction or Half-Written Data: BeginTxx in sqlx
Org and member writes ran as separate statements; a mid-way failure left half-written data. One BeginTxx closes the gap.
TL;DR: Kartara had a design flaw. The organisation was written separately from its members. Using transactions fixed this issue.
#go#sqlx#mysql - 14:22backend
Go Repository Pattern: Nullable Model, One List
Database model and JSON DTO never share a struct: nullable columns scan into sql.NullX, responses use pointers, one List serves admin and public.
TL;DR: Database columns are stored in one struct. A separate struct handles JSON responses. Null types and escaping prevent silent bugs.
#go#mysql#sqlx