telefonicasc / tcjexl

Recubrimiento de la librería de jexl incluyendo un conjunto de transformaciones por defecto
GNU Affero General Public License v3.0
0 stars 0 forks source link

Transformation to avoid problem with null values in numerical variables #11

Closed fgalan closed 5 months ago

fgalan commented 6 months ago

Currently this fails:

from tcjexl import JEXL
jexl = JEXL()
print(jexl.evaluate('num*10', {"num": None}))

with

TypeError: unsupported operand type(s) for *: 'NoneType' and 'int'

(Curiously, note that in JavaScript JEXL it works :)

This one works:

from tcjexl import JEXL
jexl = JEXL()
print(jexl.evaluate('(num==null?0:num)*10', {"num": None}))

Include that x==null?0:x into a add_transformation (possible name: numberNullSafe)

fgalan commented 5 months ago

PR #13