Documentation
¶
Index ¶
- func HasSingleColumnUniqueIndex(column string, indexes []string) booldeprecated
- func JSONArrayLength(column string) string
- func JSONEach(column string) string
- func JSONEachByPlaceholder(placeholder string) string
- func JSONExtract(column string, path string) string
- func JsonArrayExistsStr(column string, strValue string) dbx.Expression
- type Index
- type IndexColumn
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HasSingleColumnUniqueIndex
deprecated
func JSONArrayLength ¶
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 ¶
JSONEach returns JSON_EACH SQLite string expression with some normalizations for non-json columns.
func JSONEachByPlaceholder ¶
JSONEachByPlaceholder expands a given user input json array to multiple rows. Use JSONEach if you want to expand a column value instead. The [placeholder] is the parameter placeholder in SQL prepared statements. We assume the parameter value is a marshalled JSON array.
func JSONExtract ¶
JSONExtract returns a JSON_EXTRACT SQLite string expression with some normalizations for non-json columns.
func JsonArrayExistsStr ¶
func JsonArrayExistsStr(column string, strValue string) dbx.Expression
JsonArrayExistsStr is used to determine whether a JSON string array contains a string element. Right now it only used to determine whether a JSON string ID array contains a specific ID. Operation "?" definition: Does the string exist as a top-level key within the JSON value? The type of the key is only supported to be string. If we want to support other types, we may need to use `@>` operator instead.
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 ¶
FindSingleColumnUniqueIndex returns the first matching single column unique index.
func ParseIndex ¶
ParseIndex parses the provided "CREATE INDEX" SQL string into Index struct.
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.