View Issue Details

IDProjectCategoryView StatusLast Update
0007185mantisbtdb oraclepublic2014-12-08 00:34
Reportermechantflou Assigned 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.
Attached Files
filter_api.zip (20,402 bytes)
[new]filter_api.zip (20,475 bytes)

Relationships

child of 0013227 closeddregad Oracle DB support multiple issues 

Activities

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";

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 ?