Add split_part formula function
Background
See https://baserow.io/docs/technical%2Fformula-technical-guide for more formula information.
The issue
The postgresql function split_part would be very useful to have as a new formula. This issue is tracking adding it to the frontend and backend and the steps involved would be:
- Add it as a new Function in
function_defs.py
- A formula function is run using SQL at the end of the day. To implement your formula function you just need to return a Django ORM expression that generates the desired SQL. See https://docs.djangoproject.com/en/3.2/ref/models/expressions/#func-expressions for more.
- A formula function also needs to define its type. Just like when you add type annotations on a python function/in typescript etc.
- Register this new function def in the register function in function_defs.py
- Add a few happy test cases in
baserow/contrib/database/formula/test_baserow_formula_``results.py:13
- Consider what happens when you pass null's etc as parameters.
- A user should never be able to write a formula that results in SQL errors, Baserow formula functions often wrap inputs in CASE WHEN THEN ELSE to prevent nulls or incorrect values being passed into Postgresql functions that could cause crashes
- Add the frontend info for your new function in
database/formula/functions.js:2
- Make sure the register your new frontend function in the frontend formula registry also