stripQuotedIdentifiers replaces double-quoted identifiers with placeholder text so that keyword searches don't match content inside quotes (e.g., "order" should not be treated as the ORDER keyword).
(s string)
| 485 | // placeholder text so that keyword searches don't match content inside |
| 486 | // quotes (e.g., "order" should not be treated as the ORDER keyword). |
| 487 | func stripQuotedIdentifiers(s string) string { |
| 488 | var b strings.Builder |
| 489 | b.Grow(len(s)) |
| 490 | i := 0 |
| 491 | for i < len(s) { |
| 492 | if s[i] == '"' { |
| 493 | // Replace the entire "..." with underscores to preserve length. |
| 494 | b.WriteByte('_') |
| 495 | i++ // skip opening " |
| 496 | for i < len(s) { |
| 497 | if s[i] == '"' { |
| 498 | i++ |
| 499 | if i < len(s) && s[i] == '"' { |
| 500 | b.WriteByte('_') |
| 501 | b.WriteByte('_') |
| 502 | i++ |
| 503 | continue |
| 504 | } |
| 505 | b.WriteByte('_') |
| 506 | break |
| 507 | } |
| 508 | b.WriteByte('_') |
| 509 | i++ |
| 510 | } |
| 511 | } else { |
| 512 | b.WriteByte(s[i]) |
| 513 | i++ |
| 514 | } |
| 515 | } |
| 516 | return b.String() |
| 517 | } |
no test coverage detected