Forum

concat function doe...
 
Notifications
Retirer tout

concat function doesn’t exist in PostgreSQL under 9.1

3 Posts
2 Utilisateurs
0 Reactions
21.2 K Vu
(@stephane-clerambault)
Posts: 5
Active Member
Début du sujet
 
[#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;
                  }

 
Posté : 27 Nov PM 16:1111
(@babynus)
Posts: 14952
Membre 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.


 
Posté : 27 Nov PM 17:1111
(@stephane-clerambault)
Posts: 5
Active Member
Début du sujet
 

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!


 
Posté : 27 Nov PM 18:1111
Share:
Retour en haut