Created on 2021-03-29.19:48:29 by albertca, last changed 1 week ago by ced.
I do not think so. This is as much arbitrary as the postgresql default. More over it still do not prevent to have similar error for out of the range value. Also database administrator could any way customize the value of a sequence.
I think it would be better to set MINVALUE to -9223372036854775808 in:
https://hg.tryton.org/trytond/file/tip/trytond/backend/postgresql/database.py#l665
As sequence is a BIGINT by default, -9223372036854775808 is its minimum value:
I think a good solution would be to catch the error from the backend and raise a UserError with a proper message.
For me it is specificity of the backend, I do not think we should do anything against that.
Trying to set number_next to 0 or lower will cause the following crash:
Traceback (most recent call last):
File "/trytond/wsgi.py", line 114, in dispatch_request
return endpoint(request, **request.view_args)
File "/trytond/protocols/dispatcher.py", line 48, in rpc
request, database_name, *request.rpc_params)
File "/trytond/wsgi.py", line 81, in auth_required
return wrapped(*args, **kwargs)
File "/trytond/protocols/wrappers.py", line 131, in wrapper
return func(request, pool, *args, **kwargs)
File "/trytond/protocols/dispatcher.py", line 186, in _dispatch
result = rpc.result(meth(*c_args, **c_kwargs))
File "/trytond/ir/sequence.py", line 184, in write
sequence.update_sql_sequence(values.get('number_next'))
File "/trytond/ir/sequence.py", line 264, in update_sql_sequence
self._sql_sequence_name, self.number_increment, number_next)
File "/trytond/backend/postgresql/database.py", line 500, in sequence_update
(number_increment, start_value))
File "/trytond/backend/postgresql/database.py", line 68, in execute
cursor.execute(self, sql, args)
psycopg2.errors.InvalidParameterValue: RESTART value (0) cannot be less than MINVALUE (1)
History | |||
---|---|---|---|
Date | User | Action | Args |
2021-03-29 23:26:19 | ced | set | messages: + msg65926 |
2021-03-29 22:14:59 | albertca | set | messages: + msg65925 |
2021-03-29 20:26:12 | ced | set | messages: + msg65924 |
2021-03-29 20:18:06 | reviewbot | set | messages:
+ msg65923 nosy: + reviewbot |
2021-03-29 20:16:45 | ced | set | messages:
+ msg65922 nosy: + ced |
2021-03-29 19:55:46 | albertca | set | status: unread -> testing |
2021-03-29 19:55:34 | albertca | set | keyword:
+ review reviews: 357601005 |
2021-03-29 19:48:29 | albertca | create |
Showing 10 items. Show all history (warning: this could be VERY long)