The forum uses IF(condition, then, else) syntax in two places that break on PostgreSQL. However there is an equivalent CASE syntax that work on PostgreSQL and is supported on MySQL according to docs (http://dev.mysql.com/doc/refman/5.0/en/case-statement.html)
Attached is path that fixed forum tests from breaking in PostgreSQL.
1 down. 3 to go.
| Comment | File | Size | Author |
|---|---|---|---|
| fix-forum-pgsql.patch | 1.91 KB | josh waihi |
Comments
Comment #1
josh waihi commentedmarking as needs review
Comment #2
andypostWorks fine
http://www.postgresql.org/docs/8.3/static/functions-conditional.html
http://dev.mysql.com/doc/refman/5.0/en/control-flow-functions.html
http://www.sqlite.org/lang_expr.html
Comment #3
damien tournoud commentedNo objection. This said, PostgreSQL can and should also implement the IF() compatibility function, as sqlite already does.
Comment #4
andypostWe should document that using IF() is mysqlism
CASE() is ansi sql but IF() is db-specific
oracle and mssql does not support IF() syntax for DML
http://download.oracle.com/docs/cd/E11882_01/server.112/e10592/expressio...
http://msdn.microsoft.com/en-us/library/ms189074.aspx and IF() http://msdn.microsoft.com/en-us/library/ms187471.aspx
Comment #5
damien tournoud commented@andypost: the IF() function can (and IMO should) be implemented by all the Drivers. SQLite and SQL Server already do that.
Comment #6
andypost@Damien Tournoud Could you explain any reason to write a custom function instead of using the standard?
IMO any custom function implementation makes install process a bit slower. Also is there any uninstall for custom functions?
Comment #7
josh waihi commentedI'd rather avoid custom functions as much as possible. Custom functions are slower. Take the FIRST() function PostgreSQL has to use in Views 2.
Comment #8
josh waihi commentedanyway, implementing an IF() function is a different issue. This fixes forums and fixes tests. We can commit this.
Comment #9
webchickCommitted to HEAD. Thanks!
It might be worth writing up a sub-page in the developer handbook about common MySQLisms that you might not know are MySQLisms and cause Pgsql and other dbs to puke all over themselves. And probably a patch to Coder module too, to catch this kind of thing.
Comment #10
andypostA child page under http://drupal.org/node/555514 is a good place
Comment #11
andypostAdded a book page http://drupal.org/node/833126
Comment #12
josh waihi commented#833138: MySQLism: Use CASE instead of IF(). added also. Will restructure both pages.
Comment #13
damien tournoud commentedWe also have http://drupal.org/node/773090, which is an effort to document the functions and operators that *we actually support* against every database drivers. Seems like a better idea then trying to document everything we don't support.