Skip to Content
fusion-orm
API Reference

Config reference

Every field of fusion.Config and fusion.Session — types, defaults, and semantics from fusion.go.

Config holds session-wide settings passed to Open:

db, err := fusion.Open(sqlite.Open("app.db"), &fusion.Config{Logger: l})

*Config itself implements Option (Apply copies it onto the working config, fusion.go:113), so a full config can be passed directly. It is copied shallowly whenever a session derivative is made, so session flags never leak back to the root — DryRun on a derivative never flips the root's flag.

Config fields

FieldTypeDefaultMeaning
SkipDefaultTransactionboolfalseDisables the implicit transaction wrapping single create/update/delete operations.
Loggerlogger.Interfacelogger.Default (Warn)Receives info/warn/error messages and SQL traces.
NowFuncfunc() time.Timetime.Now().Local()Produces timestamps.
DryRunboolfalseCaptures SQL on Statement instead of executing it.
TranslateErrorboolfalseMaps driver constraint errors through the dialector's ErrorTranslator before they reach the error slot.
AllowGlobalUpdateboolfalsePermits Update/Delete statements without WHERE clauses (guarded by ErrMissingWhereClause otherwise).
DisableAutomaticPingboolfalseSkips the Ping performed by Open.
DisableNestedTransactionboolfalseRuns nested Transaction calls inline instead of via savepoints.
NamingStrategyschema.Namerschema.NamingStrategy{}Maps Go model/field names to table/column names.
StrictTagsboolfalseRejects unknown fusion tag keys instead of warning.
PrepareStmtboolfalseEnables the LRU+TTL prepared-statement cache.
PreparedStmtCacheSizeint1000Bounds cached statements.
PreparedStmtTTLtime.Duration0 (no expiry)Expires cached statements.
QueryHooks[]QueryHooknilObserves statements around execution.
ConnPoolConnPoolnilWhen set before Open, is used instead of opening a pool through the dialector.
Dialectordialect.Dialectorset by OpenRenders SQL for the session. Set by Open from its argument.
Pluginsmap[string]Pluginempty mapRegistered before Open; each is initialized during Open.
FullSaveAssociationsboolfalseMakes association saves use Save (not Create) for records that already carry a primary key.

The last internal fields — tables (*schema.Tables), callbacks (*CallbackManager), and joinTables (*joinTableRegistry) — are the per-session schema cache and CRUD processors. They are created by Open and shared read-only by every derivative.

Session fields

Session configures a derivative created by DB.Session:

// Flags on config are one-way overrides onto a copied Config; the
// receiver's Config is never mutated.
tx := db.Session(&fusion.Session{DryRun: true})
FieldTypeDefaultMeaning
DryRunboolfalseTurns the derivative into a SQL-capturing session.
NewDBboolfalseResets the chain: the derivative starts with a fresh Statement instead of inheriting the receiver's clauses.
InitializedboolfalseForces the derivative through getInstance immediately.
SkipDefaultTransactionboolfalseOverrides the corresponding Config flag for this session.
DisableNestedTransactionboolfalseOverrides the corresponding Config flag for this session.
AllowGlobalUpdateboolfalseOverrides the corresponding Config flag for this session.
Contextcontext.ContextnilReplaces the derivative's execution context.
Loggerlogger.InterfacenilReplaces the derivative's logger (used by Debug).
NowFuncfunc() time.TimenilReplaces the derivative's timestamp source.
FullSaveAssociationsboolfalseSaves associated records with Save instead of Create on the derivative.

One-way overrides

Session boolean flags are only ever turned on by the derivative — there is no way for a Session to unset a flag that the receiver's Config carries. Pass NewDB: true when you want a clean statement, not a clean config.

Next

On this page