class PG::TypeMap
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.
Public Instance Methods
query_param_encoders(params)
click to toggle source
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.
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;
}