Ensure that text larger than underlying field size should not be truncated automatically. Fixes #5210

This commit is contained in:
navnath gadakh 2020-04-16 14:39:31 +05:30 committed by Akshay Joshi
parent 0dd1cb3fc1
commit c0a2f1f24d
3 changed files with 98 additions and 20 deletions

View File

@ -45,6 +45,7 @@ Bug fixes
| `Issue #5007 <https://redmine.postgresql.org/issues/5007>`_ - Ensure index dropdown should have existing indexes while creating unique constraints.
| `Issue #5053 <https://redmine.postgresql.org/issues/5053>`_ - Fixed an issue where changing the columns in the existing view throws an error.
| `Issue #5180 <https://redmine.postgresql.org/issues/5180>`_ - Fixed an issue where the autovacuum_enabled parameter is added automatically in the RE-SQL when the table has been created using the WITH clause.
| `Issue #5210 <https://redmine.postgresql.org/issues/5210>`_ - Ensure that text larger than underlying field size should not be truncated automatically.
| `Issue #5227 <https://redmine.postgresql.org/issues/5227>`_ - Fixed an issue where user cannot be added if many users are already exists.
| `Issue #5268 <https://redmine.postgresql.org/issues/5268>`_ - Fixed generated SQL when any token in FTS Configuration or any option in FTS Dictionary is changed.
| `Issue #5270 <https://redmine.postgresql.org/issues/5270>`_ - Ensure that OID should be shown in properties for Synonyms.

View File

@ -452,9 +452,6 @@ def poll(trans_id):
for col_type in types:
if col_type['oid'] == col_info['type_code']:
typname = col_type['typname']
typname = compose_type_name(col_info, typname)
col_info['type_name'] = typname
# Using characters %, (, ) in the argument names is not
@ -529,22 +526,6 @@ def poll(trans_id):
)
def compose_type_name(col_info, typname):
# If column is of type character, character[],
# character varying and character varying[]
# then add internal size to it's name for the
# correct sql query.
if col_info['internal_size'] >= 0:
if typname == 'character' or typname == 'character varying':
typname = typname + '(' + str(col_info['internal_size']) + ')'
elif typname == 'character[]' or typname == 'character varying[]':
typname = '{}({})[]'.format(
typname[:-2],
str(col_info['internal_size'])
)
return typname
@blueprint.route(
'/fetch/<int:trans_id>', methods=["GET"], endpoint='fetch'
)

View File

@ -71,6 +71,55 @@ class TestSaveChangedData(BaseTestGenerator):
check_sql='SELECT * FROM %s WHERE pk_col = 3',
check_result=[[3, "three"]]
)),
('When inserting row with long data', dict(
save_payload={
"updated": {},
"added": {
"2": {
"err": False,
"data": {
"pk_col": "3",
"__temp_PK": "2",
"normal_col": "invalid-log-string"
}
}
},
"staged_rows": {},
"deleted": {},
"updated_index": {},
"added_index": {"2": "2"},
"columns": [
{
"name": "pk_col",
"display_name": "pk_col",
"column_type": "[PK] integer",
"column_type_internal": "integer",
"pos": 0,
"label": "pk_col<br>[PK] integer",
"cell": "number",
"can_edit": True,
"type": "integer",
"not_null": True,
"has_default_val": False,
"is_array": False},
{"name": "normal_col",
"display_name": "normal_col",
"column_type": "character varying",
"column_type_internal": "character varying",
"pos": 1,
"label": "normal_col<br>character varying",
"cell": "string",
"can_edit": True,
"type": "character varying",
"not_null": False,
"has_default_val": False,
"is_array": False}
]
},
save_status=False,
check_sql='SELECT * FROM %s WHERE pk_col = 3',
check_result='SELECT 0'
)),
('When inserting new invalid row', dict(
save_payload={
"updated": {},
@ -168,6 +217,53 @@ class TestSaveChangedData(BaseTestGenerator):
check_sql='SELECT * FROM %s WHERE pk_col = 1',
check_result=[[1, "ONE"]]
)),
('When updating a row in a invalid way', dict(
save_payload={
"updated": {
"1":
{"err": False,
"data": {"normal_col": "INVALID-COL-LENGTH"},
"primary_keys":
{"pk_col": 1}
}
},
"added": {},
"staged_rows": {},
"deleted": {},
"updated_index": {"1": "1"},
"added_index": {},
"columns": [
{
"name": "pk_col",
"display_name": "pk_col",
"column_type": "[PK] integer",
"column_type_internal": "integer",
"pos": 0,
"label": "pk_col<br>[PK] integer",
"cell": "number",
"can_edit": True,
"type": "integer",
"not_null": True,
"has_default_val": False,
"is_array": False},
{"name": "normal_col",
"display_name": "normal_col",
"column_type": "character varying",
"column_type_internal": "character varying",
"pos": 1,
"label": "normal_col<br>character varying",
"cell": "string",
"can_edit": True,
"type": "character varying",
"not_null": False,
"has_default_val": False,
"is_array": False}
]
},
save_status=False,
check_sql='SELECT * FROM %s WHERE pk_col = 1',
check_result=[[1, "one"]]
)),
('When updating a row in an invalid way', dict(
save_payload={
"updated": {
@ -343,7 +439,7 @@ class TestSaveChangedData(BaseTestGenerator):
CREATE TABLE "%s"(
pk_col INT PRIMARY KEY,
normal_col VARCHAR);
normal_col VARCHAR(5));
INSERT INTO "%s" VALUES
(1, 'one'),