View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0011963 | mantisbt | db postgresql | public | 2010-05-28 01:28 | 2014-05-16 15:02 |
Reporter | gerald2545 | Assigned To | dregad | ||
Priority | normal | Severity | crash | Reproducibility | always |
Status | closed | Resolution | duplicate | ||
Product Version | 1.2.1 | ||||
Summary | 0011963: error filtering with a custom field of type Date | ||||
Description | I added a custom field of type Date ("Realisation date") and linked it to all my projects (postgresql 8.1, mantis 1.1.6). I created a bug and assigned a date to "Realisation date" then upgraded mantis to 1.2.1....but the problem is still there... Am I doing something wrong or do you think it's a bug? I search for such an error in the bugtracker of mantis, but didn't found the same problem. I know how I can solve this issue by editing the mantis/core/filter_api.php and deleting all occurences of "+0" (it solved the problem in 1.1.6)... Do you know what is the purpose of this "+0"? | ||||
Additional Information | source code of core/filter_apip.php to modify to solve this issue (with my installation) : if( $t_def['type'] == CUSTOM_FIELD_TYPE_DATE ) { | ||||
Tags | No tags attached. | ||||
I think this may have been an attempt at casting the string value to a number for the data comparison that isn't compatible with all databases. Is there any progress on getting this fixed so that the code is more database independent? For now, I simply replaced all of those +0 occurrences with the SQL standard CAST (field AS type) syntax to do the cast correctly. |
|
I think you're correct, it's using implicit type conversion to convert the string value stored in the DB table, to a number. This works on MySQL and Oracle for sure. I do not have access to a PostgreSQL environment to test. The problem with CAST is that while the function itself is standard SQL and available on all supported platforms, AFAIK the data types are different in each RDBMS. MySQL: SIGNED, UNSIGNED And if you use the wrong type, you get a syntax error. So the function is not as portable as it should be, and using it would force to write RDBMS-specific code. EDIT: implicit conversion works also on MSSQL (just tested). What happens on PostgreSQL if you execute SELECT '1' + 0 ? |
|
It gives the error as in the description of this issue: Since version 8.3 Postgres has had stricter type checking which prohibits this sort of cast. It also applies to type comparisons. Why not do something like db_prepare_string for this that then casts to any known data type depending on the DB being used? |
|
Because if you convert the date to a string, then the date values would then be compared in lexicographical instead of numeric. In any case I think you are right, the only way would be to make this code RDBMS-specific. |
|
Same issue is described in 0011279, so I'm marking this resolved/duplicate. |
|
MantisBT currently supports Mysql and has support for other database engines. The support for other databases is known to be problematic. Having implemented the current database layer into Mantis 10 years ago, I'm currently working on replacing the current layer. If you are interested in using Mantis with non-mysql databases - for example, Oracle, PGSQL or MSSQL, and would be willing to help out testing the new database layer, please drop me an email at paul@mantisforge.org In the meantime, I'd advise running Mantis with Mysql Only to avoid issues. Thanks |
|