abstract class Jennifer::Adapter::Base
- Jennifer::Adapter::Base
- Reference
- Object
Included Modules
Extended Modules
Direct Known Subclasses
Defined in:
jennifer/adapter/base.crConstructors
Class Method Summary
-
.foreign_key_name(from_table, to_table = nil, column = nil, name : String? = nil) : String
Generates foreign key name for given tables.
-
.join_table_name(table1 : String | Symbol, table2 : String | Symbol)
Generates name for join table.
-
.t(field : Nil)
filter out value; should be refactored
- .t(field : String)
- .t(field)
Instance Method Summary
- #bulk_insert(table : String, fields : Array(String), values : Array(ArgsType))
- #bulk_insert(collection : Array(Model::Base))
-
#column_exists?(table, name)
Returns whether column of table with name exists.
- #command_interface
- #config : Config
- #connection_string(type : ConnectionType)
- #count(query : QueryBuilder::Query)
- #create_database
- #database_exists?
- #db : DB::Database
-
#db_connection(&)
Yields to block connection to the database main schema.
- #default_type_size(name)
- #delete(query : QueryBuilder::Query)
- #drop_database
- #exec(query : String, args : ArgsType = [] of DBAny) : DB::ExecResult
- #exists?(query : QueryBuilder::Query) : Bool
- #explain(q)
-
#foreign_key_exists?(from_table, to_table = nil, column = nil, name : String? = nil) : Bool
Checks to see if a foreign key exists on a table for a given foreign key definition.
- #generate_schema
-
#index_exists?(table, fields : Array)
Returns whether index for the *table` with name or fields exists.
- #index_exists?(table, name : String)
- #insert(obj : Model::Base)
- #load_schema
- #log_query(query : String, args : Enumerable, &)
- #log_query(query : String, &)
- #max_bind_vars_count
- #parse_query(q : String, args : ArgsType)
- #parse_query(q : String)
- #prepare
- #query(query : String, args : ArgsType = [] of DBAny, &)
- #query_array(_query : String, klass : T.class, field_count : Int32 = 1) forall T
- #ready_to_migrate!
- #refresh_materialized_view(name)
- #scalar(query : String, args : ArgsType = [] of DBAny)
- #schema_processor
- #sql_generator
- #table_column_count(table)
-
#table_exists?(table)
Returns where table with given table name exists.
- #tables_column_count(tables : Array(String))
-
#translate_type(name)
Translates symbol data type name to database-specific data type.
- #truncate(klass : Class)
- #truncate(table_name : String)
- #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)
-
#view_exists?(name) : Bool
Check whether view with given name exists.
- #with_table_lock(table : String, type : String = "default", &block : DB::Transaction -> Void)
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
Constructor Detail
Class Method Detail
Generates foreign key name for given tables.
Generates name for join table.
Instance Method Detail
Returns whether column of table with name exists.
# Check a column exists
column_exists?(:suppliers, :name)
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")
Returns whether index for the *table` with name or fields exists.
# Check an index exists
adapter.index_exists?(:suppliers, :company_id)
# Check an index on multiple columns exists
adapter.index_exists?(:suppliers, [:company_id, :company_type])
# Check an index with a custom name exists
adapter.index_exists?(:suppliers, "idx_company_id")
Returns where table with given table name exists.
adapter.table_exists?(:developers)
Translates symbol data type name to database-specific data type.
Check whether view with given name exists.
adapter.view_exists?(:youth_contacts)