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
Description

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.

Activities

cproensa

cproensa

2016-12-07 04:06

developer   ~0054710

@dregad maybe you know better what was done here:

<pre>
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;
}
}
}
</pre>

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
https://github.com/mantisbt/mantisbt/commit/29f85ad23dfe565b175a8dd1d8fbe84ab8f20473

I don't know the handling in mssql dirvers, as i cant test, but do you think this would be valid?
<pre>
if( isbool( $p_arr_parms[$i] ) ) {
$p_arr_parms[$i] = $p_arr_parms[$i] ? $g_db->true : $g_db->false;
}
</pre>
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.