json

package
v0.18.1 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidPath = fmt.Errorf("Invalid JSON path expression")
View Source
var ErrPathWildcard = fmt.Errorf("Path expressions may not contain the * and ** tokens")
View Source
var ErrUnsupportedJSONFunction = errors.NewKind("unsupported JSON function: %s")

ErrUnsupportedJSONFunction is returned when a unsupported JSON function is called.

View Source
var InvalidJsonArgument = errors.NewKind("invalid data type for JSON data in argument 1 to function json_value; a JSON string or JSON type is required")

Functions

func GetJSONFromWrapperOrCoercibleString added in v0.18.1

func GetJSONFromWrapperOrCoercibleString(js interface{}) (jsonData interface{}, err error)

GetJSONFromWrapperOrCoercibleString takes a valid argument for JSON functions (either a JSON wrapper type or a string) and unwraps the JSON, or coerces the string into JSON. The return value can return any type that can be stored in a JSON column, not just maps. For a complete list, see https://dev.mysql.com/doc/refman/8.3/en/json-attribute-functions.html#function_json-type

func NewJSONArray

func NewJSONArray(args ...sql.Expression) (sql.Expression, error)

NewJSONArray creates a new JSONArray function.

func NewJSONArrayAppend

func NewJSONArrayAppend(args ...sql.Expression) (sql.Expression, error)

NewJSONArrayAppend creates a new JSONArrayAppend function.

func NewJSONArrayInsert

func NewJSONArrayInsert(args ...sql.Expression) (sql.Expression, error)

NewJSONArrayInsert creates a new JSONArrayInsert function.

func NewJSONContains

func NewJSONContains(args ...sql.Expression) (sql.Expression, error)

NewJSONContains creates a new JSONContains function.

func NewJSONContainsPath

func NewJSONContainsPath(args ...sql.Expression) (sql.Expression, error)

NewJSONContainsPath creates a new JSONContainsPath function.

func NewJSONDepth

func NewJSONDepth(args ...sql.Expression) (sql.Expression, error)

NewJSONDepth creates a new JSONDepth function.

func NewJSONExtract

func NewJSONExtract(args ...sql.Expression) (sql.Expression, error)

NewJSONExtract creates a new JSONExtract UDF.

func NewJSONInsert

func NewJSONInsert(args ...sql.Expression) (sql.Expression, error)

NewJSONInsert creates a new JSONInsert function.

func NewJSONKeys

func NewJSONKeys(args ...sql.Expression) (sql.Expression, error)

NewJSONKeys creates a new JSONKeys function.

func NewJSONMergePatch

func NewJSONMergePatch(args ...sql.Expression) (sql.Expression, error)

NewJSONMergePatch creates a new JSONMergePatch function.

func NewJSONMergePreserve

func NewJSONMergePreserve(args ...sql.Expression) (sql.Expression, error)

NewJSONMergePreserve creates a new JSONMergePreserve function.

func NewJSONObject

func NewJSONObject(exprs ...sql.Expression) (sql.Expression, error)

NewJSONObject creates a new JSONObject function.

func NewJSONOverlaps

func NewJSONOverlaps(args ...sql.Expression) (sql.Expression, error)

NewJSONOverlaps creates a new JSONOverlaps function.

func NewJSONPretty

func NewJSONPretty(arg sql.Expression) sql.Expression

NewJSONPretty creates a new JSONPretty function.

func NewJSONQuote

func NewJSONQuote(json sql.Expression) sql.Expression

NewJSONQuote creates a new JSONQuote UDF.

func NewJSONRemove

func NewJSONRemove(args ...sql.Expression) (sql.Expression, error)

NewJSONRemove creates a new JSONRemove function.

func NewJSONReplace

func NewJSONReplace(args ...sql.Expression) (sql.Expression, error)

NewJSONReplace creates a new JSONReplace function.

func NewJSONSchemaValid

func NewJSONSchemaValid(args ...sql.Expression) (sql.Expression, error)

NewJSONSchemaValid creates a new JSONSchemaValid function.

func NewJSONSchemaValidationReport

func NewJSONSchemaValidationReport(args ...sql.Expression) (sql.Expression, error)

NewJSONSchemaValidationReport creates a new JSONSchemaValidationReport function.

func NewJSONSearch

func NewJSONSearch(args ...sql.Expression) (sql.Expression, error)

NewJSONSearch creates a new NewJSONSearch function.

func NewJSONSet

func NewJSONSet(args ...sql.Expression) (sql.Expression, error)

NewJSONSet creates a new JSONSet function.

func NewJSONStorageFree

func NewJSONStorageFree(args ...sql.Expression) (sql.Expression, error)

NewJSONStorageFree creates a new JSONStorageFree function.

func NewJSONStorageSize

func NewJSONStorageSize(args ...sql.Expression) (sql.Expression, error)

NewJSONStorageSize creates a new JSONStorageSize function.

func NewJSONTable

func NewJSONTable(args ...sql.Expression) (sql.Expression, error)

NewJSONTable creates a new JSONTable function.

func NewJSONType

func NewJSONType(args ...sql.Expression) (sql.Expression, error)

NewJSONType creates a new JSONType function.

func NewJSONUnquote

func NewJSONUnquote(json sql.Expression) sql.Expression

NewJSONUnquote creates a new JSONUnquote UDF.

func NewJSONValid

func NewJSONValid(args ...sql.Expression) (sql.Expression, error)

NewJSONValid creates a new JSONValid function.

func NewJsonLength

func NewJsonLength(args ...sql.Expression) (sql.Expression, error)

NewJsonLength creates a new JsonLength UDF.

func NewJsonValue

func NewJsonValue(args ...sql.Expression) (sql.Expression, error)

NewJsonValue creates a new JsonValue UDF.

Types

type JSONArray

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

func (*JSONArray) Children

func (j *JSONArray) Children() []sql.Expression

Children implements the Expression interface.

func (JSONArray) CollationCoercibility

func (JSONArray) CollationCoercibility(ctx *sql.Context) (collation sql.CollationID, coercibility byte)

CollationCoercibility implements the interface sql.CollationCoercible.

func (JSONArray) Description

func (j JSONArray) Description() string

Description implements sql.FunctionExpression

func (*JSONArray) Eval

func (j *JSONArray) Eval(ctx *sql.Context, row sql.Row) (interface{}, error)

Eval implements the Expression interface.

func (JSONArray) FunctionName

func (j JSONArray) FunctionName() string

FunctionName implements sql.FunctionExpression

func (*JSONArray) IsNullable

func (j *JSONArray) IsNullable() bool

IsNullable implements the Expression interface.

func (JSONArray) IsUnsupported

func (j JSONArray) IsUnsupported() bool

IsUnsupported implements sql.UnsupportedFunctionStub

func (*JSONArray) Resolved

func (j *JSONArray) Resolved() bool

Resolved implements the Expression interface.

func (*JSONArray) String

func (j *JSONArray) String() string

String implements the Expression interface.

func (*JSONArray) Type

func (j *JSONArray) Type() sql.Type

Type implements the Expression interface.

func (*JSONArray) WithChildren

func (j *JSONArray) WithChildren(children ...sql.Expression) (sql.Expression, error)

WithChildren implements the Expression interface.

type JSONArrayAppend

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

JSON_ARRAY_APPEND(json_doc, path, val[, path, val] ...)

JSONArrayAppend Appends values to the end of the indicated arrays within a JSON document and returns the result. Returns NULL if any argument is NULL. An error occurs if the json_doc argument is not a valid JSON document or any path argument is not a valid path expression or contains a * or ** wildcard. The path-value pairs are evaluated left to right. The document produced by evaluating one pair becomes the new value against which the next pair is evaluated. If a path selects a scalar or object value, that value is autowrapped within an array and the new value is added to that array. Pairs for which the path does not identify any value in the JSON document are ignored.

https://dev.mysql.com/doc/refman/8.0/en/json-modification-functions.html#function_json-array-append

func (JSONArrayAppend) Children

func (j JSONArrayAppend) Children() []sql.Expression

func (JSONArrayAppend) Description

func (j JSONArrayAppend) Description() string

Description implements sql.FunctionExpression

func (JSONArrayAppend) Eval

func (j JSONArrayAppend) Eval(ctx *sql.Context, row sql.Row) (interface{}, error)

func (JSONArrayAppend) FunctionName

func (j JSONArrayAppend) FunctionName() string

FunctionName implements sql.FunctionExpression

func (JSONArrayAppend) IsNullable

func (j JSONArrayAppend) IsNullable() bool

func (JSONArrayAppend) IsUnsupported

func (j JSONArrayAppend) IsUnsupported() bool

IsUnsupported implements sql.UnsupportedFunctionStub

func (JSONArrayAppend) Resolved

func (j JSONArrayAppend) Resolved() bool

func (JSONArrayAppend) String

func (j JSONArrayAppend) String() string

func (JSONArrayAppend) Type

func (j JSONArrayAppend) Type() sql.Type

func (JSONArrayAppend) WithChildren

func (j JSONArrayAppend) WithChildren(children ...sql.Expression) (sql.Expression, error)

type JSONArrayInsert

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

JSON_ARRAY_INSERT(json_doc, path, val[, path, val] ...)

JSONArrayInsert Updates a JSON document, inserting into an array within the document and returning the modified document. Returns NULL if any argument is NULL. An error occurs if the json_doc argument is not a valid JSON document or any path argument is not a valid path expression or contains a * or ** wildcard or does not end with an array element identifier. The path-value pairs are evaluated left to right. The document produced by evaluating one pair becomes the new value against which the next pair is evaluated. Pairs for which the path does not identify any array in the JSON document are ignored. If a path identifies an array element, the corresponding value is inserted at that element position, shifting any following values to the right. If a path identifies an array position past the end of an array, the value is inserted at the end of the array.

https://dev.mysql.com/doc/refman/8.0/en/json-modification-functions.html#function_json-array-insert

func (JSONArrayInsert) Children

func (j JSONArrayInsert) Children() []sql.Expression

func (JSONArrayInsert) Description

func (j JSONArrayInsert) Description() string

Description implements sql.FunctionExpression

func (JSONArrayInsert) Eval

func (j JSONArrayInsert) Eval(ctx *sql.Context, row sql.Row) (interface{}, error)

func (JSONArrayInsert) FunctionName

func (j JSONArrayInsert) FunctionName() string

FunctionName implements sql.FunctionExpression

func (JSONArrayInsert) IsNullable

func (j JSONArrayInsert) IsNullable() bool

func (JSONArrayInsert) IsUnsupported

func (j JSONArrayInsert) IsUnsupported() bool

IsUnsupported implements sql.UnsupportedFunctionStub

func (JSONArrayInsert) Resolved

func (j JSONArrayInsert) Resolved() bool

func (JSONArrayInsert) String

func (j JSONArrayInsert) String() string

func (JSONArrayInsert) Type

func (j JSONArrayInsert) Type() sql.Type

func (JSONArrayInsert) WithChildren

func (j JSONArrayInsert) WithChildren(children ...sql.Expression) (sql.Expression, error)

type JSONContains

type JSONContains struct {
	JSONTarget    sql.Expression
	JSONCandidate sql.Expression
	Path          sql.Expression
}

JSON_CONTAINS(target, candidate[, path])

JSONContains indicates by returning 1 or 0 whether a given candidate JSON document is contained within a target JSON document, or, if a path argument was supplied, whether the candidate is found at a specific path within the target. Returns NULL if any argument is NULL, or if the path argument does not identify a section of the target document. An error occurs if target or candidate is not a valid JSON document, or if the path argument is not a valid path expression or contains a * or ** wildcard. To check only whether any data exists at the path, use JSON_CONTAINS_PATH() instead.

The following rules define containment:

  • A candidate scalar is contained in a target scalar if and only if they are comparable and are equal. Two scalar values are comparable if they have the same JSON_TYPE() types, with the exception that values of types INTEGER and DECIMAL are also comparable to each other.
  • A candidate array is contained in a target array if and only if every element in the candidate is contained in some element of the target.
  • A candidate non-array is contained in a target array if and only if the candidate is contained in some element of the target.
  • A candidate object is contained in a target object if and only if for each key in the candidate there is a key with the same name in the target and the value associated with the candidate key is contained in the value associated with the target key.

Otherwise, the candidate value is not contained in the target document.

https://dev.mysql.com/doc/refman/8.0/en/json-search-functions.html#function_json-contains TODO: Add multi index optimization -> https://dev.mysql.com/doc/refman/8.0/en/create-index.html#create-index-multi-valued

func (*JSONContains) Children

func (j *JSONContains) Children() []sql.Expression

func (*JSONContains) CollationCoercibility

func (*JSONContains) CollationCoercibility(ctx *sql.Context) (collation sql.CollationID, coercibility byte)

CollationCoercibility implements the interface sql.CollationCoercible.

func (*JSONContains) Description

func (j *JSONContains) Description() string

Description implements sql.FunctionExpression

func (*JSONContains) Eval

func (j *JSONContains) Eval(ctx *sql.Context, row sql.Row) (interface{}, error)

func (*JSONContains) FunctionName

func (j *JSONContains) FunctionName() string

FunctionName implements sql.FunctionExpression

func (*JSONContains) IsNullable

func (j *JSONContains) IsNullable() bool

func (JSONContains) IsUnsupported

func (j JSONContains) IsUnsupported() bool

IsUnsupported implements sql.UnsupportedFunctionStub

func (*JSONContains) Resolved

func (j *JSONContains) Resolved() bool

func (*JSONContains) String

func (j *JSONContains) String() string

func (*JSONContains) Type

func (j *JSONContains) Type() sql.Type

func (*JSONContains) WithChildren

func (j *JSONContains) WithChildren(children ...sql.Expression) (sql.Expression, error)

type JSONContainsPath

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

JSON_CONTAINS_PATH(json_doc, one_or_all, path[, path] ...)

JSONContainsPath Returns 0 or 1 to indicate whether a JSON document contains data at a given path or paths. Returns NULL if any argument is NULL. An error occurs if the json_doc argument is not a valid JSON document, any path argument is not a valid path expression, or one_or_all is not 'one' or 'all'. To check for a specific value at a path, use JSON_CONTAINS() instead.

The return value is 0 if no specified path exists within the document. Otherwise, the return value depends on the one_or_all argument:

  • 'one': 1 if at least one path exists within the document, 0 otherwise.
  • 'all': 1 if all paths exist within the document, 0 otherwise.

https://dev.mysql.com/doc/refman/8.0/en/json-search-functions.html#function_json-contains-path

Above is the documentation from MySQL's documentation. Minor Nit - the observed behavior for NULL paths is that if a NULL path is found before the search can terminate, then NULL is returned.

func (JSONContainsPath) Children

func (j JSONContainsPath) Children() []sql.Expression

func (JSONContainsPath) Description

func (j JSONContainsPath) Description() string

Description implements sql.FunctionExpression

func (JSONContainsPath) Eval

func (j JSONContainsPath) Eval(ctx *sql.Context, row sql.Row) (interface{}, error)

func (JSONContainsPath) FunctionName

func (j JSONContainsPath) FunctionName() string

FunctionName implements sql.FunctionExpression

func (JSONContainsPath) IsNullable

func (j JSONContainsPath) IsNullable() bool

func (JSONContainsPath) IsUnsupported

func (j JSONContainsPath) IsUnsupported() bool

IsUnsupported implements sql.UnsupportedFunctionStub

func (JSONContainsPath) Resolved

func (j JSONContainsPath) Resolved() bool

func (JSONContainsPath) String

func (j JSONContainsPath) String() string

func (JSONContainsPath) Type

func (j JSONContainsPath) Type() sql.Type

func (JSONContainsPath) WithChildren

func (j JSONContainsPath) WithChildren(children ...sql.Expression) (sql.Expression, error)

type JSONDepth

type JSONDepth struct {
	JSON sql.Expression
}

JSONDepth (json_doc)

JSONDepth Returns the maximum depth of a JSON document. Returns NULL if the argument is NULL. An error occurs if the argument is not a valid JSON document. An empty array, empty object, or scalar value has depth 1. A nonempty array containing only elements of depth 1 or nonempty object containing only member values of depth 1 has depth 2. Otherwise, a JSON document has depth greater than 2.

https://dev.mysql.com/doc/refman/8.0/en/json-attribute-functions.html#function_json-depth

func (*JSONDepth) Children

func (j *JSONDepth) Children() []sql.Expression

Children implements sql.Expression interface.

func (*JSONDepth) Description

func (j *JSONDepth) Description() string

Description implements sql.FunctionExpression interface.

func (*JSONDepth) Eval

func (j *JSONDepth) Eval(ctx *sql.Context, row sql.Row) (interface{}, error)

Eval implements sql.Expression interface.

func (*JSONDepth) FunctionName

func (j *JSONDepth) FunctionName() string

FunctionName implements sql.FunctionExpression interface.

func (*JSONDepth) IsNullable

func (j *JSONDepth) IsNullable() bool

IsNullable implements sql.Expression interface.

func (*JSONDepth) Resolved

func (j *JSONDepth) Resolved() bool

Resolved implements sql.Expression interface.

func (*JSONDepth) String

func (j *JSONDepth) String() string

String implements sql.Expression interface.

func (*JSONDepth) Type

func (j *JSONDepth) Type() sql.Type

Type implements sql.Expression interface.

func (*JSONDepth) WithChildren

func (j *JSONDepth) WithChildren(children ...sql.Expression) (sql.Expression, error)

WithChildren implements sql.Expression interface.

type JSONExtract

type JSONExtract struct {
	JSON  sql.Expression
	Paths []sql.Expression
}

JSON_EXTRACT(json_doc, path[, path] ...)

JSONExtract extracts data from a json document using json paths. https://dev.mysql.com/doc/refman/8.0/en/json-search-functions.html#function_json-extract

func (*JSONExtract) Children

func (j *JSONExtract) Children() []sql.Expression

Children implements the sql.Expression interface.

func (*JSONExtract) CollationCoercibility

func (*JSONExtract) CollationCoercibility(ctx *sql.Context) (collation sql.CollationID, coercibility byte)

CollationCoercibility implements the interface sql.CollationCoercible.

func (*JSONExtract) Description

func (j *JSONExtract) Description() string

Description implements sql.FunctionExpression

func (*JSONExtract) Eval

func (j *JSONExtract) Eval(ctx *sql.Context, row sql.Row) (interface{}, error)

Eval implements the sql.Expression interface.

func (*JSONExtract) FunctionName

func (j *JSONExtract) FunctionName() string

FunctionName implements sql.FunctionExpression

func (*JSONExtract) IsNullable

func (j *JSONExtract) IsNullable() bool

IsNullable implements the sql.Expression interface.

func (JSONExtract) IsUnsupported

func (j JSONExtract) IsUnsupported() bool

IsUnsupported implements sql.UnsupportedFunctionStub

func (*JSONExtract) Resolved

func (j *JSONExtract) Resolved() bool

Resolved implements the sql.Expression interface.

func (*JSONExtract) String

func (j *JSONExtract) String() string

func (*JSONExtract) Type

func (j *JSONExtract) Type() sql.Type

Type implements the sql.Expression interface.

func (*JSONExtract) WithChildren

func (j *JSONExtract) WithChildren(children ...sql.Expression) (sql.Expression, error)

WithChildren implements the Expression interface.

type JSONInsert

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

JSON_INSERT(json_doc, path, val[, path, val] ...)

JSONInsert Inserts data into a JSON document and returns the result. Returns NULL if any argument is NULL. An error occurs if the json_doc argument is not a valid JSON document or any path argument is not a valid path expression or contains a * or ** wildcard. The path-value pairs are evaluated left to right. The document produced by evaluating one pair becomes the new value against which the next pair is evaluated. A path-value pair for an existing path in the document is ignored and does not overwrite the existing document value. A path-value pair for a nonexisting path in the document adds the value to the document if the path identifies one of these types of values:

  • A member not present in an existing object. The member is added to the object and associated with the new value.
  • A position past the end of an existing array. The array is extended with the new value. If the existing value is not an array, it is autowrapped as an array, then extended with the new value.

Otherwise, a path-value pair for a nonexisting path in the document is ignored and has no effect.

https://dev.mysql.com/doc/refman/8.0/en/json-modification-functions.html#function_json-insert

func (JSONInsert) Children

func (j JSONInsert) Children() []sql.Expression

func (JSONInsert) Description

func (j JSONInsert) Description() string

Description implements sql.FunctionExpression

func (JSONInsert) Eval

func (j JSONInsert) Eval(ctx *sql.Context, row sql.Row) (interface{}, error)

func (JSONInsert) FunctionName

func (j JSONInsert) FunctionName() string

FunctionName implements sql.FunctionExpression

func (JSONInsert) IsNullable

func (j JSONInsert) IsNullable() bool

func (JSONInsert) IsUnsupported

func (j JSONInsert) IsUnsupported() bool

IsUnsupported implements sql.UnsupportedFunctionStub

func (JSONInsert) Resolved

func (j JSONInsert) Resolved() bool

func (JSONInsert) String

func (j JSONInsert) String() string

func (JSONInsert) Type

func (j JSONInsert) Type() sql.Type

func (JSONInsert) WithChildren

func (j JSONInsert) WithChildren(children ...sql.Expression) (sql.Expression, error)

type JSONKeys

type JSONKeys struct {
	JSON sql.Expression
	Path sql.Expression
}

JSONKeys (json_doc[, path])

JSONKeys Returns the keys from the top-level value of a JSON object as a JSON array, or, if a path argument is given, the top-level keys from the selected path. Returns NULL if any argument is NULL, the json_doc argument is not an object, or path, if given, does not locate an object. An error occurs if the json_doc argument is not a valid JSON document or the path argument is not a valid path expression or contains a * or ** wildcard. The result array is empty if the selected object is empty. If the top-level value has nested subobjects, the return value does not include keys from those subobjects.

https://dev.mysql.com/doc/refman/8.0/en/json-search-functions.html#function_json-keys

func (*JSONKeys) Children

func (j *JSONKeys) Children() []sql.Expression

Children implements sql.Expression

func (*JSONKeys) Description

func (j *JSONKeys) Description() string

Description implements sql.FunctionExpression

func (*JSONKeys) Eval

func (j *JSONKeys) Eval(ctx *sql.Context, row sql.Row) (interface{}, error)

Eval implements sql.Expression

func (*JSONKeys) FunctionName

func (j *JSONKeys) FunctionName() string

FunctionName implements sql.FunctionExpression

func (*JSONKeys) IsNullable

func (j *JSONKeys) IsNullable() bool

IsNullable implements sql.Expression

func (*JSONKeys) Resolved

func (j *JSONKeys) Resolved() bool

Resolved implements sql.Expression

func (*JSONKeys) String

func (j *JSONKeys) String() string

String implements sql.Expression

func (*JSONKeys) Type

func (j *JSONKeys) Type() sql.Type

Type implements sql.Expression

func (*JSONKeys) WithChildren

func (j *JSONKeys) WithChildren(children ...sql.Expression) (sql.Expression, error)

WithChildren implements sql.Expression

type JSONMergePatch

type JSONMergePatch struct {
	JSONs []sql.Expression
}

JSONMergePatch (json_doc, json_doc[, json_doc] ...)

JSONMergePatch Performs an RFC 7396 compliant merge of two or more JSON documents and returns the merged result, without preserving members having duplicate keys. Raises an error if at least one of the documents passed as arguments to this function is not valid. JSONMergePatch performs a merge as follows:

  • If the first argument is not an object, the result of the merge is the same as if an empty object had been merged with the second argument.
  • If the second argument is not an object, the result of the merge is the second argument.
  • If both arguments are objects, the result of the merge is an object with the following members:
  • All members of the first object which do not have a corresponding member with the same key in the second object.
  • All members of the second object which do not have a corresponding key in the first object, and whose value is not the JSON null literal.
  • All members with a key that exists in both the first and the second object, and whose value in the second object is not the JSON null literal. The values of these members are the results of recursively merging the value in the first object with the value in the second object.

The behavior of JSONMergePatch is the same as that of JSONMergePreserve, with the following two exceptions:

  • JSONMergePatch removes any member in the first object with a matching key in the second object, provided that the value associated with the key in the second object is not JSON null.
  • If the second object has a member with a key matching a member in the first object, JSONMergePatch replaces the value in the first object with the value in the second object, whereas JSONMergePreserve appends the second value to the first value.

https://dev.mysql.com/doc/refman/8.0/en/json-modification-functions.html#function_json-merge-patch

func (*JSONMergePatch) Children added in v0.18.1

func (j *JSONMergePatch) Children() []sql.Expression

Children implements the Expression interface.

func (*JSONMergePatch) Description

func (j *JSONMergePatch) Description() string

Description implements sql.FunctionExpression

func (*JSONMergePatch) Eval added in v0.18.1

func (j *JSONMergePatch) Eval(ctx *sql.Context, row sql.Row) (interface{}, error)

Eval implements the Expression interface.

func (*JSONMergePatch) FunctionName

func (j *JSONMergePatch) FunctionName() string

FunctionName implements sql.FunctionExpression

func (*JSONMergePatch) IsNullable added in v0.18.1

func (j *JSONMergePatch) IsNullable() bool

IsNullable implements the Expression interface.

func (*JSONMergePatch) Resolved added in v0.18.1

func (j *JSONMergePatch) Resolved() bool

Resolved implements sql.Expression

func (*JSONMergePatch) String added in v0.18.1

func (j *JSONMergePatch) String() string

String implements sql.Expression

func (*JSONMergePatch) Type added in v0.18.1

func (j *JSONMergePatch) Type() sql.Type

Type implements the Expression interface.

func (*JSONMergePatch) WithChildren added in v0.18.1

func (j *JSONMergePatch) WithChildren(children ...sql.Expression) (sql.Expression, error)

WithChildren implements the Expression interface.

type JSONMergePreserve

type JSONMergePreserve struct {
	JSONs []sql.Expression
}

JSONMergePreserve (json_doc, json_doc[, json_doc] ...)

JSONMergePreserve Merges two or more JSON documents and returns the merged result. Returns NULL if any argument is NULL. An error occurs if any argument is not a valid JSON document. Merging takes place according to the following rules:

  • Adjacent arrays are merged to a single array.
  • Adjacent objects are merged to a single object.
  • A scalar value is autowrapped as an array and merged as an array.
  • An adjacent array and object are merged by autowrapping the object as an array and merging the two arrays.

This function was added in MySQL 8.0.3 as a synonym for JSONMerge. The JSONMerge function is now deprecated, and is subject to removal in a future release of MySQL.

The behavior of JSONMergePatch is the same as that of JSONMergePreserve, with the following two exceptions:

  • JSONMergePatch removes any member in the first object with a matching key in the second object, provided that the value associated with the key in the second object is not JSON null.
  • If the second object has a member with a key matching a member in the first object, JSONMergePatch replaces the value in the first object with the value in the second object, whereas JSONMergePreserve appends the second value to the first value.

https://dev.mysql.com/doc/refman/8.0/en/json-modification-functions.html#function_json-merge-preserve

func (*JSONMergePreserve) Children

func (j *JSONMergePreserve) Children() []sql.Expression

Children implements the Expression interface.

func (*JSONMergePreserve) CollationCoercibility

func (*JSONMergePreserve) CollationCoercibility(ctx *sql.Context) (collation sql.CollationID, coercibility byte)

CollationCoercibility implements the interface sql.CollationCoercible.

func (*JSONMergePreserve) Description

func (j *JSONMergePreserve) Description() string

Description implements sql.FunctionExpression

func (*JSONMergePreserve) Eval

func (j *JSONMergePreserve) Eval(ctx *sql.Context, row sql.Row) (interface{}, error)

Eval implements the Expression interface.

func (*JSONMergePreserve) FunctionName

func (j *JSONMergePreserve) FunctionName() string

FunctionName implements sql.FunctionExpression

func (*JSONMergePreserve) IsNullable

func (j *JSONMergePreserve) IsNullable() bool

IsNullable implements the Expression interface.

func (JSONMergePreserve) IsUnsupported

func (j JSONMergePreserve) IsUnsupported() bool

IsUnsupported implements sql.UnsupportedFunctionStub

func (*JSONMergePreserve) Resolved

func (j *JSONMergePreserve) Resolved() bool

Resolved implements the Expression interface.

func (*JSONMergePreserve) String

func (j *JSONMergePreserve) String() string

String implements the Expression interface.

func (*JSONMergePreserve) Type

func (j *JSONMergePreserve) Type() sql.Type

Type implements the Expression interface.

func (*JSONMergePreserve) WithChildren

func (j *JSONMergePreserve) WithChildren(children ...sql.Expression) (sql.Expression, error)

WithChildren implements the Expression interface.

type JSONObject

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

JSONObject Evaluates a (possibly empty) list of key-value pairs and returns a JSON object containing those pairs. An error occurs if any key name is NULL or the number of arguments is odd.

func (JSONObject) Children

func (j JSONObject) Children() []sql.Expression

func (JSONObject) CollationCoercibility

func (JSONObject) CollationCoercibility(ctx *sql.Context) (collation sql.CollationID, coercibility byte)

CollationCoercibility implements the interface sql.CollationCoercible.

func (JSONObject) Description

func (j JSONObject) Description() string

Description implements sql.FunctionExpression

func (JSONObject) Eval

func (j JSONObject) Eval(ctx *sql.Context, row sql.Row) (interface{}, error)

func (JSONObject) FunctionName

func (j JSONObject) FunctionName() string

FunctionName implements sql.FunctionExpression

func (JSONObject) IsNullable

func (j JSONObject) IsNullable() bool

func (JSONObject) IsUnsupported

func (j JSONObject) IsUnsupported() bool

IsUnsupported implements sql.UnsupportedFunctionStub

func (JSONObject) Resolved

func (j JSONObject) Resolved() bool

func (JSONObject) String

func (j JSONObject) String() string

func (JSONObject) Type

func (j JSONObject) Type() sql.Type

func (JSONObject) WithChildren

func (j JSONObject) WithChildren(children ...sql.Expression) (sql.Expression, error)

type JSONOverlaps

type JSONOverlaps struct {
	Left  sql.Expression
	Right sql.Expression
}

JSONOverlaps (json_doc1, json_doc2)

JSONOverlaps Compares two JSON documents. Returns true (1) if the two document have any key-value pairs or array elements in common. If both arguments are scalars, the function performs a simple equality test.

This function serves as counterpart to JSON_CONTAINS(), which requires all elements of the array searched for to be present in the array searched in. Thus, JSON_CONTAINS() performs an AND operation on search keys, while JSON_OVERLAPS() performs an OR operation.

Queries on JSON columns of InnoDB tables using JSON_OVERLAPS() in the WHERE clause can be optimized using multi-valued indexes. Multi-Valued Indexes, provides detailed information and examples.

https://dev.mysql.com/doc/refman/8.0/en/json-search-functions.html#function_json-overlaps

func (*JSONOverlaps) Children added in v0.18.1

func (j *JSONOverlaps) Children() []sql.Expression

Children implements sql.Expression

func (*JSONOverlaps) Description

func (j *JSONOverlaps) Description() string

Description implements sql.FunctionExpression

func (*JSONOverlaps) Eval added in v0.18.1

func (j *JSONOverlaps) Eval(ctx *sql.Context, row sql.Row) (interface{}, error)

Eval implements sql.Expression

func (*JSONOverlaps) FunctionName

func (j *JSONOverlaps) FunctionName() string

FunctionName implements sql.FunctionExpression

func (*JSONOverlaps) IsNullable added in v0.18.1

func (j *JSONOverlaps) IsNullable() bool

IsNullable implements sql.Expression

func (*JSONOverlaps) Resolved added in v0.18.1

func (j *JSONOverlaps) Resolved() bool

Resolved implements sql.Expression

func (*JSONOverlaps) String added in v0.18.1

func (j *JSONOverlaps) String() string

String implements sql.Expression

func (*JSONOverlaps) Type added in v0.18.1

func (j *JSONOverlaps) Type() sql.Type

Type implements sql.Expression

func (*JSONOverlaps) WithChildren added in v0.18.1

func (j *JSONOverlaps) WithChildren(children ...sql.Expression) (sql.Expression, error)

WithChildren implements sql.Expression

type JSONPretty

type JSONPretty struct {
	expression.UnaryExpression
}

JSONPretty (json_val)

JSONPretty Provides pretty-printing of JSON values similar to that implemented in PHP and by other languages and database systems. The value supplied must be a JSON value or a valid string representation of a JSON value. Extraneous whitespaces and newlines present in this value have no effect on the output. For a NULL value, the function returns NULL. If the value is not a JSON document, or if it cannot be parsed as one, the function fails with an error. Formatting of the output from this function adheres to the following rules:

  • Each array element or object member appears on a separate line, indented by one additional level as compared to its parent.
  • Each level of indentation adds two leading spaces.
  • A comma separating individual array elements or object members is printed before the newline that separates the two elements or members.
  • The key and the value of an object member are separated by a colon followed by a space (': ').
  • An empty object or array is printed on a single line. No space is printed between the opening and closing brace.
  • Special characters in string scalars and key names are escaped employing the same rules used by JSONQuote.

https://dev.mysql.com/doc/refman/8.0/en/json-utility-functions.html#function_json-pretty

func (*JSONPretty) Description

func (j *JSONPretty) Description() string

Description implements sql.FunctionExpression

func (*JSONPretty) Eval added in v0.18.1

func (j *JSONPretty) Eval(ctx *sql.Context, row sql.Row) (interface{}, error)

Eval implements sql.Expression

func (*JSONPretty) FunctionName

func (j *JSONPretty) FunctionName() string

FunctionName implements sql.FunctionExpression

func (*JSONPretty) String added in v0.18.1

func (j *JSONPretty) String() string

String implements sql.Expression

func (*JSONPretty) Type added in v0.18.1

func (j *JSONPretty) Type() sql.Type

Type implements sql.Expression

func (*JSONPretty) WithChildren added in v0.18.1

func (j *JSONPretty) WithChildren(children ...sql.Expression) (sql.Expression, error)

WithChildren implements sql.Expression

type JSONQuote

type JSONQuote struct {
	expression.UnaryExpression
}

JSONQuote (string)

JSONQuote Quotes a string as a JSON value by wrapping it with double quote characters and escaping interior quote and other characters, then returning the result as a utf8mb4 string. Returns NULL if the argument is NULL. This function is typically used to produce a valid JSON string literal for inclusion within a JSON document. Certain special characters are escaped with backslashes per the escape sequences shown in Table 12.23, “JSON_UNQUOTE() Special Character Escape Sequences”: https://dev.mysql.com/doc/refman/8.0/en/json-modification-functions.html#json-unquote-character-escape-sequences

https://dev.mysql.com/doc/refman/8.0/en/json-creation-functions.html#function_json-quote

func (*JSONQuote) CollationCoercibility added in v0.18.1

func (*JSONQuote) CollationCoercibility(ctx *sql.Context) (collation sql.CollationID, coercibility byte)

CollationCoercibility implements the interface sql.CollationCoercible.

func (*JSONQuote) Description

func (js *JSONQuote) Description() string

Description implements sql.FunctionExpression

func (*JSONQuote) Eval added in v0.18.1

func (js *JSONQuote) Eval(ctx *sql.Context, row sql.Row) (interface{}, error)

Eval implements the Expression interface.

func (*JSONQuote) FunctionName

func (js *JSONQuote) FunctionName() string

FunctionName implements sql.FunctionExpression

func (*JSONQuote) String added in v0.18.1

func (js *JSONQuote) String() string

String implements the fmt.Stringer interface.

func (*JSONQuote) Type added in v0.18.1

func (*JSONQuote) Type() sql.Type

Type implements the Expression interface.

func (*JSONQuote) WithChildren added in v0.18.1

func (js *JSONQuote) WithChildren(children ...sql.Expression) (sql.Expression, error)

WithChildren implements the Expression interface.

type JSONRemove

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

JSON_REMOVE(json_doc, path[, path] ...)

JSONRemove Removes data from a JSON document and returns the result. Returns NULL if any argument is NULL. An error occurs if the json_doc argument is not a valid JSON document or any path argument is not a valid path expression or is $ or contains a * or ** wildcard. The path arguments are evaluated left to right. The document produced by evaluating one path becomes the new value against which the next path is evaluated. It is not an error if the element to be removed does not exist in the document; in that case, the path does not affect the document.

https://dev.mysql.com/doc/refman/8.0/en/json-modification-functions.html#function_json-remove

func (JSONRemove) Children

func (j JSONRemove) Children() []sql.Expression

func (JSONRemove) Description

func (j JSONRemove) Description() string

Description implements sql.FunctionExpression

func (JSONRemove) Eval

func (j JSONRemove) Eval(ctx *sql.Context, row sql.Row) (interface{}, error)

func (JSONRemove) FunctionName

func (j JSONRemove) FunctionName() string

FunctionName implements sql.FunctionExpression

func (JSONRemove) IsNullable

func (j JSONRemove) IsNullable() bool

func (JSONRemove) IsUnsupported

func (j JSONRemove) IsUnsupported() bool

IsUnsupported implements sql.UnsupportedFunctionStub

func (JSONRemove) Resolved

func (j JSONRemove) Resolved() bool

func (JSONRemove) String

func (j JSONRemove) String() string

func (JSONRemove) Type

func (j JSONRemove) Type() sql.Type

func (JSONRemove) WithChildren

func (j JSONRemove) WithChildren(children ...sql.Expression) (sql.Expression, error)

type JSONReplace

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

JSON_REPLACE(json_doc, path, val[, path, val] ...)

JSONReplace Replaces existing values in a JSON document and returns the result. Returns NULL if any argument is NULL. An error occurs if the json_doc argument is not a valid JSON document or any path argument is not a valid path expression or contains a * or ** wildcard. The path-value pairs are evaluated left to right. The document produced by evaluating one pair becomes the new value against which the next pair is evaluated. A path-value pair for an existing path in the document overwrites the existing document value with the new value. A path-value pair for a non-existing path in the document is ignored and has no effect.

https://dev.mysql.com/doc/refman/8.0/en/json-modification-functions.html#function_json-replace

func (JSONReplace) Children

func (j JSONReplace) Children() []sql.Expression

func (JSONReplace) Description

func (j JSONReplace) Description() string

Description implements sql.FunctionExpression

func (JSONReplace) Eval

func (j JSONReplace) Eval(ctx *sql.Context, row sql.Row) (interface{}, error)

func (JSONReplace) FunctionName

func (j JSONReplace) FunctionName() string

FunctionName implements sql.FunctionExpression

func (JSONReplace) IsNullable

func (j JSONReplace) IsNullable() bool

func (JSONReplace) IsUnsupported

func (j JSONReplace) IsUnsupported() bool

IsUnsupported implements sql.UnsupportedFunctionStub

func (JSONReplace) Resolved

func (j JSONReplace) Resolved() bool

func (JSONReplace) String

func (j JSONReplace) String() string

func (JSONReplace) Type

func (j JSONReplace) Type() sql.Type

func (JSONReplace) WithChildren

func (j JSONReplace) WithChildren(children ...sql.Expression) (sql.Expression, error)

type JSONSchemaValid

type JSONSchemaValid struct {
	sql.Expression
}

JSON_SCHEMA_VALID(schema,document)

JSONSchemaValid Validates a JSON document against a JSON schema. Both schema and document are required. The schema must be a valid JSON object; the document must be a valid JSON document. Provided that these conditions are met: If the document validates against the schema, the function returns true (1); otherwise, it returns false (0). https://dev.mysql.com/doc/refman/8.0/en/json-validation-functions.html#function_json-schema-valid

func (JSONSchemaValid) Description

func (j JSONSchemaValid) Description() string

Description implements sql.FunctionExpression

func (JSONSchemaValid) FunctionName

func (j JSONSchemaValid) FunctionName() string

FunctionName implements sql.FunctionExpression

func (JSONSchemaValid) IsUnsupported

func (j JSONSchemaValid) IsUnsupported() bool

IsUnsupported implements sql.UnsupportedFunctionStub

type JSONSchemaValidationReport

type JSONSchemaValidationReport struct {
	sql.Expression
}

JSON_SCHEMA_VALIDATION_REPORT(schema,document)

JSONSchemaValidationReport Validates a JSON document against a JSON schema. Both schema and document are required. As with JSONSchemaValid, the schema must be a valid JSON object, and the document must be a valid JSON document. Provided that these conditions are met, the function returns a report, as a JSON document, on the outcome of the validation. If the JSON document is considered valid according to the JSON Schema, the function returns a JSON object with one property valid having the value "true". If the JSON document fails validation, the function returns a JSON object which includes the properties listed here:

  • valid: Always "false" for a failed schema validation
  • reason: A human-readable string containing the reason for the failure
  • schema-location: A JSON pointer URI fragment identifier indicating where in the JSON schema the validation failed (see Note following this list)
  • document-location: A JSON pointer URI fragment identifier indicating where in the JSON document the validation failed (see Note following this list)
  • schema-failed-keyword: A string containing the name of the keyword or property in the JSON schema that was violated

https://dev.mysql.com/doc/refman/8.0/en/json-validation-functions.html#function_json-schema-validation-report

func (JSONSchemaValidationReport) Description

func (j JSONSchemaValidationReport) Description() string

Description implements sql.FunctionExpression

func (JSONSchemaValidationReport) FunctionName

func (j JSONSchemaValidationReport) FunctionName() string

FunctionName implements sql.FunctionExpression

func (JSONSchemaValidationReport) IsUnsupported

func (j JSONSchemaValidationReport) IsUnsupported() bool

IsUnsupported implements sql.UnsupportedFunctionStub

type JSONSearch

type JSONSearch struct {
	JSON     sql.Expression
	OneOrAll sql.Expression
	Search   sql.Expression
	Escape   sql.Expression
	Paths    []sql.Expression
}

JSONSearch (json_doc, one_or_all, search_str[, escape_char[, path] ...])

JSONSearch Returns the path to the given string within a JSON document. Returns NULL if any of the json_doc, search_str, or path arguments are NULL; no path exists within the document; or search_str is not found. An error occurs if the json_doc argument is not a valid JSON document, any path argument is not a valid path expression, one_or_all is not 'one' or 'all', or escape_char is not a constant expression. The one_or_all argument affects the search as follows:

  • 'one': The search terminates after the first match and returns one path string. It is undefined which match is considered first.
  • 'all': The search returns all matching path strings such that no duplicate paths are included. If there are multiple strings, they are autowrapped as an array. The order of the array elements is undefined.

Within the search_str search string argument, the % and _ characters work as for the LIKE operator: % matches any number of characters (including zero characters), and _ matches exactly one character.

To specify a literal % or _ character in the search string, precede it by the escape character. The default is \ if the escape_char argument is missing or NULL. Otherwise, escape_char must be a constant that is empty or one character. For more information about matching and escape character behavior, see the description of LIKE in Section 12.8.1, “String Comparison Functions and Operators”: https://dev.mysql.com/doc/refman/8.0/en/string-comparison-functions.html For escape character handling, a difference from the LIKE behavior is that the escape character for JSON_SEARCH() must evaluate to a constant at compile time, not just at execution time. For example, if JSON_SEARCH() is used in a prepared statement and the escape_char argument is supplied using a ? parameter, the parameter value might be constant at execution time, but is not at compile time.

https://dev.mysql.com/doc/refman/8.0/en/json-search-functions.html#function_json-search

func (*JSONSearch) Children added in v0.18.1

func (j *JSONSearch) Children() []sql.Expression

Children implements sql.Expression

func (*JSONSearch) CollationCoercibility added in v0.18.1

func (j *JSONSearch) CollationCoercibility(ctx *sql.Context) (sql.CollationID, byte)

CollationCoercibility implements the interface sql.CollationCoercible.

func (*JSONSearch) Description

func (j *JSONSearch) Description() string

Description implements sql.FunctionExpression

func (*JSONSearch) Eval added in v0.18.1

func (j *JSONSearch) Eval(ctx *sql.Context, row sql.Row) (interface{}, error)

Eval implements sql.Expression

func (*JSONSearch) FunctionName

func (j *JSONSearch) FunctionName() string

FunctionName implements sql.FunctionExpression

func (*JSONSearch) IsNullable added in v0.18.1

func (j *JSONSearch) IsNullable() bool

IsNullable implements sql.Expression

func (*JSONSearch) Resolved added in v0.18.1

func (j *JSONSearch) Resolved() bool

Resolved implements sql.Expression

func (*JSONSearch) String added in v0.18.1

func (j *JSONSearch) String() string

String implements sql.Expression

func (*JSONSearch) Type added in v0.18.1

func (j *JSONSearch) Type() sql.Type

Type implements sql.Expression

func (*JSONSearch) WithChildren added in v0.18.1

func (j *JSONSearch) WithChildren(children ...sql.Expression) (sql.Expression, error)

WithChildren implements sql.Expression

type JSONSet

type JSONSet struct {
	JSONDoc     sql.Expression
	PathAndVals []sql.Expression
}

func (*JSONSet) Children

func (j *JSONSet) Children() []sql.Expression

Children implements sql.Expression

func (*JSONSet) Description

func (j *JSONSet) Description() string

Description implements sql.FunctionExpression

func (*JSONSet) Eval

func (j *JSONSet) Eval(ctx *sql.Context, row sql.Row) (interface{}, error)

Eval implements sql.Expression

func (*JSONSet) FunctionName

func (j *JSONSet) FunctionName() string

FunctionName implements sql.FunctionExpression

func (*JSONSet) IsNullable

func (j *JSONSet) IsNullable() bool

IsNullable implements sql.Expression

func (*JSONSet) Resolved

func (j *JSONSet) Resolved() bool

Resolved implements sql.Expression

func (*JSONSet) String

func (j *JSONSet) String() string

String implements Stringer

func (*JSONSet) Type

func (j *JSONSet) Type() sql.Type

Type implements sql.Expression

func (*JSONSet) WithChildren

func (j *JSONSet) WithChildren(children ...sql.Expression) (sql.Expression, error)

WithChildren implements sql.Expression

type JSONStorageFree

type JSONStorageFree struct {
	sql.Expression
}

JSON_STORAGE_FREE(json_val)

JSONStorageFree For a JSON column value, this function shows how much storage space was freed in its binary representation after it was updated in place using JSON_SET(), JSON_REPLACE(), or JSON_REMOVE(). The argument can also be a valid JSON document or a string which can be parsed as one—either as a literal value or as the value of a user variable—in which case the function returns 0. It returns a positive, nonzero value if the argument is a JSON column value which has been updated as described previously, such that its binary representation takes up less space than it did prior to the update. For a JSON column which has been updated such that its binary representation is the same as or larger than before, or if the update was not able to take advantage of a partial update, it returns 0; it returns NULL if the argument is NULL. If json_val is not NULL, and neither is a valid JSON document nor can be successfully parsed as one, an error results.

https://dev.mysql.com/doc/refman/8.0/en/json-utility-functions.html#function_json-storage-size

func (JSONStorageFree) Description

func (j JSONStorageFree) Description() string

Description implements sql.FunctionExpression

func (JSONStorageFree) FunctionName

func (j JSONStorageFree) FunctionName() string

FunctionName implements sql.FunctionExpression

func (JSONStorageFree) IsUnsupported

func (j JSONStorageFree) IsUnsupported() bool

IsUnsupported implements sql.UnsupportedFunctionStub

type JSONStorageSize

type JSONStorageSize struct {
	sql.Expression
}

JSON_STORAGE_SIZE(json_val)

JSONStorageSize This function returns the number of bytes used to store the binary representation of a JSON document. When the argument is a JSON column, this is the space used to store the JSON document as it was inserted into the column, prior to any partial updates that may have been performed on it afterwards. json_val must be a valid JSON document or a string which can be parsed as one. In the case where it is string, the function returns the amount of storage space in the JSON binary representation that is created by parsing the string as JSON and converting it to binary. It returns NULL if the argument is NULL. An error results when json_val is not NULL, and is not—or cannot be successfully parsed as—a JSON document.

https://dev.mysql.com/doc/refman/8.0/en/json-utility-functions.html#function_json-storage-size

func (JSONStorageSize) Description

func (j JSONStorageSize) Description() string

Description implements sql.FunctionExpression

func (JSONStorageSize) FunctionName

func (j JSONStorageSize) FunctionName() string

FunctionName implements sql.FunctionExpression

func (JSONStorageSize) IsUnsupported

func (j JSONStorageSize) IsUnsupported() bool

IsUnsupported implements sql.UnsupportedFunctionStub

type JSONTable

type JSONTable struct {
	sql.Expression
}

JSON_TABLE(expr, path COLUMNS (column_list) [AS] alias)

JSONTable Extracts data from a JSON document and returns it as a relational table having the specified columns. TODO(andy): this doc was heavily truncated

https://dev.mysql.com/doc/refman/8.0/en/json-table-functions.html#function_json-table

func (JSONTable) Description

func (j JSONTable) Description() string

Description implements sql.FunctionExpression

func (JSONTable) FunctionName

func (j JSONTable) FunctionName() string

FunctionName implements sql.FunctionExpression

func (JSONTable) IsUnsupported

func (j JSONTable) IsUnsupported() bool

IsUnsupported implements sql.UnsupportedFunctionStub

type JSONType

type JSONType struct {
	JSON sql.Expression
}

JSONType (json_val)

Returns a utf8mb4 string indicating the type of a JSON value. This can be an object, an array, or a scalar type. JSONType returns NULL if the argument is NULL. An error occurs if the argument is not a valid JSON value

https://dev.mysql.com/doc/refman/8.0/en/json-attribute-functions.html#function_json-type

func (JSONType) Children added in v0.18.1

func (j JSONType) Children() []sql.Expression

Children implements sql.Expression

func (JSONType) Description

func (j JSONType) Description() string

Description implements sql.FunctionExpression

func (JSONType) Eval added in v0.18.1

func (j JSONType) Eval(ctx *sql.Context, row sql.Row) (interface{}, error)

Eval implements sql.Expression

func (JSONType) FunctionName

func (j JSONType) FunctionName() string

FunctionName implements sql.FunctionExpression

func (JSONType) IsNullable added in v0.18.1

func (j JSONType) IsNullable() bool

IsNullable implements sql.Expression

func (JSONType) Resolved added in v0.18.1

func (j JSONType) Resolved() bool

Resolved implements sql.Expression

func (JSONType) String added in v0.18.1

func (j JSONType) String() string

String implements fmt.Stringer

func (JSONType) Type added in v0.18.1

func (j JSONType) Type() sql.Type

Type implements sql.Expression

func (JSONType) WithChildren added in v0.18.1

func (j JSONType) WithChildren(children ...sql.Expression) (sql.Expression, error)

WithChildren implements sql.Expression

type JSONUnquote

type JSONUnquote struct {
	expression.UnaryExpression
}

JSONUnquote unquotes JSON value and returns the result as a utf8mb4 string. Returns NULL if the argument is NULL. An error occurs if the value starts and ends with double quotes but is not a valid JSON string literal.

func (*JSONUnquote) CollationCoercibility

func (*JSONUnquote) CollationCoercibility(ctx *sql.Context) (collation sql.CollationID, coercibility byte)

CollationCoercibility implements the interface sql.CollationCoercible.

func (*JSONUnquote) Description

func (js *JSONUnquote) Description() string

Description implements sql.FunctionExpression

func (*JSONUnquote) Eval

func (js *JSONUnquote) Eval(ctx *sql.Context, row sql.Row) (interface{}, error)

Eval implements the Expression interface.

func (*JSONUnquote) FunctionName

func (js *JSONUnquote) FunctionName() string

FunctionName implements sql.FunctionExpression

func (*JSONUnquote) IsUnsupported

func (js *JSONUnquote) IsUnsupported() bool

IsUnsupported implements sql.UnsupportedFunctionStub

func (*JSONUnquote) String

func (js *JSONUnquote) String() string

func (*JSONUnquote) Type

func (*JSONUnquote) Type() sql.Type

Type implements the Expression interface.

func (*JSONUnquote) WithChildren

func (js *JSONUnquote) WithChildren(children ...sql.Expression) (sql.Expression, error)

WithChildren implements the Expression interface.

type JSONValid

type JSONValid struct {
	JSON sql.Expression
}

JSON_VALID(val)

Returns 0 or 1 to indicate whether a value is valid JSON. Returns NULL if the argument is NULL.

https://dev.mysql.com/doc/refman/8.0/en/json-attribute-functions.html#function_json-valid

func (JSONValid) Children

func (j JSONValid) Children() []sql.Expression

func (JSONValid) Description

func (j JSONValid) Description() string

Description implements sql.FunctionExpression

func (JSONValid) Eval

func (j JSONValid) Eval(ctx *sql.Context, row sql.Row) (interface{}, error)

func (JSONValid) FunctionName

func (j JSONValid) FunctionName() string

FunctionName implements sql.FunctionExpression

func (JSONValid) IsNullable

func (j JSONValid) IsNullable() bool

func (JSONValid) IsUnsupported

func (j JSONValid) IsUnsupported() bool

IsUnsupported implements sql.UnsupportedFunctionStub

func (JSONValid) Resolved

func (j JSONValid) Resolved() bool

func (JSONValid) String

func (j JSONValid) String() string

func (JSONValid) Type

func (j JSONValid) Type() sql.Type

func (JSONValid) WithChildren

func (j JSONValid) WithChildren(children ...sql.Expression) (sql.Expression, error)

type JsonLength

type JsonLength struct {
	JSON sql.Expression
	Path sql.Expression
}

JSON_LENGTH(json_doc [, path])

JsonLength returns the length of a JSON document, or the length of the value extracted from the specified path. https://dev.mysql.com/doc/refman/8.0/en/json-attribute-functions.html#function_json-length

func (*JsonLength) Children

func (j *JsonLength) Children() []sql.Expression

Children implements the sql.Expression interface.

func (*JsonLength) CollationCoercibility

func (*JsonLength) CollationCoercibility(ctx *sql.Context) (collation sql.CollationID, coercibility byte)

CollationCoercibility implements the interface sql.CollationCoercible.

func (*JsonLength) Description

func (j *JsonLength) Description() string

Description implements sql.FunctionExpression

func (*JsonLength) Eval

func (j *JsonLength) Eval(ctx *sql.Context, row sql.Row) (interface{}, error)

Eval implements the sql.Expression interface.

func (*JsonLength) FunctionName

func (j *JsonLength) FunctionName() string

FunctionName implements sql.FunctionExpression

func (*JsonLength) IsNullable

func (j *JsonLength) IsNullable() bool

IsNullable implements the sql.Expression interface.

func (*JsonLength) Resolved

func (j *JsonLength) Resolved() bool

Resolved implements the sql.Expression interface.

func (*JsonLength) String

func (j *JsonLength) String() string

func (*JsonLength) Type

func (j *JsonLength) Type() sql.Type

Type implements the sql.Expression interface.

func (*JsonLength) WithChildren

func (j *JsonLength) WithChildren(children ...sql.Expression) (sql.Expression, error)

WithChildren implements the Expression interface.

type JsonValue

type JsonValue struct {
	JSON sql.Expression
	Path sql.Expression
	Typ  sql.Type
}

JsonValue selects data from a json document using a json path and optional type coercion. https://dev.mysql.com/doc/refman/8.0/en/json-search-functions.html#function_json-value usage: JSON_VALUE(json_doc, path, [returning type]) TODO: [RETURNING TYPE] should be appended to path option in parser TODO: missing [on empty] and [on error] support

func (*JsonValue) Children

func (j *JsonValue) Children() []sql.Expression

Children implements the sql.Expression interface.

func (*JsonValue) CollationCoercibility

func (*JsonValue) CollationCoercibility(ctx *sql.Context) (collation sql.CollationID, coercibility byte)

CollationCoercibility implements the interface sql.CollationCoercible.

func (*JsonValue) Description

func (j *JsonValue) Description() string

Description implements sql.FunctionExpression

func (*JsonValue) Eval

func (j *JsonValue) Eval(ctx *sql.Context, row sql.Row) (interface{}, error)

Eval implements the sql.Expression interface.

func (*JsonValue) FunctionName

func (j *JsonValue) FunctionName() string

FunctionName implements sql.FunctionExpression

func (*JsonValue) IsNullable

func (j *JsonValue) IsNullable() bool

IsNullable implements the sql.Expression interface.

func (*JsonValue) Resolved

func (j *JsonValue) Resolved() bool

Resolved implements the sql.Expression interface.

func (*JsonValue) String

func (j *JsonValue) String() string

func (*JsonValue) Type

func (j *JsonValue) Type() sql.Type

Type implements the sql.Expression interface.

func (*JsonValue) WithChildren

func (j *JsonValue) WithChildren(children ...sql.Expression) (sql.Expression, error)

WithChildren implements the Expression interface.

Jump to

Keyboard shortcuts

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