Files
db/exec/query_factory.go
whatandClaude 304d553b3c docs: Add CLAUDE.md with codebase guidance
Create comprehensive documentation for future Claude Code instances working in this repository, including:
- Development commands for testing, building, and code quality
- Core architecture overview of the SQL query builder system
- Directory structure and component explanations
- Testing patterns and conventions
- Key dependencies and their purposes

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-27 15:47:28 +08:00

37 lines
921 B
Go

package exec
import (
"context"
"database/sql"
"git.fsdpf.net/go/db/internal/sb"
)
type (
//nolint:stylecheck // keep name for backwards compatibility
DbExecutor interface {
ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
}
QueryFactory interface {
FromSQL(sql string, args ...interface{}) QueryExecutor
FromSQLBuilder(b sb.SQLBuilder) QueryExecutor
}
querySupport struct {
de DbExecutor
}
)
func NewQueryFactory(de DbExecutor) QueryFactory {
return &querySupport{de}
}
func (qs *querySupport) FromSQL(query string, args ...interface{}) QueryExecutor {
return newQueryExecutor(qs.de, nil, query, args...)
}
func (qs *querySupport) FromSQLBuilder(b sb.SQLBuilder) QueryExecutor {
query, args, err := b.ToSQL()
return newQueryExecutor(qs.de, err, query, args...)
}