From e0388eccfe32154b29957e738a83bddabd2112b5 Mon Sep 17 00:00:00 2001 From: Julien Muchembled <jm@nexedi.com> Date: Mon, 25 May 2015 18:02:12 +0200 Subject: [PATCH] =?UTF-8?q?catalog:=20render=20=C2=B5s=20in=20SQL=20method?= =?UTF-8?q?s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- product/ERP5Type/patches/sqlvar.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/product/ERP5Type/patches/sqlvar.py b/product/ERP5Type/patches/sqlvar.py index 1b7e57ba0a..2d1226adc1 100644 --- a/product/ERP5Type/patches/sqlvar.py +++ b/product/ERP5Type/patches/sqlvar.py @@ -72,17 +72,15 @@ def SQLVar_render(self, md): 'Invalid datetime value for <em>%s</em>: %r' % (name, v)) try: - if getattr(v, 'ISO', None) is not None: - v=v.toZone('UTC').ISO() - else: - v = DateTime(v) - v=v.toZone('UTC').ISO() + v = (v if isinstance(v, DateTime) else DateTime(v)).toZone('UTC') + # For subsecond precision in MySQL, use 'datetime(N)' type, + # where N is the number of digits after the decimal point. + v = "'%s.%06u'" % (v.ISO(), v.micros() % 1000000) except: if not v and args.has_key('optional') and args['optional']: return 'null' raise ValueError, ( 'Invalid datetime value for <em>%s</em>: %r' % (name, v)) - v=md.getitem('sql_quote__',0)(v) # End of patch else: # Patched by yo -- 2.30.9