Class: PG::TypeMap
- Inherits:
-
Object
- Object
- PG::TypeMap
- Defined in:
- ext/pg_type_map.c,
ext/pg_type_map.c
Overview
This is the base class for type maps. See derived classes for implementations of different type cast strategies ( PG::TypeMapByColumn, PG::TypeMapByOid, etc.).
Find more type maps in the README.
Direct Known Subclasses
TypeMapAllStrings, TypeMapByClass, TypeMapByColumn, TypeMapByMriType, TypeMapByOid, TypeMapInRuby
Defined Under Namespace
Modules: DefaultTypeMappable
Instance Method Summary collapse
-
#query_param_encoders(params) ⇒ Object
Retrieve the encoders that are used to encode the given values to be submitted to the database server.
Instance Method Details
#query_param_encoders(params) ⇒ Object
Retrieve the encoders that are used to encode the given values to be submitted to the database server. The selection of the encoders is defined in the derived type map class.
params must be an Array of values to be encoded.
It's like params given to exec_params .
Returns an Array with the same length as params.
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
# File 'ext/pg_type_map.c', line 131
static VALUE
pg_typemap_query_param_encoders( VALUE self, VALUE params )
{
t_typemap *this = RTYPEDDATA_DATA( self );
int nParams;
int i=0;
VALUE res;
Check_Type(params, T_ARRAY);
this->funcs.fit_to_query( self, params );
nParams = RARRAY_LENINT(params);
res = rb_ary_new2(nParams);
for ( i = 0; i < nParams; i++ ) {
t_pg_coder *conv;
VALUE param_value = rb_ary_entry(params, i);
/* Let the given typemap select a coder for this param */
conv = this->funcs.typecast_query_param(this, param_value, i);
rb_ary_push(res, conv ? conv->coder_obj : Qnil);
}
return res;
}
|