Fixed an issue in SQL generation for PostgreSQL-14 functions. Fixes #7081

This commit is contained in:
Yogesh Mahajan 2021-12-31 14:30:53 +05:30 committed by Akshay Joshi
parent 19016c3733
commit 44ab4648a8
2 changed files with 4 additions and 3 deletions

View File

@ -24,4 +24,5 @@ Bug fixes
| `Issue #7075 <https://redmine.postgresql.org/issues/7075>`_ - Ensure that help should be visible properly for Procedures.
| `Issue #7077 <https://redmine.postgresql.org/issues/7077>`_ - Fixed an issue where the Owner is not displayed in the reverse engineering SQL for Procedures.
| `Issue #7078 <https://redmine.postgresql.org/issues/7078>`_ - Fixed an issue where an operation error message pop up showing the database object's name incorrectly.
| `Issue #7081 <https://redmine.postgresql.org/issues/7081>`_ - Fixed an issue in SQL generation for PostgreSQL-14 functions.
| `Issue #7096 <https://redmine.postgresql.org/issues/7096>`_ - Ensure that Truncate and Reset statistics should work.

View File

@ -1455,7 +1455,7 @@ class FunctionView(PGChildNodeView, DataTypeReader, SchemaDiffObjectCompare):
else:
FunctionView._merge_variables(data)
self._format_prosrc_for_pure_sql(data, False)
self._format_prosrc_for_pure_sql(data, False, old_data['lanname'])
if allow_code_formatting:
self.reformat_prosrc_code(data)
@ -1466,7 +1466,7 @@ class FunctionView(PGChildNodeView, DataTypeReader, SchemaDiffObjectCompare):
)
return True, '', sql
def _format_prosrc_for_pure_sql(self, data, view_only=True):
def _format_prosrc_for_pure_sql(self, data, view_only=True, lanname='sql'):
if self.manager.sversion < 140000:
return
@ -1483,7 +1483,7 @@ class FunctionView(PGChildNodeView, DataTypeReader, SchemaDiffObjectCompare):
else:
# when function/procedure definition is changed, we need to find
# whether definition is of pure or have std sql definition.
if self._is_function_def_sql_standard(data):
if lanname == 'sql' and self._is_function_def_sql_standard(data):
data['is_pure_sql'] = True
if data['prosrc'].endswith(';') is False:
data['prosrc'] = ''.join((data['prosrc'], ';'))