beancount / beanquery

A customizable light-weight SQL query tool that works on tabular data, including Beancount.
GNU General Public License v2.0
19 stars 12 forks source link

String formatting ang string concatenation #194

Open dnicolodi opened 3 months ago

dnicolodi commented 3 months ago

There would be value in adding support for rendering values as strings with some control on the formatting, and for concatenating strings.

Formatting could be done with a format() function resembling the homonymous Python function, or the Python str class method. The latter would allow to format multiple values in one string, with the drawback of a more complex implementation, especially regarding typing in BQL. The former would be much simpler to implement.

String concatenation could be done with the + operator like in Python or with the || like in standard SQL. I like the + better.

dnicolodi commented 3 months ago

PostgreSQL has a format(frmt, value, ...) function. Thus maybe this is the way to go for BQL too. https://www.postgresql.org/docs/current/functions-string.html#FUNCTIONS-STRING-FORMAT