{"modulePath":"github.com/bitechdev/ResolveSpec","version":"v1.3.14","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package dialect\n\nPackage dialect holds the per-database adaptors used by the lookup direct backend. An adaptor supplies only what differs between databases (placeholders, quoting, booleans, time and JSON handling, insert-returning-id); the backend builds queries from it. It imports only the standard library.\n\n## Functions\n\n```go\nfunc Names() []string\n```\nNames lists the registered dialect names, sorted.\n\n```go\nfunc Register(name string, f Factory)\n```\nRegister adds a dialect under name. Registering a name twice replaces it, so applications can override a built-in. Adding a database = implementing Dialect and calling Register.\n\n## Types\n\n```go\ntype Dialect interface {\n\t// Name is the registry name, e.g. \"postgres\".\n\tName() string\n\t// Matches reports whether a driver type identifier (lowercased \"\u003cpkgpath\u003e.\u003cType\u003e\")\n\t// belongs to this database. Used by Detect.\n\tMatches(driver string) bool\n\t// Placeholder returns the bind placeholder for the n-th (1-based) argument.\n\tPlaceholder(n int) string\n\t// Quote quotes an identifier. A dotted name is quoted per part (\"schema.table\").\n\t// Embedded quote characters are escaped, never interpolated raw.\n\tQuote(ident string) string\n\t// Bool converts a Go bool to the value bound as a boolean column argument.\n\tBool(v bool) any\n\t// ScanBool reads a boolean column value that the driver returned as bool, integer, string or bytes.\n\tScanBool(src any) (bool, error)\n\t// ScanTime reads a time column value that the driver returned as time.Time, string or bytes.\n\t// NULL (nil) yields the zero time.\n\tScanTime(src any) (time.Time, error)\n\t// EncodeJSON converts a value to the argument bound to a JSON/TEXT column. A nil\n\t// value, map or slice yields nil (SQL NULL).\n\tEncodeJSON(v any) (any, error)\n\t// DecodeJSON reads a JSON/TEXT column value into dst. NULL and empty values leave dst untouched.\n\tDecodeJSON(src any, dst any) error\n\t// InsertReturningID builds an INSERT of cols into table and describes how to read the new id.\n\t// Arguments are bound positionally in cols order.\n\tInsertReturningID(table string, cols []string, idCol string) Insert\n}\n```\nDialect is the adaptor for one database type.\n\n```go\nfunc Detect(db *sql.DB) (Dialect, error)\n```\nDetect picks the dialect for db from its driver type.\n\n```go\nfunc DetectDriver(driver string) (Dialect, error)\n```\nDetectDriver picks the dialect for a driver type identifier (see Dialect.Matches).\n\n```go\nfunc Get(name string) (Dialect, error)\n```\nGet returns the dialect registered under name.\n\n```go\ntype Factory func() Dialect\n```\nFactory creates a Dialect.\n\n```go\ntype Insert struct {\n\tSQL      string\n\tStrategy InsertStrategy\n}\n```\nInsert is a generated INSERT statement and how to read the id it creates.\n\n```go\nfunc (i Insert) Run(ctx context.Context, q Querier, args ...any) (int64, error)\n```\nRun executes the insert and returns the generated id.\n\n```go\ntype InsertStrategy int\n```\nInsertStrategy tells how the generated id is read after an Insert.\n\n```go\nconst (\n\t// ReturningQuery means the statement returns the id as a single row (QueryRow + Scan).\n\tReturningQuery InsertStrategy = iota\n\t// LastInsertID means the id is read from sql.Result.LastInsertId after Exec.\n\tLastInsertID\n)\n```\n\n```go\ntype Querier interface {\n\tExecContext(ctx context.Context, query string, args ...any) (sql.Result, error)\n\tQueryRowContext(ctx context.Context, query string, args ...any) *sql.Row\n}\n```\nQuerier is implemented by \\*sql.DB, \\*sql.Tx and \\*sql.Conn.\n\n","path":"github.com/bitechdev/ResolveSpec/pkg/security/lookup/dialect","name":"dialect","synopsis":"Package dialect holds the per-database adaptors used by the lookup direct backend.","isRedistributable":true}
