https://kotlinlang.org logo
#exposed
Title
# exposed
d

Damien

02/06/2022, 8:38 AM
Is there any way to run a sort/select on a jsonb column in Postgres? (e.g.
order by my_json_column->'key' ASC
). Is it possible to write a raw/custom order expression for this? Not sure where to start.
b

Bogdan

02/06/2022, 9:13 AM
Exposed пока tot не поддерживает JSON(B) (https://github.com/JetBrains/Exposed/wiki/DataTypes, https://github.com/JetBrains/Exposed/issues/127). You can declare a column of type string (the database schema must already be created). Or manually implement a new column type (an example can be found in the issue). Assuming this option suits you.
Select and sorting is performed by regular means Exposed
d

Damien

02/06/2022, 9:58 AM
Thanks! I'll take a look. I already have a jsonb extension based on input from one of those issues. Haven't figured out how to select/sort based on the column, though.
b

Bogdan

02/06/2022, 11:22 AM
You need to implement the operators you need. Interface Op. Example: concat function, see implementation for Oracle (OracleDialect.kt). It just acts as an operator, not a function.
🙌 1