gorm-sql-builder

Execute raw SQL with GORM for reads, writes, and DDL.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

GORM users often need to run low-level SQL and fine-tune queries while still leveraging the ORM for models and relationships. This Skill provides direct access to raw SQL execution, clause customization, and debugging utilities to build efficient, database-specific queries without sacrificing ORM integration.

Core Features & Use Cases

  • Raw SQL execution and scanning: run queries with db.Raw and scan results into models or primitive types.
  • Clause customization: apply and compose custom clauses for inserts, updates, and complex queries.
  • Debugging and validation: generate executable SQL strings with ToSQL and preview queries prior to execution.
  • Named arguments and parameter binding: safely bind named, map, or struct parameters to SQL statements.
  • Prepared statements and performance: enable prepared statements to optimize repeated query paths.

Quick Start

Start by writing a raw SQL query with db.Raw and scanning the result into a struct.

Frequently Asked Questions about gorm-sql-builder

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

FAQPage Schema
How do I execute raw SQL queries in GORM while preserving ORM models?

GORM allows executing raw SQL while preserving ORM models by using the db.Raw API to run custom statements and scan returned rows directly into existing structs or primitive types.

What is the best way to preview a GORM query before executing it?

The best way to preview a GORM query before execution is using the ToSQL dry-run generation utility, which renders the executable SQL string without touching the database to validate clause composition and parameter binding.

Can I use named arguments and struct parameters with db.Raw in GORM?

Yes, you can use named arguments with db.Raw in GORM to safely bind map or struct parameters to your SQL statements, ensuring precise parameter binding and secure handling of query inputs.

Does GORM support custom clauses for complex inserts and updates?

GORM supports custom clauses for complex inserts and updates by allowing you to apply and compose tailored clause expressions, enabling database-specific query construction without sacrificing underlying ORM integration.

How do I optimize repeated raw SQL execution paths in GORM?

You optimize repeated raw SQL execution paths in GORM by enabling prepared statements, which pre-compile the query structure to improve performance across iterative db.Raw or db.Exec operations.

When should I use GORM raw SQL execution instead of standard ORM methods?

You should use GORM raw SQL execution instead of standard ORM methods when you need low-level database-specific tuning, complex clause composition, or precise SQL generation that standard ORM chaining cannot achieve.