func (stmt *SelectStmt) InnerLateralJoin(rs *SelectStmt, as string, conds ...WhereCondition) *SelectStmt {
	return stmt.Join(InnerLateralJoin, as, rs, conds...)
}
InnerLateralJoin is a wrapper of Join for creating a INNER LATERAL JOIN on a
table with the provided conditions
package sqlz
import (
	"context"
	"fmt"
	"strings"
	"github.com/jmoiron/sqlx"
)
type JoinType string
const (
	InnerJoin        JoinType = "INNER JOIN"
	LeftJoin         JoinType = "LEFT JOIN"
	RightJoin        JoinType = "RIGHT JOIN"
	FullJoin                  = "FULL JOIN"
	InnerLateralJoin          = "INNER JOIN LATERAL"
	LeftLateralJoin           = "LEFT JOIN LATERAL"
	RightLateralJoin          = "RIGHT JOIN LATERAL"
)
func (j JoinType) String() string {
	return string(j)
}
func (j JoinType) IsLateral() bool {
	return j == InnerLateralJoin || j == LeftLateralJoin || j == RightLateralJoin
}
type SelectStmt struct {
	Table           string
	LimitTo         int64
	OffsetFrom      int64
	OffsetRows      int64
	IsDistinct      bool
	IsUnionAll      bool
	orderWithNulls  orderWithNulls
	queryer         Queryer
	DistinctColumns []string
	Columns         []string
	Joins           []JoinClause
	Conditions      []WhereCondition
	Ordering        []SQLStmt
	Grouping        []string
	GroupConditions []WhereCondition
	Unions          []*SelectStmt
	Locks           []*LockClause
	*Statement
}
type JoinClause struct {
	Type       JoinType
	Table      string
	ResultSet  *SelectStmt
	Conditions []WhereCondition
}
type LockClause struct {
	Strength LockStrength
	Wait     LockWait
	Tables   []string
}
func (lock *LockClause) NoWait() *LockClause {
	lock.Wait = LockNoWait
	return lock
}
func (lock *LockClause) SkipLocked() *LockClause {
	lock.Wait = LockSkipLocked
	return lock
}
func (lock *LockClause) OfTables(tables ...string) *LockClause {
	lock.Tables = append(lock.Tables, tables...)
	return lock
}
type LockStrength int8
const (
	LockForUpdate LockStrength = iota
	LockForNoKeyUpdate
	LockForShare
	LockForKeyShare
)
type LockWait int8
const (
	LockDefault LockWait = iota
	LockNoWait
	LockSkipLocked
)
type OrderColumn struct {
	Column string
	Desc   bool
}
type orderWithNulls struct {
	Enabled bool
	First   bool
}
func (o OrderColumn) ToSQL(_ bool) (string, []interface{}) {
	str := o.Column
	if o.Desc {
		str += " DESC"
	} else {
		str += " ASC"
	}
	return str, nil
}
func Asc(col string) OrderColumn {
	return OrderColumn{col, false}
}
func Desc(col string) OrderColumn {
	return OrderColumn{col, true}
}
func (db *DB) Select(cols ...string) *SelectStmt {
	return &SelectStmt{
		Columns:   append([]string{}, cols...),
		queryer:   db.DB,
		Statement: &Statement{db.ErrHandlers},
	}
}
func (tx *Tx) Select(cols ...string) *SelectStmt {
	return &SelectStmt{
		Columns:   append([]string{}, cols...),
		queryer:   tx.Tx,
		Statement: &Statement{tx.ErrHandlers},
	}
}
func (stmt *SelectStmt) Distinct(cols ...string) *SelectStmt {
	stmt.DistinctColumns = append([]string{}, cols...)
	stmt.IsDistinct = true
	return stmt
}
func (stmt *SelectStmt) From(table string) *SelectStmt {
	stmt.Table = table
	return stmt
}
func (stmt *SelectStmt) Join(
	joinType JoinType,
	table string,
	resultSet *SelectStmt,
	conds ...WhereCondition,
) *SelectStmt {
	stmt.Joins = append(stmt.Joins, JoinClause{
		Type:       joinType,
		Table:      table,
		ResultSet:  resultSet,
		Conditions: append([]WhereCondition{}, conds...),
	})
	return stmt
}
func (stmt *SelectStmt) LeftJoin(table string, conds ...WhereCondition) *SelectStmt {
	return stmt.Join(LeftJoin, table, nil, conds...)
}
func (stmt *SelectStmt) RightJoin(table string, conds ...WhereCondition) *SelectStmt {
	return stmt.Join(RightJoin, table, nil, conds...)
}
func (stmt *SelectStmt) InnerJoin(table string, conds ...WhereCondition) *SelectStmt {
	return stmt.Join(InnerJoin, table, nil, conds...)
}
func (stmt *SelectStmt) FullJoin(table string, conds ...WhereCondition) *SelectStmt {
	return stmt.Join(FullJoin, table, nil, conds...)
}
func (stmt *SelectStmt) LeftJoinRS(rs *SelectStmt, as string, conds ...WhereCondition) *SelectStmt {
	return stmt.Join(LeftJoin, as, rs, conds...)
}
func (stmt *SelectStmt) RightJoinRS(rs *SelectStmt, as string, conds ...WhereCondition) *SelectStmt {
	return stmt.Join(RightJoin, as, rs, conds...)
}
func (stmt *SelectStmt) InnerJoinRS(rs *SelectStmt, as string, conds ...WhereCondition) *SelectStmt {
	return stmt.Join(InnerJoin, as, rs, conds...)
}
func (stmt *SelectStmt) FullJoinRS(rs *SelectStmt, as string, conds ...WhereCondition) *SelectStmt {
	return stmt.Join(FullJoin, as, rs, conds...)
}
func (stmt *SelectStmt) LeftLateralJoin(rs *SelectStmt, as string, conds ...WhereCondition) *SelectStmt {
	return stmt.Join(LeftLateralJoin, as, rs, conds...)
}
func (stmt *SelectStmt) RightLateralJoin(rs *SelectStmt, as string, conds ...WhereCondition) *SelectStmt {
	return stmt.Join(RightLateralJoin, as, rs, conds...)
}