The IF formula function can generate SQL errors due to incorrect output field set when returning non text values
Describe the problem
The following formual should work:
if(
tonumber(
join(
totext(field("a")),
""
)
) = 0,
1,
tonumber(
join(
totext(field("b")),
""
)
)
) / 10
Instead there is a typo in the BaserowIf function:
Index: backend/src/baserow/contrib/database/formula/ast/function_defs.py
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/backend/src/baserow/contrib/database/formula/ast/function_defs.py b/backend/src/baserow/contrib/database/formula/ast/function_defs.py
--- a/backend/src/baserow/contrib/database/formula/ast/function_defs.py (revision 12cc2d1cc37f5af0d5dd6d8605b032b3aaa68ab3)
+++ b/backend/src/baserow/contrib/database/formula/ast/function_defs.py (date 1657891613988)
@@ -579,7 +579,7 @@
return Case(
When(condition=arg1, then=arg2),
default=arg3,
- output_field=arg1.output_field,
+ output_field=arg2.output_field,
)
Edited by Nigel Gott