[Formed-commits] r387 - trunk/formed/formed/plugins/export
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Mon Aug 9 15:37:53 CEST 2010
Author: torsten
Date: 2010-08-09 15:37:53 +0200 (Mon, 09 Aug 2010)
New Revision: 387
Modified:
trunk/formed/formed/plugins/export/rules_sql.py
Log:
Added Today-operator und GT BinaryOperator.
Modified: trunk/formed/formed/plugins/export/rules_sql.py
===================================================================
--- trunk/formed/formed/plugins/export/rules_sql.py 2010-08-09 09:36:22 UTC (rev 386)
+++ trunk/formed/formed/plugins/export/rules_sql.py 2010-08-09 13:37:53 UTC (rev 387)
@@ -20,6 +20,11 @@
import codecs
from cgi import escape
+def sql_today(node, document):
+ out = []
+ out.append("now()")
+ return " ".join(out)
+
def sql_var(node, document):
out = []
out.append(node.var_name)
@@ -53,6 +58,9 @@
elif node.operator.__name__ == "EQ":
operator = "="
out.append("%s %s %s" % (recursive_parse(node.a, document), operator, recursive_parse(node.b, document)))
+ elif node.operator.__name__ == "GE":
+ operator = ">="
+ out.append("%s %s %s" % (recursive_parse(node.a, document), operator, recursive_parse(node.b, document)))
elif node.operator.__name__ == "DAYS":
operator = "-"
out.append("abs(%s %s %s)" % (recursive_parse(node.a, document), operator, recursive_parse(node.b, document)))
@@ -101,6 +109,8 @@
out.append(sql_var(node, document))
elif isinstance(node, Const):
out.append(sql_const(node, document))
+ elif isinstance(node, Today):
+ out.append(sql_today(node, document))
else:
raise Exception('Can not parse %s' % node)
return " ".join(out)
More information about the Formed-commits
mailing list