Fix error while importing data to a table using Import/Export dialog and providing Not null columns option. Fixes #4461.

This commit is contained in:
Aditya Toshniwal 2019-09-03 11:19:33 +05:30 committed by Akshay Joshi
parent a0f6e5272a
commit 04357b7a55
3 changed files with 5 additions and 8 deletions

View File

@ -32,6 +32,7 @@ Bug fixes
| `Issue #3936 <https://redmine.postgresql.org/issues/3936>`_ - Further code refactoring to stabilise the Feature Tests.
| `Issue #4381 <https://redmine.postgresql.org/issues/4381>`_ - Fix an issue where oid column should not be pasted when copy/paste row is used on query output containing the oid column.
| `Issue #4419 <https://redmine.postgresql.org/issues/4419>`_ - Fix a debugger error when using Python 2.7.
| `Issue #4461 <https://redmine.postgresql.org/issues/4461>`_ - Fix error while importing data to a table using Import/Export dialog and providing "Not null columns" option.
| `Issue #4486 <https://redmine.postgresql.org/issues/4486>`_ - Ensure View should be created with special characters.
| `Issue #4487 <https://redmine.postgresql.org/issues/4487>`_ - Ensure Boolean columns should be editable in View/Edit data and Query Tool.
| `Issue #4577 <https://redmine.postgresql.org/issues/4577>`_ - Fix an error that could be seen when click on any system column of a table.

View File

@ -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

View File

@ -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 %};