piccolo-orm / piccolo

A fast, user friendly ORM and query builder which supports asyncio.
https://piccolo-orm.com/
MIT License
1.41k stars 89 forks source link

Add `Concat` function #1024

Closed dantownsend closed 3 months ago

dantownsend commented 3 months ago

We recently added some basic string functions, like Upper. It would be good to have a Concat function, for combining strings.

It's currently possible in Piccolo through queries such as:

await Band.update({Band.name: Band.name + "!!!"}, force=True)

Note how Band.name + "!!!" gets converted under the hood into the following SQL name || '!!!' (where || is the concat operator).

But it will be nice to have an explicit Concat function.

>>> await Band.select(Concat(Band.name, '-', Band.manager._.name, alias="name"))
[{"name": "Pythonistas-Guido"}]