func GtAny(arr interface{}, value interface{}) ArrayCondition {
	return ArrayCondition{value, ">", "ANY", arr}
}
GtAny creates an "> ANY" condition on an array
package sqlz
import (
	"context"
	"database/sql"
	"fmt"
	"sort"
	"strconv"
	"strings"
	"github.com/jmoiron/sqlx"
)
type Ext interface {
	sqlx.Queryer
	sqlx.QueryerContext
	sqlx.Execer
	sqlx.ExecerContext
}
type Queryer interface {
	sqlx.Queryer
	sqlx.QueryerContext
}
type DB struct {
	*sqlx.DB
	ErrHandlers []func(err error)
}
type Tx struct {
	*sqlx.Tx
	ErrHandlers []func(err error)
}
type SQLStmt interface {
	ToSQL(bool) (string, []interface{})
}
func New(db *sql.DB, driverName string, errHandlerFuncs ...func(err error)) *DB {
	errHandlers := make([]func(err error), len(errHandlerFuncs))
	copy(errHandlers, errHandlerFuncs)
	return &DB{
		DB:          sqlx.NewDb(db, driverName),
		ErrHandlers: errHandlers,
	}
}
func Newx(db *sqlx.DB) *DB {
	return &DB{DB: db}
}
func (db *DB) Transactional(f func(tx *Tx) error, opts ...*sql.TxOptions) error {
	var lastOpts *sql.TxOptions
	if len(opts) > 0 {
		lastOpts = opts[len(opts)-1]
	}
	return db.TransactionalContext(context.Background(), lastOpts, f)
}
func (db *DB) TransactionalContext(
	ctx context.Context,
	opts *sql.TxOptions,
	f func(tx *Tx) error,
) error {
	tx, err := db.BeginTxx(ctx, opts)
	if err != nil {
		return fmt.Errorf("failed starting transaction: %w", err)
	}
	err = f(&Tx{Tx: tx, ErrHandlers: db.ErrHandlers})
	if err != nil {
		tx.Rollback()  
		return err
	}
	err = tx.Commit()
	if err != nil {
		return fmt.Errorf("failed committing transaction: %w", err)
	}
	return nil
}
type WhereCondition interface {
	Parse() (asSQL string, bindings []interface{})
}
type SimpleCondition struct {
	Left     string
	Right    interface{}
	Operator string
}
type AndOrCondition struct {
	Or         bool
	Conditions []WhereCondition
}
type PreCondition struct {
	Pre       string
	Condition WhereCondition
}
type SubqueryCondition struct {
	Stmt     *SelectStmt
	Operator string
}
type SQLCondition struct {
	Condition string
	Binds     []interface{}
}
type IndirectValue struct {
	Reference string
	Bindings  []interface{}
}
func Indirect(value string, bindings ...interface{}) IndirectValue {
	return IndirectValue{value, bindings}
}
func (i IndirectValue) ToSQL(_ bool) (string, []interface{}) {
	return i.Reference, i.Bindings
}
func And(conds ...WhereCondition) AndOrCondition {
	return AndOrCondition{false, conds}
}
func Or(conds ...WhereCondition) AndOrCondition {
	return AndOrCondition{true, conds}
}
func Not(cond WhereCondition) PreCondition {
	return PreCondition{"NOT", cond}
}
func Eq(col string, value interface{}) SimpleCondition {
	return SimpleCondition{col, value, "="}
}
func Ne(col string, value interface{}) SimpleCondition {
	return SimpleCondition{col, value, "<>"}
}
func Gt(col string, value interface{}) SimpleCondition {
	return SimpleCondition{col, value, ">"}
}
func Gte(col string, value interface{}) SimpleCondition {
	return SimpleCondition{col, value, ">="}
}
func Lt(col string, value interface{}) SimpleCondition {
	return SimpleCondition{col, value, "<"}
}
func Lte(col string, value interface{}) SimpleCondition {
	return SimpleCondition{col, value, "<="}
}
func Like(col string, value interface{}) SimpleCondition {
	return SimpleCondition{col, value, "LIKE"}
}
func NotLike(col string, value interface{}) SimpleCondition {
	return SimpleCondition{col, value, "NOT LIKE"}
}
func ILike(col string, value interface{}) SimpleCondition {
	return SimpleCondition{col, value, "ILIKE"}
}
func IsNull(col string) SimpleCondition {
	return SimpleCondition{col, nil, "IS NULL"}
}
func IsNotNull(col string) SimpleCondition {
	return SimpleCondition{col, nil, "IS NOT NULL"}
}
func Exists(stmt *SelectStmt) SubqueryCondition {
	return SubqueryCondition{stmt, "EXISTS"}
}
func NotExists(stmt *SelectStmt) SubqueryCondition {
	return SubqueryCondition{stmt, "NOT EXISTS"}
}
func JSONBOp(op string, left string, value interface{}) SimpleCondition {
	switch op {
	case "@>", "<@", "?", "?!", "?&", "||", "-", "#-":
		return SimpleCondition{left, value, op}
	default:
		return SimpleCondition{}
	}
}
func SQLCond(condition string, binds ...interface{}) SQLCondition {
	return SQLCondition{condition, binds}
}
type InCondition struct {
	NotIn bool
	Left  string
	Right []interface{}
}
func In(col string, values ...interface{}) InCondition {
	return InCondition{false, col, values}
}
func NotIn(col string, values ...interface{}) InCondition {
	return InCondition{true, col, values}
}
type ArrayCondition struct {
	Left     interface{}
	Operator string
	Type     string
	Right    interface{}
}
func Any(arr interface{}, value interface{}) ArrayCondition {
	return ArrayCondition{arr, "=", "ANY", value}
}
func EqAny(arr interface{}, value interface{}) ArrayCondition {
	return ArrayCondition{value, "=", "ANY", arr}
}
func NeAny(arr interface{}, value interface{}) ArrayCondition {
	return ArrayCondition{value, "<>", "ANY", arr}
}
func LtAny(arr interface{}, value interface{}) ArrayCondition {
	return ArrayCondition{value, "<", "ANY", arr}
}
func LteAny(arr interface{}, value interface{}) ArrayCondition {
	return ArrayCondition{value, "<=", "ANY", arr}
}