View Issue Details

IDProjectCategoryView StatusLast Update
0007185mantisbtdb oraclepublic2014-12-08 00:34
ReportermechantflouAssigned Todregad 
PrioritynormalSeveritycrashReproducibilityalways
Status closedResolutionfixed 
Product Version1.0.3 
Target Version1.3.0-beta.1Fixed in Version1.3.0-beta.1 
Summary0007185: Empty string incompatibility mysql/oracle
Description

In MySql, an empty string is ''
in Oracle... An empty string in is NULL.

This problem crash bug filter, it doesn't work with oracle.
Consequently, I propose this function for this file database_api.php

function empty_string( $p_field){
$t_db_type = config_get( 'db_type' );

    switch( $t_db_type ) {
        case 'mssql':
        case 'odbc_mssql':
        case 'mysql':
        case 'mysqli':
        case 'postgres':
        case 'postgres64':
        case 'postgres7':
        case 'pgsql':
                    case 'mysql':
        return "$p_field=''";
        case 'oci8':
        return "$p_field IS NULL";

        default:
            error_parameters( 'db_type', $t_db_type );
            trigger_error( ERROR_CONFIG_OPT_INVALID, ERROR );
}
}

then filter_api.php for exemple in the query:

$query = "DELETE FROM $t_filters_table
WHERE project_id<='$t_all_id'
AND ".empty_string('name');
I let the complete file fixed here

TagsNo tags attached.

Relationships

child of 0013227 closeddregad Oracle DB support multiple issues 

Activities

2006-06-09 09:36

 

filter_api.zip (20,402 bytes)

2006-06-09 10:22

 

[new]filter_api.zip (20,475 bytes)
mechantflou

mechantflou

2006-06-09 10:24

reporter   ~0012951

filter_api.zip [^] (20,402 bytes) 06-09-06 09:36 is wrong!!!
please check this one
[new]filter_api.zip [^] (20,475 bytes) 06-09-06 10:22

now, bug filter run correctly with oracle (driver oci8)

mechantflou

mechantflou

2006-06-09 10:45

reporter   ~0012952

function for this file database_api.php

function empty_string( $p_field,$p_bool){
$t_db_type = config_get( 'db_type' );

    switch( $t_db_type ) {
        case 'mssql':
        case 'odbc_mssql':
        case 'mysql':
        case 'mysqli':
        case 'postgres':
        case 'postgres64':
        case 'postgres7':
        case 'pgsql':
        if ($p_bool)
        return "$p_field=''";
        else
        return "$p_field!=''";
        case 'oci8':
        if ($p_bool)
        return "$p_field IS NULL";
        else
        return "$p_field IS NOT NULL";

        default:
            error_parameters( 'db_type', $t_db_type );
            trigger_error( ERROR_CONFIG_OPT_INVALID, ERROR );
}
}

and for exemple in the file filer_api.php

$query = "SELECT id FROM $t_filters_table
WHERE user_id='$t_user_id'
AND project_id='$c_project_id'
AND ".empty_string('name',true);

Or
$query = "SELECT * FROM $t_filters_table
WHERE (project_id='$t_project_id'
OR project_id='0')
AND ".empty_string('name',false)."
ORDER BY is_public DESC, name ASC";

2006-06-09 10:45

 

[new with not empty string ]filter_api.zip (20,478 bytes)
dregad

dregad

2011-09-09 12:36

developer   ~0029672

Would you have a chance to test if problem still exists using oracle branch in 0013227 (https://github.com/dregad/mantisbt/commits/oracle), and submit a revised patch/pull request against that if it's the case ?

Issue History

Date Modified Username Field Change
2006-06-09 09:34 mechantflou New Issue
2006-06-09 09:36 mechantflou File Added: filter_api.zip
2006-06-09 10:22 mechantflou File Added: [new]filter_api.zip
2006-06-09 10:24 mechantflou Note Added: 0012951
2006-06-09 10:45 mechantflou Note Added: 0012952
2006-06-09 10:45 mechantflou File Added: [new with not empty string ]filter_api.zip
2011-09-09 12:36 dregad Note Added: 0029672
2011-09-09 12:37 dregad Relationship added child of 0013227
2013-10-17 12:50 dregad Status new => resolved
2013-10-17 12:50 dregad Fixed in Version => 1.3.0-beta.1
2013-10-17 12:50 dregad Resolution open => fixed
2013-10-17 12:50 dregad Assigned To => dregad
2013-10-17 12:51 dregad Target Version => 1.3.0-beta.1
2014-04-12 19:39 grangeway Issue cloned: 0017211
2014-12-08 00:34 vboctor Status resolved => closed