cbcd945251
* preview of work so far * stylistic improvements * fix linters * remove golden tests, they may cause the system to be too rigid to changes * remove unnecessary code for golden tests * remove white space mangling in Execute * also handle output data, improve API, examples and docs * add helper methods * fix interface
34 lines
683 B
Go
34 lines
683 B
Go
package sqltemplate
|
|
|
|
import (
|
|
"errors"
|
|
"strings"
|
|
)
|
|
|
|
// PostgreSQL is an implementation of Dialect for the PostgreSQL DMBS.
|
|
var PostgreSQL = postgresql{
|
|
rowLockingClauseAll: true,
|
|
}
|
|
|
|
var _ Dialect = PostgreSQL
|
|
|
|
// PostgreSQL-specific errors.
|
|
var (
|
|
ErrPostgreSQLUnsupportedIdent = errors.New("identifiers in PostgreSQL cannot contain the character with code zero")
|
|
)
|
|
|
|
type postgresql struct {
|
|
standardIdent
|
|
rowLockingClauseAll
|
|
}
|
|
|
|
func (p postgresql) Ident(s string) (string, error) {
|
|
// See:
|
|
// https://www.postgresql.org/docs/current/sql-syntax-lexical.html
|
|
if strings.IndexByte(s, 0) != -1 {
|
|
return "", ErrPostgreSQLUnsupportedIdent
|
|
}
|
|
|
|
return p.standardIdent.Ident(s)
|
|
}
|