builder

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ColOf

func ColOf(model any, fieldPtr any) string

Keep your pointer-based resolver if you have it.

func MarshalClause

func MarshalClause(c Clause) string

func NormalizeClauseSQL

func NormalizeClauseSQL(sql string, qualifiers ...ClauseQualifier) string

func StripStorageBucketFilter

func StripStorageBucketFilter(sql string, bucketName string) string

StripStorageBucketFilter removes the default bucket filter from a raw clause so that generator routines can rebuild it using StorageUsingClause or StorageCheckClause.

func TableFromModel

func TableFromModel(model any) (schema, table string)

Types

type Clause

type Clause string // boolean expression fragment
var (
	True  Clause = "TRUE"
	False Clause = "FALSE"
)

func And

func And(cs ...Clause) Clause

func ArrayContainedBy

func ArrayContainedBy(col string, arr Exp) Clause

func ArrayContains

func ArrayContains(col string, arr Exp) Clause

func ArrayOverlaps

func ArrayOverlaps(col string, arr Exp) Clause

func Between

func Between(col string, low, high Exp) Clause

func ContainsText

func ContainsText(col, needle string) Clause

func EndsWith

func EndsWith(col, suffix string) Clause

func Eq

func Eq(col string, rhs Exp) Clause

func EqAll

func EqAll(col string, arr Exp) Clause

func EqAny

func EqAny(col string, arr Exp) Clause

func EqS deprecated

func EqS(col, s string) Clause

Deprecated: use EqString.

func EqString

func EqString(col, s string) Clause

Readable sugar for Eq(col, String(s)).

func Exists

func Exists(rawSelectSQL string) Clause

func ExistsFrom

func ExistsFrom(table string, joinCond Clause, extra ...Clause) Clause

Common pattern: EXISTS (SELECT 1 FROM schema.table t WHERE joinCond AND extra...)

func Ge

func Ge(col string, rhs Exp) Clause

func Gt

func Gt(col string, rhs Exp) Clause

func ILike

func ILike(col, pattern string) Clause

func IRegex

func IRegex(col, re string) Clause

func If

func If(cond bool, c Clause) Clause

Optional clause builders (include only when condition is true / value not empty)

func IfString

func IfString(notEmpty string, f func(string) Clause) Clause

func In

func In(col string, items ...Exp) Clause

IN / NOT IN

func InOrg

func InOrg(col string) Clause

multi-tenant: org_id match from claim (string)

func InS deprecated

func InS(col string, values ...string) Clause

Deprecated: use InStrings.

func InStrings

func InStrings(col string, values ...string) Clause

func IsDistinctFrom

func IsDistinctFrom(col string, rhs Exp) Clause

func IsFalse

func IsFalse(col string) Clause

func IsNotDistinctFrom

func IsNotDistinctFrom(col string, rhs Exp) Clause

func IsNull

func IsNull(col string) Clause

func IsTrue

func IsTrue(col string) Clause

func JSONContains

func JSONContains(col string, json Exp) Clause

func JSONHasAllKeys

func JSONHasAllKeys(col string, keys ...string) Clause

func JSONHasAnyKeys

func JSONHasAnyKeys(col string, keys ...string) Clause

func JSONHasKey

func JSONHasKey(col, key string) Clause

func Le

func Le(col string, rhs Exp) Clause

func Like

func Like(col, pattern string) Clause

func Lt

func Lt(col string, rhs Exp) Clause

func Ne

func Ne(col string, rhs Exp) Clause

func Not

func Not(c Clause) Clause

Logical composition

func NotBetween

func NotBetween(col string, low, high Exp) Clause

func NotExists

func NotExists(rawSelectSQL string) Clause

func NotILike

func NotILike(col, pattern string) Clause

func NotIn

func NotIn(col string, items ...Exp) Clause

func NotLike

func NotLike(col, pattern string) Clause

func NotNull

func NotNull(col string) Clause

func Or

func Or(cs ...Clause) Clause

func OwnerIsAuth

func OwnerIsAuth(col string) Clause

func RangeContainedBy

func RangeContainedBy(col string, rhs Exp) Clause

func RangeContains

func RangeContains(col string, rhs Exp) Clause

func RangeOverlaps

func RangeOverlaps(col string, rhs Exp) Clause

func Regex

func Regex(col, re string) Clause

func RoleIs

func RoleIs(role string) Clause

token has single role match OR role in roles[]

func RolesAny

func RolesAny(roles ...string) Clause
func Search(col, q, config string) Clause

func StartsWith

func StartsWith(col, prefix string) Clause

func StorageBucketClause

func StorageBucketClause(bucketName string) Clause

StorageBucketClause returns the canonical bucket scope clause for Supabase storage policies.

func StorageCheckClause

func StorageCheckClause(bucketName string, clause Clause) Clause

StorageCheckClause ensures the storage policy CHECK clause is scoped to the bucket. Additional constraints are AND-ed to the required bucket filter, preserving pre-existing filters.

func StorageUsingClause

func StorageUsingClause(bucketName string, clause Clause) Clause

StorageUsingClause ensures the storage policy USING clause is scoped to the bucket. Additional constraints are AND-ed to the required bucket filter, preserving pre-existing filters.

func TenantMatch

func TenantMatch(col string, settingKey, cast string) Clause

func TsMatches

func TsMatches(vector Exp, query Exp) Clause

func UnmarshalClause

func UnmarshalClause(sql string, qualifiers ...ClauseQualifier) (Clause, string, bool)

func (Clause) IsEmpty

func (c Clause) IsEmpty() bool

func (Clause) Paren

func (c Clause) Paren() Clause

func (Clause) String

func (c Clause) String() string

type ClauseQualifier

type ClauseQualifier struct {
	Schema string
	Table  string
}

type Exp

type Exp string // RHS literal or trusted function/expression

func Array

func Array(items ...Exp) Exp

func ArrayStrings

func ArrayStrings(values ...string) Exp

func AuthUID

func AuthUID() Exp

func Bool

func Bool(b bool) Exp

func Cast

func Cast(rhs Exp, typ string) Exp

Cast applies ::type if type is a simple identifier (letters/digits/_).

func Claim

func Claim(key string) Exp

simple string claim (text)

func Coalesce

func Coalesce(args ...Exp) Exp

func CurrentSetting

func CurrentSetting(key string) Exp

func CurrentSettingAs

func CurrentSettingAs(key, typ string) Exp

CurrentSettingAs casts current_setting(key) to a given type (if safe).

func CurrentSettingCast deprecated

func CurrentSettingCast(key, cast string) Exp

Deprecated: use CurrentSettingAs.

func CurrentUser

func CurrentUser() Exp

func Date

func Date(s string) Exp

func F64 deprecated

func F64(f float64) Exp

Deprecated: use Float64.

func Float64

func Float64(f float64) Exp

Float64 formats a float using compact, lossless representation.

func Func

func Func(name string, args ...Exp) Exp

Generic function call: Func("lower", Ident("name"))

func I64 deprecated

func I64(n int64) Exp

Deprecated: use Int64.

func Ident

func Ident(name string) Exp

Use an identifier as an expression (compare column-to-column).

func Int64

func Int64(n int64) Exp

Int64 formats a signed 64-bit integer literal.

func Interval

func Interval(s string) Exp

func JSONB

func JSONB(s string) Exp

func JSONGet

func JSONGet(col, key string) Exp

func JSONGetText

func JSONGetText(col, key string) Exp

func JSONPath

func JSONPath(col string, path ...string) Exp

func JSONPathText

func JSONPathText(col string, path ...string) Exp

func Now

func Now() Exp

func NullIf

func NullIf(a, b Exp) Exp

func Raw

func Raw(s string) Exp

Raw allows trusted fragments (avoid passing user input here).

func S deprecated

func S(s string) Exp

Deprecated: use String.

func SessionUser

func SessionUser() Exp

func String

func String(s string) Exp

String quotes a Go string as a SQL literal ('...'), escaping internal quotes.

func Timestamp

func Timestamp(s string) Exp

func Timestamptz

func Timestamptz(s string) Exp

func TsVector

func TsVector(doc Exp, config ...string) Exp

func UUID

func UUID(s string) Exp

UUID casts a string literal to uuid safely.

func UUIDLit deprecated

func UUIDLit(s string) Exp

Deprecated: use UUID.

func Val deprecated

func Val(s string) Exp

Deprecated: use String.

func WebSearchQuery

func WebSearchQuery(q string, config ...string) Exp

func (Exp) String

func (e Exp) String() string

Jump to

Keyboard shortcuts

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