-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathdialect.go
36 lines (30 loc) · 1.25 KB
/
dialect.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package db
import (
"context"
"fmt"
sink "github.com/streamingfast/substreams-sink"
)
type UnknownDriverError struct {
Driver string
}
// Error returns a formatted string description.
func (e UnknownDriverError) Error() string {
return fmt.Sprintf("unknown database driver: %s", e.Driver)
}
type dialect interface {
GetCreateCursorQuery(schema string, withPostgraphile bool) string
GetCreateHistoryQuery(schema string, withPostgraphile bool) string
ExecuteSetupScript(ctx context.Context, l *Loader, schemaSql string) error
DriverSupportRowsAffected() bool
GetUpdateCursorQuery(table, moduleHash string, cursor *sink.Cursor, block_num uint64, block_id string) string
ParseDatetimeNormalization(value string) string
Flush(tx Tx, ctx context.Context, l *Loader, outputModuleHash string, lastFinalBlock uint64) (int, error)
Revert(tx Tx, ctx context.Context, l *Loader, lastValidFinalBlock uint64) error
OnlyInserts() bool
AllowPkDuplicates() bool
CreateUser(tx Tx, ctx context.Context, l *Loader, username string, password string, database string, readOnly bool) error
}
var driverDialect = map[string]dialect{
"*pq.Driver": postgresDialect{}, // github.com/lib/pq
"*clickhouse.stdDriver": clickhouseDialect{}, // github.com/clickhouse-go/v2
}