What problem does it solve?
Working with complex SQL that GORM's high-level APIs cannot express requires low-level execution, inspection, and careful parameter binding to avoid injection, connection leaks, and lost hooks; this Skill explains how to run, inspect, and safely handle raw SQL and SQL builder queries in GORM.
Core Features & Use Cases
- Raw Execution & Scanning: Execute raw queries and scan results into structs or primitives for reporting and ad-hoc queries.
- Named Arguments & Parameterization: Use named parameters and maps/structs to improve readability and safety for multi-parameter queries.
- Inspection Tools: Use DryRun, ToSQL, and statement inspection to generate SQL and arguments without side effects for debugging.
- Low-level Access & Hints: Work with Row/Rows for manual scanning, use clause-based optimizer and index hints, and run multiple statements on the same connection when needed.
Quick Start
Use the gorm-raw-sql skill to produce a parameterized raw SQL statement with named arguments, show the DryRun/ToSQL output and variables, and explain safe scanning into a target struct.