dbutils

package
v1.5.26 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AliasOrIdentifier added in v0.29.4

func AliasOrIdentifier(columnOrTableIdentifier string) string

AliasOrIdentifier returns the alias from a column or table identifier. Returns the identifier unmodified if no alias was found.

func HasSingleColumnUniqueIndex deprecated

func HasSingleColumnUniqueIndex(column string, indexes []string) bool

Deprecated: Use `_, ok := FindSingleColumnUniqueIndex(indexes, column)` instead.

HasColumnUniqueIndex loosely checks whether the specified column has a single column unique index (WHERE statements are ignored).

func JSONArrayLength

func JSONArrayLength(d dialect.Dialect, column string) string

JSONArrayLength counts the elements of the column. An empty or null column is 0.

func JSONEach

func JSONEach(d dialect.Dialect, column string) string

JSONEach is a relation with one row per element of the column, in a column named value.

func JSONExtract

func JSONExtract(d dialect.Dialect, column string, path string) string

JSONExtract reads path out of the column as text. The path is relative to the value: "a.b", "[0]" or "" for the value itself.

Types

type Index

type Index struct {
	SchemaName string        `json:"schemaName"`
	IndexName  string        `json:"indexName"`
	TableName  string        `json:"tableName"`
	Where      string        `json:"where"`
	Columns    []IndexColumn `json:"columns"`
	Unique     bool          `json:"unique"`
	Optional   bool          `json:"optional"`
}

Index represents a single parsed SQL CREATE INDEX expression.

func FindSingleColumnUniqueIndex

func FindSingleColumnUniqueIndex(indexes []string, column string) (Index, bool)

FindSingleColumnUniqueIndex returns the first matching single column unique index.

func ParseIndex

func ParseIndex(createIndexExpr string) Index

ParseIndex parses the provided "CREATE INDEX" SQL string into Index struct.

func (Index) Build

func (idx Index) Build(d dialect.Dialect) string

Build returns a "CREATE INDEX" SQL string from the current index parts.

Returns empty string if idx.IsValid() is false.

func (Index) IsValid

func (idx Index) IsValid() bool

IsValid checks if the current Index contains the minimum required fields to be considered valid.

type IndexColumn

type IndexColumn struct {
	Name    string `json:"name"` // identifier or expression
	Collate string `json:"collate"`
	Sort    string `json:"sort"`
}

IndexColumn represents a single parsed SQL index column.

Jump to

Keyboard shortcuts

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