In recent releases we have been adding more SQL functions to Piccolo.
These functions return QueryString - the building block of queries in Piccolo.
By overriding magic methods in QueryString we can make a more intuitive API. For example:
await Ticket.select(Round(Ticket.price) * 2)
In the example above, Round returns a QueryString, and by overriding the __mul__ magic method on QueryString, we can make it so Round(Ticket.price) * 2 returns a new QueryString which compiles down to round(price) * 2 in SQL.
In recent releases we have been adding more SQL functions to Piccolo.
These functions return
QueryString
- the building block of queries in Piccolo.By overriding magic methods in
QueryString
we can make a more intuitive API. For example:In the example above,
Round
returns aQueryString
, and by overriding the__mul__
magic method onQueryString
, we can make it soRound(Ticket.price) * 2
returns a newQueryString
which compiles down toround(price) * 2
in SQL.