View Issue Details

IDProjectCategoryView StatusLast Update
0022019mantisbtdb postgresqlpublic2016-12-07 08:01
Reportercproensa Assigned To 
PrioritynormalSeverityminorReproducibilityhave not tried
Status newResolutionopen 
Product Version1.3.4 
Summary0022019: Postgres query parameters are treated inconsistently for boolean types

With pgsql, the bound parameters that are passed with a query are processssed inconsistently for boolean types
This produces that they are passed to execution as:
false is passed as 0 (int)
true is passed as true (bool)

currently, both forms works, as both are recognised by the driver

TagsNo tags attached.




2016-12-07 04:06

developer   ~0054710

@dregad maybe you know better what was done here:

if( !empty( $p_arr_parms ) && $s_check_params ) {
$t_params = count( $p_arr_parms );
for( $i = 0;$i < $t_params;$i++ ) {
if( $p_arr_parms[$i] === false ) {
$p_arr_parms[$i] = 0;
} elseif( $p_arr_parms[$i] === true && $t_db_type == 'mssqlnative' ) {
$p_arr_parms[$i] = 1;

As i see it:
Previously, only value subtituted was boolean false for "db_is_pgsql() || config_get_global( 'db_type' ) == 'odbc_mssql' "
This is beacuse false seems to be mapped to '' by the low level api functions (by casting to string)
Introduced in 403db3c8fca56ca4fbabff2ea7112f39eb097ccb

later mssqlnative was added, and cast (bool)true to (int)1 only for this driver

I don't know the handling in mssql dirvers, as i cant test, but do you think this would be valid?
if( isbool( $p_arr_parms[$i] ) ) {
$p_arr_parms[$i] = $p_arr_parms[$i] ? $g_db->true : $g_db->false;
This would unload the responsibility of mapping bool values to ADOdb, the same way it maps the L field-type to the underlying db types.