Liking cljdoc? Tell your friends :D

wagoe.platform.shell.adapters.database.common.execution

Query execution with I/O, logging, and error handling.

This is part of the imperative shell - it performs database I/O, manages transactions, and handles side effects like logging.

Query execution with I/O, logging, and error handling.

This is part of the imperative shell - it performs database I/O,
manages transactions, and handles side effects like logging.
raw docstring

*transaction-datasource*clj

Bound transaction connection used by database execution helpers.

This ensures all nested database calls inside a transaction share the same JDBC connection instead of borrowing a new one from the pool.

Bound transaction connection used by database execution helpers.

This ensures all nested database calls inside a transaction share the same
JDBC connection instead of borrowing a new one from the pool.
sourceraw docstring

after-commit!clj

(after-commit! f)

Call f once the transaction with-transaction* holds open on this thread commits, and never if it rolls back; with none open, now. For work another system sees, such as a job on a queue outside the database.

Call `f` once the transaction `with-transaction*` holds open on this thread
commits, and never if it rolls back; with none open, now. For work another
system sees, such as a job on a queue outside the database.
sourceraw docstring

as-kebab-mapsclj

(as-kebab-maps rs opts)

next.jdbc builder-fn: unqualified maps keyed as snake-case->kebab-case-string names a column, where the default splits digits off (e2e_id becomes :e-2e-id). Opt in with :builder-fn on the db context.

next.jdbc builder-fn: unqualified maps keyed as `snake-case->kebab-case-string`
names a column, where the default splits digits off (`e2e_id` becomes
`:e-2e-id`). Opt in with `:builder-fn` on the db context.
sourceraw docstring

current-datasourceclj

(current-datasource ctx)

Return the active JDBC executor for the current call.

Prefer a transaction-bound connection when present so transaction-scoped settings like PostgreSQL search_path remain in effect for all downstream queries.

Return the active JDBC executor for the current call.

Prefer a transaction-bound connection when present so transaction-scoped
settings like PostgreSQL `search_path` remain in effect for all downstream
queries.
sourceraw docstring

db-context?clj

Check if value is a valid database context.

Delegates to pure core function.

Check if value is a valid database context.

Delegates to pure core function.
sourceraw docstring

encode-paramsclj

(encode-params adapter [sql & params])

[sql & params] with each param as the engine takes it (BOU-648). An adapter without an encoder gets an Instant as its ISO string (BOU-655).

`[sql & params]` with each param as the engine takes it (BOU-648). An
adapter without an encoder gets an Instant as its ISO string (BOU-655).
sourceraw docstring

execute-batch!clj

(execute-batch! ctx query-maps)

Execute multiple queries in a single transaction.

Args: ctx: Database context query-maps: Vector of HoneySQL query maps

Returns: Vector of results (for SELECTs) or affected row counts (for updates)

Example: (execute-batch! ctx [{:insert-into :users :values [{:name "John"}]} {:insert-into :users :values [{:name "Jane"}]}])

Execute multiple queries in a single transaction.

Args:
  ctx: Database context
  query-maps: Vector of HoneySQL query maps

Returns:
  Vector of results (for SELECTs) or affected row counts (for updates)

Example:
  (execute-batch! ctx [{:insert-into :users :values [{:name "John"}]}
                      {:insert-into :users :values [{:name "Jane"}]}])
sourceraw docstring

execute-one!clj

(execute-one! ctx query-map)

Execute query expecting single result.

Args: ctx: Database context query-map: HoneySQL query map

Returns: Single result map or nil

Example: (execute-one! ctx {:select [:*] :from [:users] :where [:= :id "123"]})

Execute query expecting single result.

Args:
  ctx: Database context
  query-map: HoneySQL query map

Returns:
  Single result map or nil

Example:
  (execute-one! ctx {:select [:*] :from [:users] :where [:= :id "123"]})
sourceraw docstring

execute-query!clj

(execute-query! ctx query-map)

Execute SELECT query and return results.

SHELL FUNCTION: Performs database I/O and logging (side effects). Uses pure core functions for query formatting.

Args: ctx: Database context {:datasource ds :adapter adapter} query-map: HoneySQL query map

Returns: Vector of result maps

Example: (execute-query! ctx {:select [:*] :from [:users] :where [:= :active true]})

Execute SELECT query and return results.

SHELL FUNCTION: Performs database I/O and logging (side effects).
Uses pure core functions for query formatting.

Args:
  ctx: Database context {:datasource ds :adapter adapter}
  query-map: HoneySQL query map

Returns:
  Vector of result maps

Example:
  (execute-query! ctx {:select [:*] :from [:users] :where [:= :active true]})
sourceraw docstring

execute-update!clj

(execute-update! ctx query-map)

Execute UPDATE/INSERT/DELETE query.

SHELL FUNCTION: Performs database I/O and logging (side effects).

Args: ctx: Database context query-map: HoneySQL query map

Returns: Number of affected rows

Example: (execute-update! ctx {:update :users :set {:active false} :where [:= :id "123"]})

Execute UPDATE/INSERT/DELETE query.

SHELL FUNCTION: Performs database I/O and logging (side effects).

Args:
  ctx: Database context
  query-map: HoneySQL query map

Returns:
  Number of affected rows

Example:
  (execute-update! ctx {:update :users :set {:active false} :where [:= :id "123"]})
sourceraw docstring

forgetting-hooks-on-failureclj

(forgetting-hooks-on-failure f)

(f); when it throws, drop the after-commit hooks it added, as a savepoint rollback drops its writes.

`(f)`; when it throws, drop the after-commit hooks it added, as a savepoint
rollback drops its writes.
sourceraw docstring

redacted-causeclj

(redacted-cause e)
(redacted-cause e {:keys [sql-state error-code] :as reported})

e, or when the driver's message quotes the values sent, a SQLException in its place saying what redaction/redacted-message says, with the same state, code and stack. Whatever logs or reports the cause chain then reads no values (BOU-628).

`e`, or when the driver's message quotes the values sent, a SQLException in
its place saying what `redaction/redacted-message` says, with the same
state, code and stack. Whatever logs or reports the cause chain then reads
no values (BOU-628).
sourceraw docstring

remembered-in-transactionclj

(remembered-in-transaction k f)

(f), called until it answers truthy once per k for the transaction open on this thread; with none open, each time. For a catalog answer such as a table being there, which the transaction's locks keep true until it ends.

`(f)`, called until it answers truthy once per `k` for the transaction open
on this thread; with none open, each time. For a catalog answer such as a
table being there, which the transaction's locks keep true until it ends.
sourceraw docstring

reportedclj

What the driver said. See redaction/reported.

What the driver said. See `redaction/reported`.
sourceraw docstring

transaction-onclj

(transaction-on datasource)

The connection of the transaction bound on this thread when it was opened on datasource, else nil: a component holding another database's datasource must not write into it.

The connection of the transaction bound on this thread when it was opened
on `datasource`, else nil: a component holding another database's
datasource must not write into it.
sourceraw docstring

validate-adapterclj

Validate that context has a valid adapter.

Delegates to pure core function.

Validate that context has a valid adapter.

Delegates to pure core function.
sourceraw docstring

validate-contextclj

Validate database context and throw if invalid.

Delegates to pure core function.

Validate database context and throw if invalid.

Delegates to pure core function.
sourceraw docstring

with-transaction*clj

(with-transaction* ctx f)

Execute function within database transaction context.

Args: ctx: Database context f: Function that takes transaction context and returns result

Returns: Result of function execution

Example: (with-transaction* ctx (fn [tx] (execute-update! tx query)))

Execute function within database transaction context.

Args:
  ctx: Database context
  f: Function that takes transaction context and returns result

Returns:
  Result of function execution

Example:
  (with-transaction* ctx (fn [tx] (execute-update! tx query)))
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
←Move to previous article
→Move to next article
Ctrl+/Jump to the search field
× close