MCPcopy Create free account
hub / github.com/ajitpratap0/GoSQLX / SQL

Method SQL

pkg/sql/ast/sql.go:129–144  ·  view source on GitHub ↗

SQL returns the SQL literal representation of this value. Strings are single-quoted with proper escaping; NULLs are returned as "NULL"; booleans are returned in uppercase (TRUE/FALSE); numbers are returned as-is.

()

Source from the content-addressed store, hash-verified

127// Strings are single-quoted with proper escaping; NULLs are returned as "NULL";
128// booleans are returned in uppercase (TRUE/FALSE); numbers are returned as-is.
129func (l *LiteralValue) SQL() string {
130 if l == nil {
131 return ""
132 }
133 if l.Value == nil || strings.EqualFold(l.Type, "NULL") {
134 return "NULL"
135 }
136 switch strings.ToUpper(l.Type) {
137 case "STRING":
138 return "'" + escapeStringLiteral(fmt.Sprintf("%v", l.Value)) + "'"
139 case "BOOLEAN":
140 return strings.ToUpper(fmt.Sprintf("%v", l.Value))
141 default:
142 return fmt.Sprintf("%v", l.Value)
143 }
144}
145
146// SQL returns the unquoted identifier name. Used for round-trip serialization.
147func (i *Ident) SQL() string {

Callers

nothing calls this directly

Calls 1

escapeStringLiteralFunction · 0.85

Tested by

no test coverage detected