field

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bool

type Bool struct {
	// contains filtered or unexported fields
}

Bool represents a boolean field for building SQL queries.

func (Bool) Asc

func (b Bool) Asc() clause.OrderByColumn

Asc creates an ascending order expression for ORDER BY clauses.

func (Bool) Column

func (b Bool) Column() clause.Column

Column returns the underlying column for this field

func (Bool) ColumnName

func (b Bool) ColumnName() string

ColumnName implements the clause.Columnar interface

func (Bool) Desc

func (b Bool) Desc() clause.OrderByColumn

Desc creates a descending order expression for ORDER BY clauses.

func (Bool) Eq

func (b Bool) Eq(value bool) clause.Expression

Eq creates an equality comparison expression (field = value).

func (Bool) InExpr added in v0.2.0

func (b Bool) InExpr(expr clause.Expression) clause.Expression

InExpr creates an IN expression with a subquery (field IN (SELECT ...)).

func (Bool) IsFalse

func (b Bool) IsFalse() clause.Expression

IsFalse creates a FALSE check expression (field = FALSE).

func (Bool) IsNotNull

func (b Bool) IsNotNull() clause.Expression

IsNotNull creates a NOT NULL check expression (field IS NOT NULL).

func (Bool) IsNull

func (b Bool) IsNull() clause.Expression

IsNull creates a NULL check expression (field IS NULL).

func (Bool) IsTrue

func (b Bool) IsTrue() clause.Expression

IsTrue creates a TRUE check expression (field = TRUE).

func (Bool) Neq

func (b Bool) Neq(value bool) clause.Expression

Neq creates a not equal comparison expression (field != value).

func (Bool) NotInExpr added in v0.2.0

func (b Bool) NotInExpr(expr clause.Expression) clause.Expression

NotInExpr creates a NOT IN expression with a subquery (field NOT IN (SELECT ...)).

func (Bool) Set

func (b Bool) Set(val bool) clause.Assignment

Set creates an assignment expression for UPDATE operations (field = value).

func (Bool) WithColumn

func (b Bool) WithColumn(name string) Bool

WithColumn creates a new Bool field with the specified column name.

func (Bool) WithTable

func (b Bool) WithTable(name string) Bool

WithTable creates a new Bool field with the specified table name.

type Bytes

type Bytes struct {
	// contains filtered or unexported fields
}

Bytes represents a binary data field (BLOB/BYTEA) for building SQL queries.

func (Bytes) Column

func (b Bytes) Column() clause.Column

Column returns the underlying column for this field

func (Bytes) ColumnName

func (b Bytes) ColumnName() string

ColumnName implements the clause.Columnar interface

func (Bytes) Eq

func (b Bytes) Eq(value []byte) clause.Expression

Eq creates an equality comparison expression (field = value).

func (Bytes) InExpr added in v0.2.0

func (b Bytes) InExpr(expr clause.Expression) clause.Expression

InExpr creates an IN expression with a subquery (field IN (SELECT ...)).

func (Bytes) IsNotNull

func (b Bytes) IsNotNull() clause.Expression

IsNotNull creates a NOT NULL check expression (field IS NOT NULL).

func (Bytes) IsNull

func (b Bytes) IsNull() clause.Expression

IsNull creates a NULL check expression (field IS NULL).

func (Bytes) Neq

func (b Bytes) Neq(value []byte) clause.Expression

Neq creates a not equal comparison expression (field != value).

func (Bytes) NotInExpr added in v0.2.0

func (b Bytes) NotInExpr(expr clause.Expression) clause.Expression

NotInExpr creates a NOT IN expression with a subquery (field NOT IN (SELECT ...)).

func (Bytes) Set

func (b Bytes) Set(val []byte) clause.Assignment

Set creates an assignment expression for UPDATE operations (field = value).

func (Bytes) WithColumn

func (b Bytes) WithColumn(name string) Bytes

WithColumn creates a new Bytes field with the specified column name.

func (Bytes) WithTable

func (b Bytes) WithTable(name string) Bytes

WithTable creates a new Bytes field with the specified table name.

type Field

type Field[T any] struct {
	// contains filtered or unexported fields
}

Field represents a generic field for any type. Use this for types that don't have a specific field type.

func (Field[T]) Asc

func (f Field[T]) Asc() clause.OrderByColumn

Asc creates an ascending order expression for ORDER BY clauses.

func (Field[T]) Column

func (f Field[T]) Column() clause.Column

Column returns the underlying column for this field

func (Field[T]) ColumnName

func (f Field[T]) ColumnName() string

ColumnName implements the clause.Columnar interface

func (Field[T]) Desc

func (f Field[T]) Desc() clause.OrderByColumn

Desc creates a descending order expression for ORDER BY clauses.

func (Field[T]) Eq

func (f Field[T]) Eq(value T) clause.Expression

Eq creates an equality comparison expression (field = value).

func (Field[T]) In

func (f Field[T]) In(values ...T) clause.Expression

In creates an IN comparison expression (field IN (values...)).

func (Field[T]) IsNotNull

func (f Field[T]) IsNotNull() clause.Expression

IsNotNull creates a NOT NULL check expression (field IS NOT NULL).

func (Field[T]) IsNull

func (f Field[T]) IsNull() clause.Expression

IsNull creates a NULL check expression (field IS NULL).

func (Field[T]) Neq

func (f Field[T]) Neq(value T) clause.Expression

Neq creates a not equal comparison expression (field != value).

func (Field[T]) NotIn

func (f Field[T]) NotIn(values ...T) clause.Expression

NotIn creates a NOT IN comparison expression (field NOT IN (values...)).

func (Field[T]) Set

func (f Field[T]) Set(val T) clause.Assignment

Set creates an assignment expression for UPDATE operations (field = value).

func (Field[T]) WithColumn

func (f Field[T]) WithColumn(name string) Field[T]

WithColumn creates a new Field with the specified column name.

func (Field[T]) WithTable

func (f Field[T]) WithTable(name string) Field[T]

WithTable creates a new Field with the specified table name.

type JSON

type JSON[T any] struct {
	// contains filtered or unexported fields
}

JSON represents a JSON field for building SQL queries. It supports any type that implements json.Marshaler/Unmarshaler indirectly.

func (JSON[T]) Column

func (j JSON[T]) Column() clause.Column

Column returns the underlying column for this field

func (JSON[T]) ColumnName

func (j JSON[T]) ColumnName() string

ColumnName implements the clause.Columnar interface

func (JSON[T]) IsNotNull

func (j JSON[T]) IsNotNull() clause.Expression

IsNotNull creates a NOT NULL check expression (field IS NOT NULL).

func (JSON[T]) IsNull

func (j JSON[T]) IsNull() clause.Expression

IsNull creates a NULL check expression (field IS NULL).

func (JSON[T]) MergePatch

func (j JSON[T]) MergePatch(value any) clause.Assignment

MergePatch creates a merge patch assignment (RFC 7396). Merges the given JSON object into the existing column value.

func (JSON[T]) MergePreserve

func (j JSON[T]) MergePreserve(value any) clause.Assignment

MergePreserve creates a merge preserve assignment (Legacy/Concat). Merges values, preserving arrays (concatenating) where supported.

func (JSON[T]) Path

func (j JSON[T]) Path(path string) JSONPathBuilder

Path returns a JSONPathBuilder for operating on a specific JSON path. Use .With(dialect) to get dialect-specific operations.

Example:

field.Metadata.Path("$.name").With(json.MySQL).Eq("alice")
field.Metadata.Path("name").With(json.Postgres).Eq("alice")

func (JSON[T]) PathEq

func (j JSON[T]) PathEq(path string, value any) clause.Expression

PathEq creates an equality expression for this JSON path using the default dialect. For explicit dialect control, use Path("...").With(dialect).Eq(value).

func (JSON[T]) RawSet

func (j JSON[T]) RawSet(val any) clause.Assignment

RawSet allows setting raw JSON string/bytes directly if needed

func (JSON[T]) RemoveBuilder

func (j JSON[T]) RemoveBuilder(dialect jsonpkg.JSONDialect) *jsonpkg.JSONRemoveBuilder

RemoveBuilder returns a JSONRemoveBuilder for constructing multi-path REMOVE expressions.

Example:

builder := field.Metadata.RemoveBuilder(json.MySQL).
    Path("$.temp").
    Path("$.cache")
repo.UpdateColumns(ctx, id, builder.Assignment(field.Metadata.Column()))

func (JSON[T]) RemovePath

func (j JSON[T]) RemovePath(path string) clause.Assignment

RemovePath creates an assignment expression for removing a JSON path using the default dialect.

func (JSON[T]) Set

func (j JSON[T]) Set(val T) clause.Assignment

Set creates an assignment expression with JSON marshaling.

func (JSON[T]) SetBuilder

func (j JSON[T]) SetBuilder(dialect jsonpkg.JSONDialect) *jsonpkg.JSONSetBuilder

SetBuilder returns a JSONSetBuilder for constructing multi-path SET expressions. Use with a dialect: .SetBuilder(json.MySQL).Path(...).Path(...).Assignment(col)

Example:

builder := field.Metadata.SetBuilder(json.MySQL).
    Path("$.name", "alice").
    Path("$.age", 25)
repo.UpdateColumns(ctx, id, builder.Assignment(field.Metadata.Column()))

func (JSON[T]) SetPath

func (j JSON[T]) SetPath(path string, value any) clause.Assignment

SetPath creates an assignment expression for setting a JSON path using the default dialect.

func (JSON[T]) SetPaths

func (j JSON[T]) SetPaths(args ...jsonpkg.PathValue) clause.Assignment

SetPaths creates an assignment expression for setting multiple JSON paths using the default dialect. It simplifies using SetBuilder by accepting PathValue pairs directly.

Example:

repo.UpdateColumns(ctx, id, field.Metadata.SetPaths(
    generated.UserMetadata.Name.Arg("Alice"),
    generated.UserMetadata.Age.Arg(30),
))

func (JSON[T]) WithColumn

func (j JSON[T]) WithColumn(name string) JSON[T]

WithColumn creates a new JSON field with the specified column name.

func (JSON[T]) WithTable

func (j JSON[T]) WithTable(name string) JSON[T]

WithTable creates a new JSON field with the specified table name.

type JSONPathBuilder

type JSONPathBuilder struct {
	// contains filtered or unexported fields
}

JSONPathBuilder holds a JSON column and path for dialect-aware operations.

func (JSONPathBuilder) With

With returns JSONPathOps configured with the specified dialect.

type Number

type Number[T constraints.Integer | constraints.Float] struct {
	// contains filtered or unexported fields
}

Number represents a numeric field that supports both integer and float types. It provides type-safe operations for building SQL queries.

func (Number[T]) Asc

func (n Number[T]) Asc() clause.OrderByColumn

Asc creates an ascending order expression for ORDER BY clauses.

func (Number[T]) Between

func (n Number[T]) Between(v1, v2 T) clause.Expression

Between creates a range comparison expression (field BETWEEN v1 AND v2).

func (Number[T]) Column

func (n Number[T]) Column() clause.Column

Column returns the underlying column for this field

func (Number[T]) ColumnName

func (n Number[T]) ColumnName() string

ColumnName implements the clause.Columnar interface

func (Number[T]) Desc

func (n Number[T]) Desc() clause.OrderByColumn

Desc creates a descending order expression for ORDER BY clauses.

func (Number[T]) Eq

func (n Number[T]) Eq(value T) clause.Expression

Eq creates an equality comparison expression (field = value).

func (Number[T]) Gt

func (n Number[T]) Gt(value T) clause.Expression

Gt creates a greater than comparison expression (field > value).

func (Number[T]) Gte

func (n Number[T]) Gte(value T) clause.Expression

Gte creates a greater than or equal comparison expression (field >= value).

func (Number[T]) In

func (n Number[T]) In(values ...T) clause.Expression

In creates an IN comparison expression (field IN (values...)).

func (Number[T]) InExpr added in v0.2.0

func (n Number[T]) InExpr(expr clause.Expression) clause.Expression

InExpr creates an IN expression with a subquery (field IN (SELECT ...)).

func (Number[T]) IsNotNull

func (n Number[T]) IsNotNull() clause.Expression

IsNotNull creates a NOT NULL check expression (field IS NOT NULL).

func (Number[T]) IsNull

func (n Number[T]) IsNull() clause.Expression

IsNull creates a NULL check expression (field IS NULL).

func (Number[T]) Lt

func (n Number[T]) Lt(value T) clause.Expression

Lt creates a less than comparison expression (field < value).

func (Number[T]) Lte

func (n Number[T]) Lte(value T) clause.Expression

Lte creates a less than or equal comparison expression (field <= value).

func (Number[T]) Neq

func (n Number[T]) Neq(value T) clause.Expression

Neq creates a not equal comparison expression (field != value).

func (Number[T]) NotIn

func (n Number[T]) NotIn(values ...T) clause.Expression

NotIn creates a NOT IN comparison expression (field NOT IN (values...)).

func (Number[T]) NotInExpr added in v0.2.0

func (n Number[T]) NotInExpr(expr clause.Expression) clause.Expression

NotInExpr creates a NOT IN expression with a subquery (field NOT IN (SELECT ...)).

func (Number[T]) Set

func (n Number[T]) Set(val T) clause.Assignment

Set creates an assignment expression for UPDATE operations (field = value).

func (Number[T]) WithColumn

func (n Number[T]) WithColumn(name string) Number[T]

WithColumn creates a new Number field with the specified column name.

func (Number[T]) WithTable

func (n Number[T]) WithTable(name string) Number[T]

WithTable creates a new Number field with the specified table name.

type String

type String struct {
	// contains filtered or unexported fields
}

String represents a string field for building SQL queries.

func (String) Asc

func (s String) Asc() clause.OrderByColumn

Asc creates an ascending order expression for ORDER BY clauses.

func (String) Column

func (s String) Column() clause.Column

Column returns the underlying column for this field

func (String) ColumnName

func (s String) ColumnName() string

ColumnName implements the clause.Columnar interface

func (String) Desc

func (s String) Desc() clause.OrderByColumn

Desc creates a descending order expression for ORDER BY clauses.

func (String) Eq

func (s String) Eq(value string) clause.Expression

Eq creates an equality comparison expression (field = value).

func (String) In

func (s String) In(values ...string) clause.Expression

In creates an IN comparison expression (field IN (values...)).

func (String) InExpr added in v0.2.0

func (s String) InExpr(expr clause.Expression) clause.Expression

InExpr creates an IN expression with a subquery (field IN (SELECT ...)).

func (String) IsNotNull

func (s String) IsNotNull() clause.Expression

IsNotNull creates a NOT NULL check expression (field IS NOT NULL).

func (String) IsNull

func (s String) IsNull() clause.Expression

IsNull creates a NULL check expression (field IS NULL).

func (String) Like

func (s String) Like(pattern string) clause.Expression

Like creates a LIKE comparison expression (field LIKE pattern).

func (String) Neq

func (s String) Neq(value string) clause.Expression

Neq creates a not equal comparison expression (field != value).

func (String) NotIn

func (s String) NotIn(values ...string) clause.Expression

NotIn creates a NOT IN comparison expression (field NOT IN (values...)).

func (String) NotInExpr added in v0.2.0

func (s String) NotInExpr(expr clause.Expression) clause.Expression

NotInExpr creates a NOT IN expression with a subquery (field NOT IN (SELECT ...)).

func (String) NotLike

func (s String) NotLike(pattern string) clause.Expression

NotLike creates a NOT LIKE comparison expression (field NOT LIKE pattern).

func (String) Set

func (s String) Set(val string) clause.Assignment

Set creates an assignment expression for UPDATE operations (field = value).

func (String) WithColumn

func (s String) WithColumn(name string) String

WithColumn creates a new String field with the specified column name.

func (String) WithTable

func (s String) WithTable(name string) String

WithTable creates a new String field with the specified table name.

type Time

type Time struct {
	// contains filtered or unexported fields
}

Time represents a time/date field for building SQL queries.

func (Time) Asc

func (t Time) Asc() clause.OrderByColumn

Asc creates an ascending order expression for ORDER BY clauses.

func (Time) Between

func (t Time) Between(v1, v2 time.Time) clause.Expression

Between creates a range comparison expression (field BETWEEN v1 AND v2).

func (Time) Column

func (t Time) Column() clause.Column

Column returns the underlying column for this field

func (Time) ColumnName

func (t Time) ColumnName() string

ColumnName implements the clause.Columnar interface

func (Time) Desc

func (t Time) Desc() clause.OrderByColumn

Desc creates a descending order expression for ORDER BY clauses.

func (Time) Eq

func (t Time) Eq(value time.Time) clause.Expression

Eq creates an equality comparison expression (field = value).

func (Time) Gt

func (t Time) Gt(value time.Time) clause.Expression

Gt creates a greater than comparison expression (field > value).

func (Time) Gte

func (t Time) Gte(value time.Time) clause.Expression

Gte creates a greater than or equal comparison expression (field >= value).

func (Time) InExpr added in v0.2.0

func (t Time) InExpr(expr clause.Expression) clause.Expression

InExpr creates an IN expression with a subquery (field IN (SELECT ...)).

func (Time) IsNotNull

func (t Time) IsNotNull() clause.Expression

IsNotNull creates a NOT NULL check expression (field IS NOT NULL).

func (Time) IsNull

func (t Time) IsNull() clause.Expression

IsNull creates a NULL check expression (field IS NULL).

func (Time) Lt

func (t Time) Lt(value time.Time) clause.Expression

Lt creates a less than comparison expression (field < value).

func (Time) Lte

func (t Time) Lte(value time.Time) clause.Expression

Lte creates a less than or equal comparison expression (field <= value).

func (Time) Neq

func (t Time) Neq(value time.Time) clause.Expression

Neq creates a not equal comparison expression (field != value).

func (Time) NotInExpr added in v0.2.0

func (t Time) NotInExpr(expr clause.Expression) clause.Expression

NotInExpr creates a NOT IN expression with a subquery (field NOT IN (SELECT ...)).

func (Time) Set

func (t Time) Set(val time.Time) clause.Assignment

Set creates an assignment expression for UPDATE operations (field = value).

func (Time) WithColumn

func (t Time) WithColumn(name string) Time

WithColumn creates a new Time field with the specified column name.

func (Time) WithTable

func (t Time) WithTable(name string) Time

WithTable creates a new Time field with the specified table name.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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