Faster Postgres numeric comparasion
This commit is contained in:
parent
95d1489087
commit
eee5b693b0
1 changed files with 4 additions and 4 deletions
|
@ -130,13 +130,13 @@ class Condition:
|
|||
return params[0], '"%s" IS NULL'%(params[0])
|
||||
|
||||
if t == '<':
|
||||
return params[0], """(CASE WHEN "%s" ~ E'^[[:digit:]]+([.][[:digit:]]+)?$' THEN CAST ("%s" AS FLOAT) ELSE 0 END) < %s"""%(params[0],params[0],params[1])
|
||||
return params[0], """(CASE WHEN "%s" ~ E'^[-]?[[:digit:]]+([.][[:digit:]]+)?$' THEN CAST ("%s" AS FLOAT) < %s ELSE false END) """%(params[0],params[0],params[1])
|
||||
if t == '<=':
|
||||
return params[0], """(CASE WHEN "%s" ~ E'^[[:digit:]]+([.][[:digit:]]+)?$' THEN CAST ("%s" AS FLOAT) ELSE 0 END) <= %s"""%(params[0],params[0],params[1])
|
||||
return params[0], """(CASE WHEN "%s" ~ E'^[-]?[[:digit:]]+([.][[:digit:]]+)?$' THEN CAST ("%s" AS FLOAT) <= %s ELSE false END)"""%(params[0],params[0],params[1])
|
||||
if t == '>':
|
||||
return params[0], """(CASE WHEN "%s" ~ E'^[[:digit:]]+([.][[:digit:]]+)?$' THEN CAST ("%s" AS FLOAT) ELSE 0 END) > %s"""%(params[0],params[0],params[1])
|
||||
return params[0], """(CASE WHEN "%s" ~ E'^[-]?[[:digit:]]+([.][[:digit:]]+)?$' THEN CAST ("%s" AS FLOAT) > %s ELSE false END) """%(params[0],params[0],params[1])
|
||||
if t == '>=':
|
||||
return params[0], """(CASE WHEN "%s" ~ E'^[[:digit:]]+([.][[:digit:]]+)?$' THEN CAST ("%s" AS FLOAT) ELSE 0 END) >= %s"""%(params[0],params[0],params[1])
|
||||
return params[0], """(CASE WHEN "%s" ~ E'^[-]?[[:digit:]]+([.][[:digit:]]+)?$' THEN CAST ("%s" AS FLOAT) >= %s ELSE false END) """%(params[0],params[0],params[1])
|
||||
except KeyError:
|
||||
pass
|
||||
def get_mapnik_filter(self):
|
||||
|
|
Loading…
Add table
Reference in a new issue