sqlutil

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 3, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExecInsertOrUpdate

func ExecInsertOrUpdate(
	ctx context.Context,
	tx *sql.Tx,
	query string,
	args ...interface{},
) (bool, error)

ExecInsertOrUpdate executes a MySQL "INSERT ... ON DUPLICATE KEY UPDATE" query, and returns true if it results in an insert.

func ExecSingleRow

func ExecSingleRow(
	ctx context.Context,
	tx *sql.Tx,
	query string,
	args ...interface{},
) error

ExecSingleRow executes a query without returning any rows and verifies that exactly one row was affected.

For an UPDATE query, this means that the query must actually alter the row, not simply match one row.

The args are for any placeholder parameters in the query. It returns an error if more than one row was affected.

func IsDeadlock

func IsDeadlock(err error) bool

IsDeadlock returns true if err represents a MySQL deadlock condition.

func IsDuplicateEntry

func IsDuplicateEntry(err error) bool

IsDuplicateEntry returns true if err represents a MySQL duplicate entry error.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL