Forum

Welcome to ProjeQtOr new Forum. We migrated old forum to the new website.
You will find all your posts here, with your usual account.
Just one point : you’ll have to reinitialize your password. Use “Lost password” feature.

concat function doe...
 
Notifications
Clear all

concat function doesn’t exist in PostgreSQL under 9.1

3 Posts
2 Users
0 Reactions
21.2 K Views
(@stephane-clerambault)
Posts: 5
Active Member
Topic starter
 
[#827]

Hello,

I recently installed Project’Or RIA on debian Squeeze with nginx Web server under postgreSQL 8.4 database. I found some problems in jsonQuery.php because concat function is not declared in this Postgres version.
The concat SQL function is defined for PostgreSQL version >= 9.1.

I patch this file but I don’t know if it is still compatible with MySQL. I don’t know either if you plan to be compatible with this version of Postgres but it can be usefull for other people.

--- a/tool/jsonQuery.php  2012-11-25 21:42:02.000000000 +0100
+++ b/tool/jsonQuery.php  2012-11-26 16:23:46.000000000 +0100
@@ -238,19 +238,19 @@
                  $externalTable = $externalObj->getDatabaseTableName();
                  $externalTableAlias = 'T' . $idTab;
                  if (Sql::isPgsql()) {
-                       $querySelect .= 'concat(';
+                       $querySelect .= '';
                  } else {
                    $querySelect .= 'convert(concat(';
                  }
                  if (property_exists($externalObj,'sortOrder')) {
                    $querySelect .= $externalTableAlias . '.' . $externalObj->getDatabaseColumnName('sortOrder');
-                   $querySelect .=  ",'#split#',";
+                   $querySelect .=  "|| '#split#' ||";
                  }
                  $querySelect .= $externalTableAlias . '.' . $externalObj->getDatabaseColumnName('name');
-                 $querySelect .=  ",'#split#',";
+                 $querySelect .=  "|| '#split#' || ";
                  $querySelect .= $externalTableAlias . '.' . $externalObj->getDatabaseColumnName('color');
                  if (Sql::isPgsql()) {
-                   $querySelect .= ') as "' . $fld .'"';
+                   $querySelect .= ' as "' . $fld .'"';
                  } else {
                    $querySelect .= ') using utf8) as ' . $fld;
                  }

 
Posted : 27 Nov 2012 16H53
babynus
(@babynus)
Posts: 14966
Main Contributor Admin
 

Thanks for pointing out this issue and proposing solution.

Unfortunately ||is not MySql compliant.

I'll look for a workaround dealing with db type to be both compatible.


 
Posted : 27 Nov 2012 17H16
(@stephane-clerambault)
Posts: 5
Active Member
Topic starter
 

Is it possible to use if (Sql::isPgsql()) test and a $concatOperator variable set with the right value, '||' for postgres request and ',' for others?

I’am not familiar with php, so it’s just a suggestion!


 
Posted : 27 Nov 2012 18H38
Share:

Scroll to Top