balancedTableRefs returns s (trimmed) with parentheses balanced. omni's JoinClause/TableRef Loc excludes a wrapping "(" or ")", so a sliced table-ref list can carry an unmatched ")" (a parenthesized left join operand) and/or an unmatched "(" (a right operand). The missing parentheses only group, so
(s string)
| 781 | // unmatched "(" (a right operand). The missing parentheses only group, so their |
| 782 | // source position is irrelevant — prepend "(" and append ")" to balance. |
| 783 | func balancedTableRefs(s string) string { |
| 784 | leading, trailing := parenDeficit(s) |
| 785 | s = strings.TrimSpace(s) |
| 786 | if leading > 0 { |
| 787 | s = strings.Repeat("(", leading) + s |
| 788 | } |
| 789 | if trailing > 0 { |
| 790 | s += strings.Repeat(")", trailing) |
| 791 | } |
| 792 | return s |
| 793 | } |
| 794 | |
| 795 | // parenDeficit returns how many "(" must be prepended and ")" appended to |
| 796 | // balance s, ignoring parentheses inside string/identifier literals ('...', |
no test coverage detected