[pgAdmin][RM4461] FORCE_NOT_NULL syntax error

Aditya Toshniwal <[email protected]>
Newsgroups gmane.comp.db.postgresql.pgadmin.devel
Message-ID <CAM9w-_n0iv5cjLPvY=X=UUvTUJiJB4v1_1T+y9m+BBwybUB7OQ@mail.gmail.com>
Hi Hackers,

Attached is the patch to fix a small error while importing data to a table
using Import/Export dialog and providing "Not null columns" option.
Kindly review.
-- 
Thanks and Regards,
Aditya Toshniwal
Software Engineer | EnterpriseDB India | Pune
"Don't Complain about Heat, Plant a TREE"
RM4461.patch (application/octet-stream, 3.3 KB)
diff --git a/web/pgadmin/tools/import_export/__init__.py b/web/pgadmin/tools/import_export/__init__.py
index d116b6e4..19d1436a 100644
--- a/web/pgadmin/tools/import_export/__init__.py
+++ b/web/pgadmin/tools/import_export/__init__.py
@@ -272,13 +272,9 @@ def create_import_export_job(sid):
         # format the ignore column list required as per copy command
         # requirement
         if ignore_cols and len(ignore_cols) > 0:
-            for col in ignore_cols:
-                if icols:
-                    icols += ', '
-                else:
-                    icols = '('
-                icols += driver.qtIdent(conn, col)
-            icols += ')'
+            icols = ", ".join([
+                driver.qtIdent(conn, col)
+                for col in ignore_cols])
 
     # format the column import/export list required as per copy command
     # requirement
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 4936d651..16448ec1 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 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 %};
+\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 %};
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.