Browse Source

fix quoting

Sven Klemm 7 năm trước cách đây
mục cha
commit
7a5b5906ed

+ 4 - 4
public/app/plugins/datasource/postgres/postgres_query.ts

@@ -37,22 +37,22 @@ export default class PostgresQuery {
   // remove identifier quoting from identifier to use in metadata queries
   unquoteIdentifier(value) {
     if (value[0] === '"' && value[value.length - 1] === '"') {
-      return value.substring(1, value.length - 1).replace('""', '"');
+      return value.substring(1, value.length - 1).replace(/""/g, '"');
     } else {
       return value;
     }
   }
 
   quoteIdentifier(value) {
-    return '"' + value.replace('"', '""') + '"';
+    return '"' + value.replace(/"/g, '""') + '"';
   }
 
   quoteLiteral(value) {
-    return "'" + value.replace("'", "''") + "'";
+    return "'" + value.replace(/'/g, "''") + "'";
   }
 
   escapeLiteral(value) {
-    return value.replace("'", "''");
+    return value.replace(/'/g, "''");
   }
 
   hasTimeGroup() {

+ 1 - 1
public/app/plugins/datasource/postgres/query_ctrl.ts

@@ -385,7 +385,7 @@ export class PostgresQueryCtrl extends QueryCtrl {
 
     if (addAlias) {
       // set initial alias name to column name
-      partModel = sqlPart.create({ type: 'alias', params: [selectParts[0].params[0].replace('"', '')] });
+      partModel = sqlPart.create({ type: 'alias', params: [selectParts[0].params[0].replace(/"/g, '')] });
       if (selectParts[selectParts.length - 1].def.type === 'alias') {
         selectParts[selectParts.length - 1] = partModel;
       } else {