quoteString determines if |s| needs to be quoted, by looking for special characters like ' ' or ',', and if so, quotes the string and returns it. If quoting is not needed, then |s| is returned as is.
(s string)
| 337 | // quoteString determines if |s| needs to be quoted, by looking for special characters like ' ' or ',', |
| 338 | // and if so, quotes the string and returns it. If quoting is not needed, then |s| is returned as is. |
| 339 | func quoteString(s string) string { |
| 340 | shouldQuote := false |
| 341 | for _, r := range s { |
| 342 | switch r { |
| 343 | case ' ', ',', '{', '}', '\\', '"': |
| 344 | shouldQuote = true |
| 345 | } |
| 346 | } |
| 347 | if shouldQuote || strings.EqualFold(s, "NULL") || len(s) == 0 { |
| 348 | return fmt.Sprintf(`"%s"`, strings.ReplaceAll(s, `"`, `\"`)) |
| 349 | } else { |
| 350 | return s |
| 351 | } |
| 352 | } |
| 353 | |
| 354 | // toInternal returns an Internal ID for the given type. This is only used for the built-in types, since they all share |
| 355 | // the same schema (pg_catalog). |
no outgoing calls
no test coverage detected