You can use the "op" method:
https://docs.sqlalchemy.org/en/14/core/sqlelement.html#sqlalchemy.sql.expression.Operators.op
some_column.op("||")(other_column)
Hope that helps,
Simon
On Mon, May 24, 2021 at 4:12 PM Massimiliano della Rovere
<[email protected]> wrote:
>
> In postgresql the || operator is the only way (no, the concat() function
> doesn't work) to concat 2 JSONB dicts; note that this works only with JSONB
> and not JSON.
>
> Example:
>
> suppose column "t.c" contains '{"a": 1}'::jsonb
>
> SELECT t.c || jsonb_build_object('b', 2);
>
> gives
>
> {"a": 1, "b": 2}
>
> Question: How can I obtain the || operator in sqlalchemy (core, 1.3) to merge
> 2 JSONB dicts?
>
>
> --
> SQLAlchemy -
> The Python SQL Toolkit and Object Relational Mapper
>
> http://www.sqlalchemy.org/
>
> To post example code, please provide an MCVE: Minimal, Complete, and
> Verifiable Example. See http://stackoverflow.com/help/mcve for a full
> description.
> ---
> You received this message because you are subscribed to the Google Groups
> "sqlalchemy" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sqlalchemy/CADKhPGRmKtTvZa4jpWby67v7fO-xbO31oJm%3D8jpb%2BrKS5_t2WQ%40mail.gmail.com.
--
SQLAlchemy -
The Python SQL Toolkit and Object Relational Mapper
http://www.sqlalchemy.org/
To post example code, please provide an MCVE: Minimal, Complete, and Verifiable
Example. See http://stackoverflow.com/help/mcve for a full description.
---
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/sqlalchemy/CAFHwexdnftgwEef9pOZ5UK3VTgLLziFTY%2B%2BRTbz1bgk56-3SyQ%40mail.gmail.com.