MCPcopy Create free account
hub / github.com/dolthub/doltgresql / sqlString

Function sqlString

server/types/utils.go:148–160  ·  view source on GitHub ↗

sqlString converts given type value to output string. This is the same as IoOutput function with an exception to BOOLEAN type. It returns "t" instead of "true".

(ctx *sql.Context, t *DoltgresType, val any)

Source from the content-addressed store, hash-verified

146// sqlString converts given type value to output string. This is the same as IoOutput function
147// with an exception to BOOLEAN type. It returns "t" instead of "true".
148func sqlString(ctx *sql.Context, t *DoltgresType, val any) (string, error) {
149 if t.IsArrayType() {
150 baseType := t.ArrayBaseType()
151 return ArrToString(ctx, val.([]any), baseType, true)
152 } else if t.ID == Bool.ID {
153 if val.(bool) {
154 return "t", nil
155 } else {
156 return "f", nil
157 }
158 }
159 return t.IoOutput(ctx, val)
160}
161
162// ArrToString is used for array_out function. |trimBool| parameter allows replacing
163// boolean result of "true" to "t" if the function is `Type.SQL()`.

Callers 1

SQLMethod · 0.85

Calls 4

ArrToStringFunction · 0.85
IsArrayTypeMethod · 0.80
ArrayBaseTypeMethod · 0.80
IoOutputMethod · 0.80

Tested by

no test coverage detected