module CQL::Executable

Overview

Runs a statement that renders to {sql, params}. Result caching, performance tracking and connection handling live here once, for every query type that can be executed.

Included Modules

Direct including types

Defined in:

executable.cr

Instance Method Summary

Instance methods inherited from module CQL::Pinnable

executor : Executor executor, schema : Schema schema, using(connection : DB::Connection) : self
using(executor : Executor) : self
using

Instance Method Detail

def all(as kind) #

All rows, each mapped to kind.


[View source]
def all!(as kind) #

[View source]
abstract def build : Expression::Statement #

[View source]
def each(as kind : U.class, & : U -> ) : Nil forall U #

Yields each row mapped to kind. The rows are read first and the connection released before the block runs, so the block may run other queries; use find_each for large results.


[View source]
def explain(analyze : Bool = false) : String #

The database's execution plan for this statement, one line per plan row. With analyze: true the statement is actually run and timed.


[View source]
def get(as kind) #

The first row (or scalar) mapped to kind, nil when there is none.


[View source]
def get!(as kind) #

Like #get, but raises DB::NoResultsError when there is no row.


[View source]
def returns_rows?(count : Int32) : Bool #

Whether the statement returns at least count rows. Steps through at most count rows without reading a column, so nothing is decoded.


[View source]
def to_sql(gen : Expression::Generator | Nil = nil) #

The SQL text and its bound parameters, rendered for the schema's dialect (or by the given generator).


[View source]
def to_sql(for adapter : Adapter) #

Renders for another dialect without needing a connection to it.


[View source]