Hi,

PFA patch to fix the issue in import/export module where,
1) Command was failing due to incorrect tab delimiter passed to the copy
command.
2) User was not allowed to pass default delimiter(ie - no delimiter, let
copy command handle it) for csv & text file format user was forced to
select delimiter.
RM#1934

--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
diff --git 
a/web/pgadmin/tools/import_export/templates/import_export/js/import_export.js 
b/web/pgadmin/tools/import_export/templates/import_export/js/import_export.js
index a8eac3c..8eebac5 100644
--- 
a/web/pgadmin/tools/import_export/templates/import_export/js/import_export.js
+++ 
b/web/pgadmin/tools/import_export/templates/import_export/js/import_export.js
@@ -23,7 +23,7 @@ define([
       encoding: undefined,
       oid: undefined,
       header: undefined,
-      delimiter: ';',
+      delimiter: '',
       quote: '\"',
       escape: '\'',
       null_string: undefined,
@@ -490,8 +490,8 @@ define([
                 this.view.model.on('change', function() {
                     if (!_.isUndefined(this.get('filename')) && 
this.get('filename') !== '') {
                       this.errorModel.clear();
-                      if (!_.isUndefined(this.get('delimiter')) && 
this.get('delimiter') !== '' &&
-                          (this.get('delimiter').length == 1 || 
this.get('delimiter') == '[tab]')) {
+                      if (!_.isUndefined(this.get('delimiter')) && 
!_.isNull(this.get('delimiter'))
+                      ) {
                         this.errorModel.clear();
                         if (!_.isUndefined(this.get('quote')) && 
this.get('quote') !== '' &&
                             this.get('quote').length == 1) {
diff --git 
a/web/pgadmin/tools/import_export/templates/import_export/sql/cmd.sql 
b/web/pgadmin/tools/import_export/templates/import_export/sql/cmd.sql
index 16de8c5..4936d65 100644
--- a/web/pgadmin/tools/import_export/templates/import_export/sql/cmd.sql
+++ b/web/pgadmin/tools/import_export/templates/import_export/sql/cmd.sql
@@ -1 +1 @@
-\copy {{ conn|qtIdent(data.schema, data.table) }} {% if columns %} {{ columns 
}} {% endif %} {% if data.is_import %}FROM{% else %}TO{% endif %} {{ 
data.filename|qtLiteral }} {% if data.oid %} OIDS {% endif %}{% if 
data.delimiter and data.format != 'binary' and data.delimiter == '[tab]' %} 
DELIMITER E'\\t' {% elif data.format != 'binary' and data.delimiter %} 
DELIMITER {{ data.delimiter|qtLiteral }}{% endif %}{% if data.format == 'csv' 
%} CSV {% endif %} {% if data.header %} HEADER {% endif %}{% if data.encoding 
%} ENCODING {{ data.encoding|qtLiteral }}{% endif %}{% if data.format == 'csv' 
and data.quote %} QUOTE {{ data.quote|qtLiteral }}{% endif %}{% if data.format 
!= 'binary' and data.null_string %} NULL {{ data.null_string|qtLiteral }}{% 
endif %}{% if data.format == 'csv' and data.escape %} ESCAPE {{ 
data.escape|qtLiteral }}{% endif %}{% if data.format == 'csv' and 
data.is_import and ignore_column_list %} FORCE_NOT_NULL {{ ignore_column_list 
}} {% endif %};
+\copy {{ conn|qtIdent(data.schema, data.table) }} {% if columns %} {{ columns 
}} {% endif %} {% if data.is_import %}FROM{% else %}TO{% endif %} {{ 
data.filename|qtLiteral }} {% if data.oid %} OIDS {% endif %}{% if 
data.delimiter is defined and data.delimiter == '' and (data.format == 'csv' or 
data.format == 'text') %} {% elif data.delimiter and data.format != 'binary' 
and data.delimiter == '[tab]' %} DELIMITER E'\t' {% elif data.format != 
'binary' and data.delimiter %} DELIMITER {{ data.delimiter|qtLiteral }}{% endif 
%}{% if data.format == 'csv' %} CSV {% endif %} {% if data.header %} HEADER {% 
endif %}{% if data.encoding %} ENCODING {{ data.encoding|qtLiteral }}{% endif 
%}{% if data.format == 'csv' and data.quote %} QUOTE {{ data.quote|qtLiteral 
}}{% endif %}{% if data.format != 'binary' and data.null_string %} NULL {{ 
data.null_string|qtLiteral }}{% endif %}{% if data.format == 'csv' and 
data.escape %} ESCAPE {{ data.escape|qtLiteral }}{% endif %}{% if data.format 
== 'csv' and data.is_import and ignore_column_list %} FORCE_NOT_NULL {{ 
ignore_column_list }} {% endif %};

Reply via email to