mirror of
https://github.com/NaN-tic/trytond-patches.git
synced 2023-12-14 06:03:03 +01:00
add support to psql v10
This commit is contained in:
parent
dda3f25cab
commit
28ed1f71d3
2
series
2
series
|
@ -55,7 +55,7 @@ commission-issue6322-issue6501.diff
|
||||||
sepa_sequence_type.diff
|
sepa_sequence_type.diff
|
||||||
add_account_in_move_line_payable_receivable.diff
|
add_account_in_move_line_payable_receivable.diff
|
||||||
locale.diff
|
locale.diff
|
||||||
|
#support_postgresql10_6789.patch
|
||||||
issue6179.diff
|
issue6179.diff
|
||||||
|
|
||||||
issue6294.diff # [tryton] - Creating a board view with a form inside
|
issue6294.diff # [tryton] - Creating a board view with a form inside
|
||||||
|
|
39
support_postgresql10_6789.patch
Normal file
39
support_postgresql10_6789.patch
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
diff -r 57512456d26d trytond/ir/sequence.py
|
||||||
|
--- a/trytond/trytond/ir/sequence.py Thu Mar 01 22:53:06 2018 +0100
|
||||||
|
+++ b/trytond/trytond/ir/sequence.py Tue Apr 10 15:02:58 2018 +0200
|
||||||
|
@@ -163,10 +163,31 @@
|
||||||
|
cursor = Transaction().cursor
|
||||||
|
sql_name = self._sql_sequence_name
|
||||||
|
if sql_sequence and not self._strict:
|
||||||
|
- cursor.execute('SELECT '
|
||||||
|
- 'CASE WHEN NOT is_called THEN last_value '
|
||||||
|
- 'ELSE last_value + increment_by '
|
||||||
|
- 'END FROM "%s"' % sql_name)
|
||||||
|
+ cursor.execute('SELECT version()')
|
||||||
|
+ cursor.execute('SHOW server_version_num')
|
||||||
|
+ version, = cursor.fetchone()
|
||||||
|
+ major, rest = divmod(int(version), 10000)
|
||||||
|
+ minor, patch = divmod(rest, 100)
|
||||||
|
+ version = (major, minor)
|
||||||
|
+ if version >= (10, 0):
|
||||||
|
+ param = Flavor.get().param
|
||||||
|
+ cursor.execute(
|
||||||
|
+ 'SELECT increment_by '
|
||||||
|
+ 'FROM pg_sequences '
|
||||||
|
+ 'WHERE sequencename=%s '
|
||||||
|
+ % param, (sql_name,))
|
||||||
|
+ increment, = cursor.fetchone()
|
||||||
|
+ cursor.execute(
|
||||||
|
+ 'SELECT CASE WHEN NOT is_called THEN last_value '
|
||||||
|
+ 'ELSE last_value + %s '
|
||||||
|
+ 'END '
|
||||||
|
+ 'FROM "%s"' % (param, sql_name),
|
||||||
|
+ (increment,))
|
||||||
|
+ else:
|
||||||
|
+ cursor.execute('SELECT '
|
||||||
|
+ 'CASE WHEN NOT is_called THEN last_value '
|
||||||
|
+ 'ELSE last_value + increment_by '
|
||||||
|
+ 'END FROM "%s"' % sql_name)
|
||||||
|
return cursor.fetchone()[0]
|
||||||
|
else:
|
||||||
|
return self.number_next_internal
|
Loading…
Reference in a new issue