changeset 23acc564167b in trytond:default
details: https://hg.tryton.org/trytond?cmd=changeset;node=23acc564167b
description:
        Convert read column into proper type with SQLite

        As SQLite has few basic types, we must use column names cast parsing to 
ensure
        to read values in proper type.

        issue9652
        review310801004
diffstat:

 trytond/model/modelsql.py |  2 ++
 trytond/model/union.py    |  2 +-
 2 files changed, 3 insertions(+), 1 deletions(-)

diffs (24 lines):

diff -r c5d556e29687 -r 23acc564167b trytond/model/modelsql.py
--- a/trytond/model/modelsql.py Wed Oct 21 21:08:55 2020 +0200
+++ b/trytond/model/modelsql.py Wed Oct 21 23:11:13 2020 +0200
@@ -732,6 +732,8 @@
             field = cls._fields.get(f)
             if field and field.sql_type():
                 columns.append(field.sql_column(table).as_(f))
+                if backend.name == 'sqlite':
+                    columns[-1].output_name += ' [%s]' % field.sql_type().base
             elif f in {'_write', '_delete'}:
                 if not callable(cls.table_query):
                     rule_domain = Rule.domain_get(
diff -r c5d556e29687 -r 23acc564167b trytond/model/union.py
--- a/trytond/model/union.py    Wed Oct 21 21:08:55 2020 +0200
+++ b/trytond/model/union.py    Wed Oct 21 23:11:13 2020 +0200
@@ -56,7 +56,7 @@
             if name == 'id' or hasattr(field, 'set'):
                 continue
             column = cls.union_column(name, field, table, Model)
-            columns.append(Cast(column, field.sql_type().base).as_(name))
+            columns.append(field.sql_cast(column).as_(name))
         return table, columns
 
     @classmethod

Reply via email to