diff options
| author | Stefan Majewsky <majewsky@gmx.net> | 2026-07-17 19:35:55 +0200 |
|---|---|---|
| committer | Stefan Majewsky <majewsky@gmx.net> | 2026-07-17 19:35:55 +0200 |
| commit | 1383c6fbaa6b9e0b7cc5e44b74a905352d596758 (patch) | |
| tree | 5aa59347be173f8c16ab9d8246e89def0a0aadcd /dialect.go | |
| parent | 3d1fce7b843891f789887655a9ce0c9ce1ace2de (diff) | |
| download | go-oblast-1383c6fbaa6b9e0b7cc5e44b74a905352d596758.tar.gz | |
cache buildPlan results
Diffstat (limited to 'dialect.go')
| -rw-r--r-- | dialect.go | 17 |
1 files changed, 17 insertions, 0 deletions
@@ -43,6 +43,11 @@ type Dialect interface { // behave like UPDATE if a record with the same primary key already exists. // This is only used for record types that have a primary key. UpsertClause(pkColumns, otherColumns []string) string + + // String returns a unique identifier for this Dialect instance. + // Different instances shall return the same string only if all their methods behave identically. + // This information is used to cache generated query plans. + String() string } // MariaDBDialect is the dialect of MariaDB 10.5+ databases. @@ -81,6 +86,10 @@ func (d mariadbDialect) UpsertClause(pkColumns, otherColumns []string) string { return ` ON DUPLICATE KEY UPDATE ` + strings.Join(clauses, ", ") } +func (mariadbDialect) String() string { + return "mariadb" +} + // PostgresDialect is the dialect of PostgreSQL databases. func PostgresDialect() Dialect { return postgresDialect{} @@ -117,6 +126,10 @@ func (d postgresDialect) UpsertClause(pkColumns, otherColumns []string) string { } } +func (postgresDialect) String() string { + return "postgres" +} + // SqliteDialect is the dialect of SQLite 3.35.0+ databases. // // This dialect does NOT support ancient SQLite versions (3.35.0 was released 2021-03-12) @@ -142,3 +155,7 @@ func (sqliteDialect) CanUseLastInsertId() bool { func (sqliteDialect) UpsertClause(pkColumns, otherColumns []string) string { return postgresDialect{}.UpsertClause(pkColumns, otherColumns) } + +func (sqliteDialect) String() string { + return "sqliteDialect" +} |
