gorm-raw-sql

Execute, inspect, and debug raw SQL and SQL builder queries in GORM.

Updated Apr 4, 2026
One-click install
npx skills add https://github.com/liurida/gorm-development-skill --skill gorm-raw-sql
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: gorm-raw-sql
Source: https://github.com/liurida/gorm-development-skill/tree/main/raw_sql
Command: npx skills add https://github.com/liurida/gorm-development-skill --skill gorm-raw-sql

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

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.

Frequently Asked Questions about gorm-raw-sql

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I execute raw SQL queries in GORM and scan results into structs?

To execute raw SQL queries in GORM, you use low-level Row and Rows access for manual scanning, safely mapping database records directly into target structs or primitives for reporting and ad-hoc queries.

How does GORM DryRun and ToSQL inspection work for debugging complex queries?

GORM DryRun and ToSQL inspection generate the final SQL statement and bound arguments as output without executing the query, allowing you to debug parameterized queries and SQL builder logic without side effects.

How do I use named arguments in GORM to prevent SQL injection?

You prevent SQL injection in GORM by using named arguments with parameterized query construction, passing maps or structs as inputs to improve readability and safely bind multiple parameters in complex SQL.

Does GORM raw SQL support optimizer and index hints for PostgreSQL and MySQL?

Yes, GORM raw SQL supports clause-based optimizer and index hints for PostgreSQL and MySQL, allowing you to apply low-level database directives to complex reporting queries when needed.

What is the best way to run multiple raw SQL statements on the same database connection in GORM?

The best way to run multiple statements on the same database connection in GORM is using connection-scoped execution, ensuring sequential raw SQL queries or Row scanning operations share a single session to prevent connection leaks.

When should I use GORM raw SQL instead of high-level APIs?

You should use GORM raw SQL instead of high-level APIs when your database-focused tasks require complex reporting queries, named-argument binding, or low-level Row scanning that standard ORM methods cannot express.