Class: PG::TypeMap
| Relationships & Source Files | |
| Namespace Children | |
|
Modules:
| |
| Extension / Inclusion / Inheritance Descendants | |
|
Subclasses:
|
|
| Inherits: | Object |
| Defined in: | ext/pg_type_map.c |
Overview
This is the base class for type maps.
See derived classes for implementations of different type cast strategies
( TypeMapByColumn, TypeMapByOid, etc.).
Find more type maps in the README.
Instance Method Summary
-
#query_param_encoders(params)
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)
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.
# 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;
}