El 26/06/17 a les 16:31, Nicolás López Solano ha escrit:
Yes i tried. For postgresql it return a correct date but for sqlite it
return only the year of the datetime base column.
If i work directly executing sql (select cast(column as date) from
mytable) over a sqlite file i get a similar "not good" result. Cast
sqlite native functión can't covert to date.
Right, I can reproduce it on my local environemnt. In order to get a
proper date on sqlite you can use:
SELECT Date(column)
instead of
SELECT Cast(column as date)
So I ended up with the following code:
from sql.functions import Function
class SqlLiteDate(Function):
__slots__ = ()
_function = 'DATE'
if backend.name() == 'sqlite':
date = SqliteDate(column)
else:
date = Cast(column, 'DATE')
Hope it helps!
--
Sergi Almacellas Abellana
www.koolpi.com
Twitter: @pokoli_srk
--
You received this message because you are subscribed to the Google Groups
"tryton-dev" group.
To view this discussion on the web visit
https://groups.google.com/d/msgid/tryton-dev/906ca9f7-71dc-deef-46ee-0210e427d137%40koolpi.com.