From 5436fe6cee5624d0893f615436fe718d576c8dc3 Mon Sep 17 00:00:00 2001 From: Sergi Almacellas Abellana Date: Wed, 4 Mar 2015 18:15:06 +0100 Subject: [PATCH] Add support for Greatest and Least on SQLite issue4597 review13011002 --- trytond/backend/sqlite/database.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/trytond/backend/sqlite/database.py b/trytond/backend/sqlite/database.py index 1b68ce7af7..c4e5e4cfe0 100644 --- a/trytond/backend/sqlite/database.py +++ b/trytond/backend/sqlite/database.py @@ -23,6 +23,7 @@ except ImportError: from sql import Flavor, Table from sql.functions import (Function, Extract, Position, Now, Substring, Overlay, CharLength) +from sql.conditionals import Greatest, Least __all__ = ['Database', 'DatabaseIntegrityError', 'DatabaseOperationalError', 'Cursor'] @@ -138,6 +139,16 @@ class SQLiteCharLength(Function): _function = 'LENGTH' +class SQLiteGreatest(Greatest): + __slots__ = () + _function = 'MAX' + + +class SQLiteLeast(Least): + __slots__ = () + _function = 'MIN' + + def sign(value): if value > 0: return 1 @@ -153,6 +164,8 @@ MAPPING = { Substring: SQLiteSubstring, Overlay: SQLiteOverlay, CharLength: SQLiteCharLength, + Greatest: SQLiteGreatest, + Least: SQLiteLeast, }