View Issue Details

IDProjectCategoryView StatusLast Update
0007190mantisbtdb oraclepublic2014-12-08 00:34
Reportermechantflou Assigned Todregad  
PrioritynormalSeveritycrashReproducibilityalways
Status closedResolutionfixed 
Target Version1.3.0-beta.1Fixed in Version1.3.0-beta.1 
Summary0007190: error in filter_api with date filter
Description

this query doesn't work in oracle

SELECT DISTINCT m_bug_tbl.id as id, FROM m_project_tbl, m_bug_tbl
WHERE m_project_tbl.enabled = 1 AND m_project_tbl.id = m_bug_tbl.project_id AND m_bug_tbl.date_submitted BETWEEN '2006-2-1 00:00:00' AND '2006-4-12 23:59:59'

first, I've added a new function in database_api.php

function db_prepare_date( $p_date)
{
$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':
        return '$p_date';
        case 'oci8':
        return "TO_TIMESTAMP('$p_date','YYYY-MM-DD HH24:MI:SS')";
}
}

then I've modified at the line 520 in filter_api.php
array_push( $t_where_clauses, "($t_bug_table.date_submitted BETWEEN ".db_prepare_date($t_start_string)." AND ".db_prepare_date($t_end_string)." )" );

With all change, date filter can work with oracle

TagsNo tags attached.

Relationships

has duplicate 0007191 closedryandesign error in filter_api with date filter 
related to 0013227 closeddregad Oracle DB support multiple issues 

Activities

chillax

chillax

2006-06-12 18:42

developer   ~0012958

The function above won't work for non-oci8 due to the quotes around $p_date in the return line. It would send back a string of '$p_date' instead of the value.

This function would be better expressed as:

function db_prepare_date( $p_date) {
$t_db_type = config_get( 'db_type' );

if ( $t_db_type == 'oci8' ) {
return "TO_TIMESTAMP('$p_date','YYYY-MM-DD HH24:MI:SS')";
} else {
return $p_date;
}
}

dregad

dregad

2011-09-09 12:38

developer   ~0029673

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 ?