stardb/sql_placeholder.go

20 lines
657 B
Go
Raw Normal View History

package stardb
import internalsqlplaceholder "b612.me/stardb/internal/sqlplaceholder"
// ConvertPlaceholders converts placeholders according to style.
func ConvertPlaceholders(query string, style PlaceholderStyle) string {
switch normalizePlaceholderStyle(style) {
case PlaceholderDollar:
return ConvertQuestionToDollarPlaceholders(query)
default:
return query
}
}
// ConvertQuestionToDollarPlaceholders converts '?' to '$1,$2,...' in SQL text.
// It skips quoted strings, quoted identifiers and comments.
func ConvertQuestionToDollarPlaceholders(query string) string {
return internalsqlplaceholder.ConvertQuestionToDollarPlaceholders(query)
}