From 293e2a52e0b45065db12ff27f89f1adebe4bf4d2 Mon Sep 17 00:00:00 2001 From: Stefan Majewsky Date: Fri, 10 Apr 2026 20:13:15 +0200 Subject: reorganize code --- dialect.go | 30 +++--------------------------- 1 file changed, 3 insertions(+), 27 deletions(-) (limited to 'dialect.go') diff --git a/dialect.go b/dialect.go index f29a34a..7a3acff 100644 --- a/dialect.go +++ b/dialect.go @@ -3,10 +3,7 @@ package oblast -import ( - "strconv" - "strings" -) +import "go.xyrillian.de/oblast/internal" // Dialect accounts for differences between different SQL dialects // that are relevant to query generation within Oblast. @@ -40,31 +37,10 @@ type Dialect interface { // PostgresDialect is the dialect of PostgreSQL databases. func PostgresDialect() Dialect { - return postgresDialect{} -} - -type postgresDialect struct{} - -func (postgresDialect) Placeholder(i int) string { return "$" + strconv.Itoa(i) } -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, ", ") + return internal.PostgresDialect{} } // SqliteDialect is the dialect of SQLite databases. func SqliteDialect() Dialect { - return sqliteDialect{} + return internal.SqliteDialect{} } - -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 "" } -- cgit v1.2.3