dbutils

package
v0.25.2 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2025 License: MIT Imports: 4 Imported by: 50

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HasSingleColumnUniqueIndex deprecated added in v0.22.0

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 added in v0.23.0

func JSONArrayLength(column string) string

JSONArrayLength returns JSON_ARRAY_LENGTH SQLite string expression with some normalizations for non-json columns.

It works with both json and non-json column values.

Returns 0 for empty string or NULL column values.

func JSONEach added in v0.23.0

func JSONEach(column string) string

JSONEach returns JSON_EACH SQLite string expression with some normalizations for non-json columns.

func JSONExtract added in v0.23.0

func JSONExtract(column string, path string) string

JSONExtract returns a JSON_EXTRACT SQLite string expression with some normalizations for non-json columns.

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 added in v0.25.0

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() 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