MCPcopy
hub / github.com/jackc/pgx / sanitizeForSimpleQuery

Method sanitizeForSimpleQuery

conn.go:1260–1279  ·  view source on GitHub ↗
(sql string, args ...any)

Source from the content-addressed store, hash-verified

1258}
1259
1260func (c *Conn) sanitizeForSimpleQuery(sql string, args ...any) (string, error) {
1261 if c.pgConn.ParameterStatus("standard_conforming_strings") != "on" {
1262 return "", errors.New("simple protocol queries must be run with standard_conforming_strings=on")
1263 }
1264
1265 if c.pgConn.ParameterStatus("client_encoding") != "UTF8" {
1266 return "", errors.New("simple protocol queries must be run with client_encoding=UTF8")
1267 }
1268
1269 var err error
1270 valueArgs := make([]any, len(args))
1271 for i, a := range args {
1272 valueArgs[i], err = convertSimpleArgument(c.typeMap, a)
1273 if err != nil {
1274 return "", err
1275 }
1276 }
1277
1278 return sanitize.SanitizeSQL(sql, valueArgs...)
1279}
1280
1281// LoadType inspects the database for typeName and produces a [pgtype.Type] suitable for registration. typeName must be
1282// the name of a type where the underlying type(s) is already understood by pgx. It is for derived types. In particular,

Callers 3

execSimpleProtocolMethod · 0.95
QueryMethod · 0.95

Calls 3

SanitizeSQLFunction · 0.92
convertSimpleArgumentFunction · 0.85
ParameterStatusMethod · 0.80

Tested by

no test coverage detected