class Jennifer::Postgres::Adapter

Included Modules

Defined in:

jennifer/adapter/postgres.cr

Constant Summary

DEFAULT_SIZES = {:string => 254}
TABLE_LOCK_TYPES = {"as" => "ACCESS SHARE", "rs" => "ROW SHARE", "re" => "ROW EXCLUSIVE", "sue" => "SHARE UPDATE EXCLUSIVE", "s" => "SHARE", "sre" => "SHARE ROW EXCLUSIVE", "e" => "EXCLUSIVE", "ae" => "ACCESS EXCLUSIVE", "default" => "SHARE"}
TYPE_TRANSLATIONS = {:bool => "boolean", :integer => "int", :short => "SMALLINT", :bigint => "BIGINT", :oid => "oid", :float => "real", :double => "double precision", :numeric => "numeric", :decimal => "decimal", :string => "varchar", :char => "char", :text => "text", :varchar => "varchar", :blchar => "blchar", :uuid => "uuid", :timestamp => "timestamp", :timestamptz => "timestamptz", :date_time => "timestamp", :date => "date", :bytea => "bytea", :json => "json", :jsonb => "jsonb", :xml => "xml", :point => "point", :lseg => "lseg", :path => "path", :box => "box", :polygon => "polygon", :line => "line", :circle => "circle"}

Class Method Summary

Instance Method Summary

Instance methods inherited from module Jennifer::Adapter::RequestMethods

insert(table, opts : Hash)
insert(obj : Model::Base)
insert
, modify(q, modifications : Hash) modify, pluck(query, fields : Array)
pluck(query, field : String | Symbol)
pluck
, select(q, &) select, update(query, options : Hash)
update(obj : Model::Base)
update

Instance methods inherited from class Jennifer::Adapter::Base

bulk_insert(table : String, fields : Array(String), values : Array(ArgsType))
bulk_insert(collection : Array(Model::Base))
bulk_insert
, column_exists?(table, name) column_exists?, command_interface command_interface, config : Config config, connection_string(type : ConnectionType) connection_string, count(query : QueryBuilder::Query) count, create_database create_database, database_exists? database_exists?, db : DB::Database db, db_connection(&) db_connection, default_type_size(name) default_type_size, delete(query : QueryBuilder::Query) delete, drop_database drop_database, exec(query : String, args : ArgsType = [] of DBAny) : DB::ExecResult exec, exists?(query : QueryBuilder::Query) : Bool exists?, explain(q) explain, foreign_key_exists?(from_table, to_table = nil, column = nil, name : String? = nil) : Bool foreign_key_exists?, generate_schema generate_schema, index_exists?(table, fields : Array)
index_exists?(table, name : String)
index_exists?
, insert(obj : Model::Base) insert, load_schema load_schema, log_query(query : String, args : Enumerable, &)
log_query(query : String, &)
log_query
, max_bind_vars_count max_bind_vars_count, parse_query(q : String, args : ArgsType)
parse_query(q : String)
parse_query
, prepare prepare, query(query : String, args : ArgsType = [] of DBAny, &) query, query_array(_query : String, klass : T.class, field_count : Int32 = 1) forall T query_array, ready_to_migrate! ready_to_migrate!, refresh_materialized_view(name) refresh_materialized_view, scalar(query : String, args : ArgsType = [] of DBAny) scalar, schema_processor schema_processor, sql_generator sql_generator, table_column_count(table) table_column_count, table_exists?(table) table_exists?, tables_column_count(tables : Array(String)) tables_column_count, translate_type(name) translate_type, truncate(klass : Class)
truncate(table_name : String)
truncate
, upsert(table : String, fields : Array(String), values : Array(ArgsType), unique_fields : Array, on_conflict : Hash)
upsert(collection : Array(Model::Base), unique_fields : Array, definition : Hash = {} of Nil => Nil)
upsert
, view_exists?(name) : Bool view_exists?, with_table_lock(table : String, type : String = "default", &block : DB::Transaction -> Void) with_table_lock

Constructor methods inherited from class Jennifer::Adapter::Base

new(config : Config) new

Class methods inherited from class Jennifer::Adapter::Base

foreign_key_name(from_table, to_table = nil, column = nil, name : String? = nil) : String foreign_key_name, join_table_name(table1 : String | Symbol, table2 : String | Symbol) join_table_name, t(field : Nil)
t(field : String)
t(field)
t

Instance methods inherited from module Jennifer::Adapter::ResultParsers

read_column(rs, column) read_column, result_to_array_by_names(rs, names : Array(String)) result_to_array_by_names, result_to_hash(rs) result_to_hash

Instance methods inherited from module Jennifer::Adapter::Transactions

begin_transaction begin_transaction, current_transaction current_transaction, rollback_transaction rollback_transaction, subscribe_on_commit(block : -> Bool) subscribe_on_commit, subscribe_on_rollback(block : -> Bool) subscribe_on_rollback, transaction(&) transaction, under_transaction? under_transaction?, with_connection(&) with_connection, with_manual_connection(&) with_manual_connection

Class Method Detail

def self.default_max_bind_vars_count #

[View source]
def self.protocol : String #

[View source]

Instance Method Detail

def column_exists?(table, name) #
Description copied from class Jennifer::Adapter::Base

Returns whether column of table with name exists.

# Check a column exists
column_exists?(:suppliers, :name)

[View source]
def command_interface #

[View source]
def default_type_size(name) #

[View source]
def enum_exists?(name) #

[View source]
def enum_values(name) #

[View source]
def exists?(query) : Bool #

[View source]
def explain(q) #

[View source]
def foreign_key_exists?(from_table, to_table = nil, column = nil, name : String? = nil) : Bool #
Description copied from class Jennifer::Adapter::Base

Checks to see if a foreign key exists on a table for a given foreign key definition.

# Checks to see if a foreign key exists.
adapter.foreign_key_exists?(:accounts, :branches)

# Checks to see if a foreign key on a specified column exists.
adapter.foreign_key_exists?(:accounts, column: :owner_id)

# Checks to see if a foreign key with a custom name exists.
adapter.foreign_key_exists?(:accounts, name: "special_fk_name")

[View source]
def index_exists?(_table, name : String) #

[View source]
def insert(obj : Model::Base) #

[View source]
def material_view_exists?(name) #

[View source]
def refresh_materialized_view(name) #

[View source]
def schema_processor #

[View source]
def sql_generator #

[View source]
def table_column_count(table) #

[View source]
def table_exists?(table) #
Description copied from class Jennifer::Adapter::Base

Returns where table with given table name exists.

adapter.table_exists?(:developers)

[View source]
def tables_column_count(tables : Array(String)) #

[View source]
def translate_type(name) #
Description copied from class Jennifer::Adapter::Base

Translates symbol data type name to database-specific data type.


[View source]
def view_exists?(name) : Bool #
Description copied from class Jennifer::Adapter::Base

Check whether view with given name exists.

adapter.view_exists?(:youth_contacts)

[View source]
def with_table_lock(table : String, type : String = "default", &block : DB::Transaction -> Void) #

[View source]