dbutils

package
v0.0.0-...-47b9678 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HasSingleColumnUniqueIndex

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

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

func JsonArrayLength

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

func JsonEach(column string) string

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

func JsonExtract

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 {
	Unique     bool          `json:"unique"`
	Optional   bool          `json:"optional"`
	SchemaName string        `json:"schemaName"`
	IndexName  string        `json:"indexName"`
	TableName  string        `json:"tableName"`
	Columns    []IndexColumn `json:"columns"`
	Where      string        `json:"where"`
}

Index represents a single parsed SQL CREATE INDEX expression.

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