Ensure sequences can be created with increment, start, minimum and maximum options set. Fixes #4100

This commit is contained in:
Akshay Joshi 2019-03-22 15:54:34 +00:00 committed by Dave Page
parent ce073a2856
commit 212ca01506
4 changed files with 19 additions and 30 deletions

View File

@ -55,3 +55,4 @@ Bug fixes
| `Bug #4081 <https://redmine.postgresql.org/issues/4081>`_ - Fix the RE-SQL syntax for roles with a VALID UNTIL clause. | `Bug #4081 <https://redmine.postgresql.org/issues/4081>`_ - Fix the RE-SQL syntax for roles with a VALID UNTIL clause.
| `Bug #4090 <https://redmine.postgresql.org/issues/4090>`_ - Improve the German translation for Backup Server. | `Bug #4090 <https://redmine.postgresql.org/issues/4090>`_ - Improve the German translation for Backup Server.
| `Bug #4099 <https://redmine.postgresql.org/issues/4099>`_ - Fix SQL help for EPAS 10+, and refactor the URL generation code into a testable function. | `Bug #4099 <https://redmine.postgresql.org/issues/4099>`_ - Fix SQL help for EPAS 10+, and refactor the URL generation code into a testable function.
| `Bug #4100 <https://redmine.postgresql.org/issues/4100>`_ - Ensure sequences can be created with increment, start, minimum and maximum options set.

View File

@ -349,11 +349,16 @@ class SequenceView(PGChildNodeView):
"Could not find the required parameter (%s)." % arg "Could not find the required parameter (%s)." % arg
) )
) )
try:
# The SQL below will execute CREATE DDL only # The SQL below will execute CREATE DDL only
SQL = render_template( SQL = render_template(
"/".join([self.template_path, 'create.sql']), "/".join([self.template_path, 'create.sql']),
data=data, conn=self.conn data=data, conn=self.conn
) )
except Exception as e:
return internal_server_error(errormsg=e)
status, msg = self.conn.execute_scalar(SQL) status, msg = self.conn.execute_scalar(SQL)
if not status: if not status:
return internal_server_error(errormsg=msg) return internal_server_error(errormsg=msg)

View File

@ -1,16 +1,16 @@
CREATE SEQUENCE {{ conn|qtIdent(data.schema, data.name) }}{% if data.increment is defined and data.cycled %} CREATE SEQUENCE {{ conn|qtIdent(data.schema, data.name) }}{% if data.increment is defined and data.cycled %}
CYCLE{% endif %}{% if data.increment is defined and data.increment is number %} CYCLE{% endif %}{% if data.increment is defined %}
INCREMENT {{data.increment}}{% endif %}{% if data.start is defined and data.start is number %} INCREMENT {{data.increment|int}}{% endif %}{% if data.start is defined %}
START {{data.start}}{% elif data.current_value is defined and data.current_value is number %} START {{data.start|int}}{% elif data.current_value is defined %}
START {{data.current_value}}{% endif %}{% if data.minimum is defined and data.minimum is number %} START {{data.current_value|int}}{% endif %}{% if data.minimum is defined %}
MINVALUE {{data.minimum}}{% endif %}{% if data.maximum is defined and data.maximum is number %} MINVALUE {{data.minimum|int}}{% endif %}{% if data.maximum is defined %}
MAXVALUE {{data.maximum}}{% endif %}{% if data.cache is defined and data.cache is number %} MAXVALUE {{data.maximum|int}}{% endif %}{% if data.cache is defined %}
CACHE {{data.cache}}{% endif %}; CACHE {{data.cache|int}}{% endif %};

View File

@ -40,23 +40,6 @@ class SequenceAddTestCase(BaseTestGenerator):
"start": "100" "start": "100"
} }
) )
),
(
'Fetch sequence Node URL (invalid optional data)',
dict(
url='/browser/sequence/obj/',
# Optional fields should be int but we are passing empty str
data={
"cache": "",
"cycled": False,
"increment": "",
"maximum": "",
"minimum": "",
"name": "test_sequence_add_%s" % (str(uuid.uuid4())[1:8]),
"securities": [],
"start": ""
}
)
) )
] ]