mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Ensure sequence with negative value should be created. Fixes #4726
This commit is contained in:
parent
31653aef70
commit
7944e75695
@ -53,3 +53,4 @@ Bug fixes
|
||||
| `Issue #4681 <https://redmine.postgresql.org/issues/4681>`_ - Increase cache control max age for static files to improve performance over longer run.
|
||||
| `Issue #4702 <https://redmine.postgresql.org/issues/4702>`_ - Fix modified SQL for Index when reset the value of Fill factor and Clustered?.
|
||||
| `Issue #4703 <https://redmine.postgresql.org/issues/4703>`_ - Fix reversed engineered SQL for btree Index when provided sort order and NULLs.
|
||||
| `Issue #4726 <https://redmine.postgresql.org/issues/4726>`_ - Ensure sequence with negative value should be created.
|
@ -137,7 +137,6 @@ define('pgadmin.node.sequence', [
|
||||
},{
|
||||
id: 'increment', label: gettext('Increment'), type: 'int',
|
||||
mode: ['properties', 'create', 'edit'], group: gettext('Definition'),
|
||||
min: 1,
|
||||
},{
|
||||
id: 'start', label: gettext('Start'), type: 'int',
|
||||
mode: ['properties', 'create'], group: gettext('Definition'),
|
||||
|
@ -1,14 +1,14 @@
|
||||
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|int(-1) > -1 %}
|
||||
CYCLE{% endif %}{% if data.increment is defined %}
|
||||
|
||||
INCREMENT {{data.increment|int}}{% endif %}{% if data.start is defined and data.start|int(-1) > -1%}
|
||||
INCREMENT {{data.increment|int}}{% endif %}{% if data.start is defined %}
|
||||
|
||||
START {{data.start|int}}{% elif data.current_value is defined and data.current_value|int(-1) > -1%}
|
||||
START {{data.start|int}}{% elif data.current_value is defined %}
|
||||
|
||||
START {{data.current_value|int}}{% endif %}{% if data.minimum is defined and data.minimum|int(-1) > -1%}
|
||||
START {{data.current_value|int}}{% endif %}{% if data.minimum is defined %}
|
||||
|
||||
MINVALUE {{data.minimum|int}}{% endif %}{% if data.maximum is defined and data.maximum|int(-1) > -1%}
|
||||
MINVALUE {{data.minimum|int}}{% endif %}{% if data.maximum is defined %}
|
||||
|
||||
MAXVALUE {{data.maximum|int}}{% endif %}{% if data.cache is defined and data.cache|int(-1) > -1%}
|
||||
|
||||
|
@ -0,0 +1,13 @@
|
||||
-- SEQUENCE: public."Seq1_$%{}[]()&*^!@""'`\/#"
|
||||
|
||||
-- DROP SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#";
|
||||
|
||||
CREATE SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#"
|
||||
INCREMENT -7
|
||||
START -30
|
||||
MINVALUE -35
|
||||
MAXVALUE -15
|
||||
CACHE 1;
|
||||
|
||||
ALTER SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#"
|
||||
OWNER TO postgres;
|
@ -0,0 +1,4 @@
|
||||
ALTER SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#"
|
||||
INCREMENT -7
|
||||
MINVALUE -35
|
||||
MAXVALUE -15;
|
@ -0,0 +1,13 @@
|
||||
-- SEQUENCE: public."Seq1_$%{}[]()&*^!@""'`\/#"
|
||||
|
||||
-- DROP SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#";
|
||||
|
||||
CREATE SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#"
|
||||
INCREMENT -5
|
||||
START -30
|
||||
MINVALUE -40
|
||||
MAXVALUE -10
|
||||
CACHE 1;
|
||||
|
||||
ALTER SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#"
|
||||
OWNER TO postgres;
|
@ -0,0 +1,9 @@
|
||||
CREATE SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#"
|
||||
INCREMENT -5
|
||||
START -30
|
||||
MINVALUE -40
|
||||
MAXVALUE -10
|
||||
CACHE 1;
|
||||
|
||||
ALTER SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#"
|
||||
OWNER TO postgres;
|
@ -122,13 +122,52 @@
|
||||
},
|
||||
"expected_sql_file": "alter_seq_privs_remove.sql",
|
||||
"expected_msql_file": "alter_seq_privs_remove_msql.sql"
|
||||
},{
|
||||
}, {
|
||||
"type": "delete",
|
||||
"name": "Drop sequence",
|
||||
"endpoint": "NODE-sequence.delete_id",
|
||||
"data": {
|
||||
"name": "Seq1_$%{}[]()&*^!@\"'`\\/#"
|
||||
}
|
||||
}, {
|
||||
"type": "create",
|
||||
"name": "Create Sequence with Negative value",
|
||||
"endpoint": "NODE-sequence.obj",
|
||||
"sql_endpoint": "NODE-sequence.sql_id",
|
||||
"msql_endpoint": "NODE-sequence.msql",
|
||||
"data": {
|
||||
"name": "Seq1_$%{}[]()&*^!@\"'`\\/#",
|
||||
"seqowner": "postgres",
|
||||
"schema": "public",
|
||||
"increment": "-5",
|
||||
"start": "-30",
|
||||
"maximum": "-10",
|
||||
"minimum": "-40",
|
||||
"cache": "1",
|
||||
"cycled": false,
|
||||
"relacl": [],
|
||||
"securities": []
|
||||
},
|
||||
"expected_sql_file": "create_negative_sequence.sql",
|
||||
"expected_msql_file": "create_negative_sequence_msql.sql"
|
||||
}, {
|
||||
"type": "alter",
|
||||
"name": "Alter Sequence properties with negative value",
|
||||
"endpoint": "NODE-sequence.obj_id",
|
||||
"sql_endpoint": "NODE-sequence.sql_id",
|
||||
"msql_endpoint": "NODE-sequence.msql_id",
|
||||
"data": {
|
||||
"increment": "-7", "minimum": "-35", "maximum": "-15"
|
||||
},
|
||||
"expected_sql_file": "alter_neg_seq_props.sql",
|
||||
"expected_msql_file": "alter_neg_seq_props_msql.sql"
|
||||
}, {
|
||||
"type": "delete",
|
||||
"name": "Drop negative sequence",
|
||||
"endpoint": "NODE-sequence.delete_id",
|
||||
"data": {
|
||||
"name": "Seq1_$%{}[]()&*^!@\"'`\\/#"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -0,0 +1,13 @@
|
||||
-- SEQUENCE: public."Seq1_$%{}[]()&*^!@""'`\/#"
|
||||
|
||||
-- DROP SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#";
|
||||
|
||||
CREATE SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#"
|
||||
INCREMENT -7
|
||||
START -30
|
||||
MINVALUE -35
|
||||
MAXVALUE -15
|
||||
CACHE 1;
|
||||
|
||||
ALTER SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#"
|
||||
OWNER TO enterprisedb;
|
@ -0,0 +1,4 @@
|
||||
ALTER SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#"
|
||||
INCREMENT -7
|
||||
MINVALUE -35
|
||||
MAXVALUE -15;
|
@ -0,0 +1,13 @@
|
||||
-- SEQUENCE: public."Seq1_$%{}[]()&*^!@""'`\/#"
|
||||
|
||||
-- DROP SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#";
|
||||
|
||||
CREATE SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#"
|
||||
INCREMENT -5
|
||||
START -30
|
||||
MINVALUE -40
|
||||
MAXVALUE -10
|
||||
CACHE 1;
|
||||
|
||||
ALTER SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#"
|
||||
OWNER TO enterprisedb;
|
@ -0,0 +1,9 @@
|
||||
CREATE SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#"
|
||||
INCREMENT -5
|
||||
START -30
|
||||
MINVALUE -40
|
||||
MAXVALUE -10
|
||||
CACHE 1;
|
||||
|
||||
ALTER SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#"
|
||||
OWNER TO enterprisedb;
|
@ -122,13 +122,52 @@
|
||||
},
|
||||
"expected_sql_file": "alter_seq_privs_remove.sql",
|
||||
"expected_msql_file": "alter_seq_privs_remove_msql.sql"
|
||||
},{
|
||||
}, {
|
||||
"type": "delete",
|
||||
"name": "Drop sequence",
|
||||
"endpoint": "NODE-sequence.delete_id",
|
||||
"data": {
|
||||
"name": "Seq1_$%{}[]()&*^!@\"'`\\/#"
|
||||
}
|
||||
}, {
|
||||
"type": "create",
|
||||
"name": "Create Sequence with Negative value",
|
||||
"endpoint": "NODE-sequence.obj",
|
||||
"sql_endpoint": "NODE-sequence.sql_id",
|
||||
"msql_endpoint": "NODE-sequence.msql",
|
||||
"data": {
|
||||
"name": "Seq1_$%{}[]()&*^!@\"'`\\/#",
|
||||
"seqowner": "enterprisedb",
|
||||
"schema": "public",
|
||||
"increment": "-5",
|
||||
"start": "-30",
|
||||
"maximum": "-10",
|
||||
"minimum": "-40",
|
||||
"cache": "1",
|
||||
"cycled": false,
|
||||
"relacl": [],
|
||||
"securities": []
|
||||
},
|
||||
"expected_sql_file": "create_negative_sequence.sql",
|
||||
"expected_msql_file": "create_negative_sequence_msql.sql"
|
||||
}, {
|
||||
"type": "alter",
|
||||
"name": "Alter Sequence properties with negative value",
|
||||
"endpoint": "NODE-sequence.obj_id",
|
||||
"sql_endpoint": "NODE-sequence.sql_id",
|
||||
"msql_endpoint": "NODE-sequence.msql_id",
|
||||
"data": {
|
||||
"increment": "-7", "minimum": "-35", "maximum": "-15"
|
||||
},
|
||||
"expected_sql_file": "alter_neg_seq_props.sql",
|
||||
"expected_msql_file": "alter_neg_seq_props_msql.sql"
|
||||
}, {
|
||||
"type": "delete",
|
||||
"name": "Drop negative sequence",
|
||||
"endpoint": "NODE-sequence.delete_id",
|
||||
"data": {
|
||||
"name": "Seq1_$%{}[]()&*^!@\"'`\\/#"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ class SequenceAddTestCase(BaseTestGenerator):
|
||||
scenarios = [
|
||||
# Fetching default URL for sequence node.
|
||||
(
|
||||
'Fetch sequence Node URL (valid optional data)',
|
||||
'Create sequence with positive values',
|
||||
dict(
|
||||
url='/browser/sequence/obj/',
|
||||
# Valid optional data
|
||||
@ -40,6 +40,23 @@ class SequenceAddTestCase(BaseTestGenerator):
|
||||
"start": "100"
|
||||
}
|
||||
)
|
||||
),
|
||||
(
|
||||
'Create sequence with negative values',
|
||||
dict(
|
||||
url='/browser/sequence/obj/',
|
||||
# Valid optional data
|
||||
data={
|
||||
"cache": "1",
|
||||
"cycled": True,
|
||||
"increment": "-5",
|
||||
"maximum": "-10",
|
||||
"minimum": "-40",
|
||||
"name": "test_sequence_add_%s" % (str(uuid.uuid4())[1:8]),
|
||||
"securities": [],
|
||||
"start": "-30"
|
||||
}
|
||||
)
|
||||
)
|
||||
]
|
||||
|
||||
|
@ -25,7 +25,28 @@ class SequencePutTestCase(BaseTestGenerator):
|
||||
skip_on_database = ['gpdb']
|
||||
scenarios = [
|
||||
# Fetching default URL for sequence node.
|
||||
('Fetch sequence Node URL', dict(url='/browser/sequence/obj/'))
|
||||
('Alter positive sequence comment, increment, max and min value',
|
||||
dict(
|
||||
url='/browser/sequence/obj/',
|
||||
data={
|
||||
"comment": "This is sequence update comment",
|
||||
"increment": "5",
|
||||
"maximum": "1000",
|
||||
"minimum": "10",
|
||||
},
|
||||
positive_seq=True
|
||||
)),
|
||||
('Alter negative sequence comment, increment, max and min value',
|
||||
dict(
|
||||
url='/browser/sequence/obj/',
|
||||
data={
|
||||
"comment": "This is sequence update comment",
|
||||
"increment": "-7",
|
||||
"maximum": "-15",
|
||||
"minimum": "-35",
|
||||
},
|
||||
positive_seq=False
|
||||
))
|
||||
]
|
||||
|
||||
def setUp(self):
|
||||
@ -47,7 +68,9 @@ class SequencePutTestCase(BaseTestGenerator):
|
||||
raise Exception("Could not find the schema to add sequence.")
|
||||
self.sequence_name = "test_sequence_delete_%s" % str(uuid.uuid4())[1:8]
|
||||
self.sequence_id = sequence_utils.create_sequences(
|
||||
self.server, self.db_name, self.schema_name, self.sequence_name)
|
||||
self.server, self.db_name, self.schema_name, self.sequence_name,
|
||||
self.positive_seq
|
||||
)
|
||||
|
||||
def runTest(self):
|
||||
"""This function will update added sequence under schema node."""
|
||||
@ -56,17 +79,17 @@ class SequencePutTestCase(BaseTestGenerator):
|
||||
self.sequence_name)
|
||||
if not sequence_response:
|
||||
raise Exception("Could not find the sequence to delete.")
|
||||
data = {
|
||||
"comment": "This is sequence update comment",
|
||||
"id": self.sequence_id
|
||||
}
|
||||
|
||||
# Add sequence id.
|
||||
self.data["id"] = self.sequence_id
|
||||
|
||||
response = self.tester.put(
|
||||
self.url + str(utils.SERVER_GROUP) + '/' +
|
||||
str(self.server_id) + '/' +
|
||||
str(self.db_id) + '/' +
|
||||
str(self.schema_id) + '/' +
|
||||
str(self.sequence_id),
|
||||
data=json.dumps(data),
|
||||
data=json.dumps(self.data),
|
||||
follow_redirects=True)
|
||||
self.assertEquals(response.status_code, 200)
|
||||
|
||||
|
@ -15,7 +15,8 @@ import traceback
|
||||
from regression.python_test_utils import test_utils as utils
|
||||
|
||||
|
||||
def create_sequences(server, db_name, schema_name, sequence_name):
|
||||
def create_sequences(server, db_name, schema_name, sequence_name,
|
||||
positive_seq=True):
|
||||
"""
|
||||
This function used to create sequence in schema provided.
|
||||
:param server: server details
|
||||
@ -26,6 +27,8 @@ def create_sequences(server, db_name, schema_name, sequence_name):
|
||||
:type schema_name: str
|
||||
:param sequence_name: sequence name
|
||||
:type sequence_name: str
|
||||
:param positive_seq: True is sequence will be created using positive values
|
||||
:type positive_seq: boolean
|
||||
:return sequence_id: sequence id
|
||||
:rtype: int
|
||||
"""
|
||||
@ -37,8 +40,12 @@ def create_sequences(server, db_name, schema_name, sequence_name):
|
||||
server['port'],
|
||||
server['sslmode'])
|
||||
pg_cursor = connection.cursor()
|
||||
query = "CREATE SEQUENCE %s.%s START 101" % (schema_name,
|
||||
sequence_name)
|
||||
|
||||
query = "CREATE SEQUENCE %s.%s INCREMENT 5 START 30 " \
|
||||
"MINVALUE 10 MAXVALUE 100" % (schema_name, sequence_name)
|
||||
if not positive_seq:
|
||||
query = "CREATE SEQUENCE %s.%s INCREMENT -5 START -30 " \
|
||||
"MINVALUE -40 MAXVALUE -10" % (schema_name, sequence_name)
|
||||
pg_cursor.execute(query)
|
||||
connection.commit()
|
||||
# Get 'oid' from newly created sequence
|
||||
|
Loading…
Reference in New Issue
Block a user