package dialect
import "entgo.io/ent/dialect"
Index ¶
- Constants
- type DebugDriver
- func (d *DebugDriver) BeginTx(ctx context.Context, opts *sql.TxOptions) (Tx, error)
- func (d *DebugDriver) Exec(ctx context.Context, query string, args, v any) error
- func (d *DebugDriver) ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error)
- func (d *DebugDriver) Query(ctx context.Context, query string, args, v any) error
- func (d *DebugDriver) QueryContext(ctx context.Context, query string, args ...any) (*sql.Rows, error)
- func (d *DebugDriver) Tx(ctx context.Context) (Tx, error)
- type DebugTx
- func (d *DebugTx) Commit() error
- func (d *DebugTx) Exec(ctx context.Context, query string, args, v any) error
- func (d *DebugTx) ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error)
- func (d *DebugTx) Query(ctx context.Context, query string, args, v any) error
- func (d *DebugTx) QueryContext(ctx context.Context, query string, args ...any) (*sql.Rows, error)
- func (d *DebugTx) Rollback() error
- type Driver
- func Debug(d Driver, logger ...func(...any)) Driver
- func DebugWithContext(d Driver, logger func(context.Context, ...any)) Driver
- type ExecQuerier
- type Tx
Constants ¶
const ( MySQL = "mysql" SQLite = "sqlite3" Postgres = "postgres" Gremlin = "gremlin" )
Dialect names for external usage.
Types ¶
type DebugDriver ¶
type DebugDriver struct { Driver // underlying driver. // contains filtered or unexported fields }
DebugDriver is a driver that logs all driver operations.
func (*DebugDriver) BeginTx ¶
BeginTx adds an log-id for the transaction and calls the underlying driver BeginTx command if it is supported.
func (*DebugDriver) Exec ¶
Exec logs its params and calls the underlying driver Exec method.
func (*DebugDriver) ExecContext ¶
func (d *DebugDriver) ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error)
ExecContext logs its params and calls the underlying driver ExecContext method if it is supported.
func (*DebugDriver) Query ¶
Query logs its params and calls the underlying driver Query method.
func (*DebugDriver) QueryContext ¶
func (d *DebugDriver) QueryContext(ctx context.Context, query string, args ...any) (*sql.Rows, error)
QueryContext logs its params and calls the underlying driver QueryContext method if it is supported.
func (*DebugDriver) Tx ¶
func (d *DebugDriver) Tx(ctx context.Context) (Tx, error)
Tx adds an log-id for the transaction and calls the underlying driver Tx command.
type DebugTx ¶
type DebugTx struct { Tx // underlying transaction. // contains filtered or unexported fields }
DebugTx is a transaction implementation that logs all transaction operations.
func (*DebugTx) Commit ¶
Commit logs this step and calls the underlying transaction Commit method.
func (*DebugTx) Exec ¶
Exec logs its params and calls the underlying transaction Exec method.
func (*DebugTx) ExecContext ¶
ExecContext logs its params and calls the underlying transaction ExecContext method if it is supported.
func (*DebugTx) Query ¶
Query logs its params and calls the underlying transaction Query method.
func (*DebugTx) QueryContext ¶
QueryContext logs its params and calls the underlying transaction QueryContext method if it is supported.
func (*DebugTx) Rollback ¶
Rollback logs this step and calls the underlying transaction Rollback method.
type Driver ¶
type Driver interface { ExecQuerier // Tx starts and returns a new transaction. // The provided context is used until the transaction is committed or rolled back. Tx(context.Context) (Tx, error) // Close closes the underlying connection. Close() error // Dialect returns the dialect name of the driver. Dialect() string }
Driver is the interface that wraps all necessary operations for ent clients.
func Debug ¶
Debug gets a driver and an optional logging function, and returns a new debugged-driver that prints all outgoing operations.
func DebugWithContext ¶
DebugWithContext gets a driver and a logging function, and returns a new debugged-driver that prints all outgoing operations with context.
type ExecQuerier ¶
type ExecQuerier interface { // Exec executes a query that does not return records. For example, in SQL, INSERT or UPDATE. // It scans the result into the pointer v. For SQL drivers, it is dialect/sql.Result. Exec(ctx context.Context, query string, args, v any) error // Query executes a query that returns rows, typically a SELECT in SQL. // It scans the result into the pointer v. For SQL drivers, it is *dialect/sql.Rows. Query(ctx context.Context, query string, args, v any) error }
ExecQuerier wraps the 2 database operations.
type Tx ¶
type Tx interface { ExecQuerier driver.Tx }
Tx wraps the Exec and Query operations in transaction.
func NopTx ¶
NopTx returns a Tx with a no-op Commit / Rollback methods wrapping the provided Driver d.
Source Files ¶
dialect.go
Directories ¶
Path | Synopsis |
---|---|
dialect/entsql | |
dialect/gremlin | |
dialect/gremlin/encoding | |
dialect/gremlin/encoding/graphson | |
dialect/gremlin/graph | |
dialect/gremlin/graph/dsl | Package dsl provide an API for writing gremlin dsl queries almost as-is in Go without using strings in the code. |
dialect/gremlin/graph/dsl/__ | |
dialect/gremlin/graph/dsl/g | |
dialect/gremlin/graph/dsl/p | |
dialect/gremlin/internal | |
dialect/gremlin/ocgremlin | |
dialect/sql | Package sql provides wrappers around the standard database/sql package to allow the generated code to interact with a statically-typed API. |
dialect/sql/schema | Package schema contains all schema migration logic for SQL dialects. |
dialect/sql/sqlgraph | Package sqlgraph provides graph abstraction capabilities on top of sql-based databases for ent codegen. |
dialect/sql/sqljson |
- Version
- v0.14.4 (latest)
- Published
- Mar 17, 2025
- Platform
- linux/amd64
- Imports
- 6 packages
- Last checked
- 3 hours ago –
Tools for package owners.