Documentation
¶
Overview ¶
Package sql provides bulk insert and upsert SQL query builders with retry helpers.
Index ¶
- Constants
- func GenerateBulkInsertSQL[T any](tableName string, paramPlaceholder string, entityList []T, ...) (sql string, params []any)
- func GenerateBulkUpsertSQL(tableName string, columns, conflictColumns, updateColumns []string, ...) (query string, args []any, err error)
- func GenerateInsertSQL(tableName string, fieldsValuesMapping map[string]any) (sql string, params []any)
- func GenerateUpsertSQL(tableName string, fieldsValuesMapping map[string]any, conflictColumns []string) (sql string, params []any)
- func QueryRowToStruct[T any](ctx context.Context, conn sqlscan.Querier, query string, args ...any) (*T, error)
- func QueryRowsPrimitive[T any](ctx context.Context, conn sqlscan.Querier, query string, args ...any) ([]T, error)
- func QueryRowsPrimitiveWithRetry[T any](ctx context.Context, conn sqlscan.Querier, query string, args ...any) ([]T, error)
- func QueryRowsToStruct[T any](ctx context.Context, conn sqlscan.Querier, query string, args ...any) ([]*T, error)
- func QueryRowsToStructWithRetry[T any](ctx context.Context, conn sqlscan.Querier, query string, args ...any) ([]*T, error)
Constants ¶
View Source
const PQParamPlaceholder = "$"
Variables ¶
This section is empty.
Functions ¶
func GenerateBulkInsertSQL ¶
func GenerateBulkUpsertSQL ¶
func GenerateBulkUpsertSQL( tableName string, columns, conflictColumns, updateColumns []string, rowCount int, rowValues func(i int) []any, ) (query string, args []any, err error)
GenerateBulkUpsertSQL requires non-empty conflictColumns. Empty updateColumns => DO NOTHING on that conflict.
func GenerateInsertSQL ¶
func GenerateUpsertSQL ¶
func GenerateUpsertSQL(tableName string, fieldsValuesMapping map[string]any, conflictColumns []string) (sql string, params []any)
GenerateUpsertSQL appends ON CONFLICT only when conflictColumns is non-empty.
func QueryRowToStruct ¶
func QueryRowsPrimitive ¶
func QueryRowsPrimitiveWithRetry ¶
func QueryRowsPrimitiveWithRetry[T any](ctx context.Context, conn sqlscan.Querier, query string, args ...any) ([]T, error)
QueryRowsPrimitiveWithRetry is QueryRowsPrimitive wrapped for read-replica conflict retry.
func QueryRowsToStruct ¶
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.