diff options
| author | Stefan Majewsky <majewsky@gmx.net> | 2026-04-14 00:50:20 +0200 |
|---|---|---|
| committer | Stefan Majewsky <majewsky@gmx.net> | 2026-04-14 00:50:20 +0200 |
| commit | d75031ffd1667c330ccc281ea330503eaeaea88a (patch) | |
| tree | 91a22017fbf2d05335f009fadcb146892e235db1 /internal/dialect.go | |
| parent | 9191e018ff90deb99f3881966a5d356a05027e0f (diff) | |
| download | go-oblast-d75031ffd1667c330ccc281ea330503eaeaea88a.tar.gz | |
fold package internal into package oblast
Diffstat (limited to 'internal/dialect.go')
| -rw-r--r-- | internal/dialect.go | 41 |
1 files changed, 0 insertions, 41 deletions
diff --git a/internal/dialect.go b/internal/dialect.go deleted file mode 100644 index e6db5b8..0000000 --- a/internal/dialect.go +++ /dev/null @@ -1,41 +0,0 @@ -// SPDX-FileCopyrightText: 2026 Stefan Majewsky <majewsky@gmx.net> -// SPDX-License-Identifier: Apache-2.0 - -package internal - -import ( - "strconv" - "strings" -) - -// Dialect is a copy of the interface of the same name in package oblast. -// We cannot refer to that interface within this package because that would constitute a cyclic dependency. -type Dialect interface { - Placeholder(i int) string - QuoteIdentifier(name string) string - UsesLastInsertID() bool - InsertSuffixForAutoColumns(columns []string) string -} - -// PostgresDialect is the dialect of PostgreSQL databases. -type PostgresDialect struct{} - -func (PostgresDialect) Placeholder(i int) string { return "$" + strconv.Itoa(i+1) } -func (PostgresDialect) QuoteIdentifier(name string) string { return `"` + name + `"` } -func (PostgresDialect) UsesLastInsertID() bool { return false } - -func (p PostgresDialect) InsertSuffixForAutoColumns(columns []string) string { - quotedColumns := make([]string, len(columns)) - for idx, name := range columns { - quotedColumns[idx] = p.QuoteIdentifier(name) - } - return ` RETURNING ` + strings.Join(quotedColumns, ", ") -} - -// SqliteDialect is the dialect of SQLite databases. -type SqliteDialect struct{} - -func (SqliteDialect) Placeholder(_ int) string { return "?" } -func (SqliteDialect) QuoteIdentifier(name string) string { return `"` + name + `"` } -func (SqliteDialect) UsesLastInsertID() bool { return true } -func (SqliteDialect) InsertSuffixForAutoColumns(columns []string) string { return "" } |
