EncodeEscapedSQLIdent writes the identifier in s to buf. The identifier is always quoted. Double quotes inside the identifier are escaped.
(buf *bytes.Buffer, s string)
| 174 | // identifier is always quoted. Double quotes inside the identifier |
| 175 | // are escaped. |
| 176 | func EncodeEscapedSQLIdent(buf *bytes.Buffer, s string) { |
| 177 | buf.WriteByte('"') |
| 178 | start := 0 |
| 179 | for i, n := 0, len(s); i < n; i++ { |
| 180 | ch := s[i] |
| 181 | // The only character that requires escaping is a double quote. |
| 182 | if ch == '"' { |
| 183 | if start != i { |
| 184 | buf.WriteString(s[start:i]) |
| 185 | } |
| 186 | start = i + 1 |
| 187 | buf.WriteByte(ch) |
| 188 | buf.WriteByte(ch) // add extra copy of ch |
| 189 | } |
| 190 | } |
| 191 | if start < len(s) { |
| 192 | buf.WriteString(s[start:]) |
| 193 | } |
| 194 | buf.WriteByte('"') |
| 195 | } |
| 196 | |
| 197 | // EncodeLocaleName writes the locale identifier in s to buf. Any dash |
| 198 | // characters are mapped to underscore characters. Underscore characters do not |
no test coverage detected