jet icon indicating copy to clipboard operation
jet copied to clipboard

Add postgres JSON cast type

Open wexder opened this issue 3 years ago • 2 comments
trafficstars

Is your feature request related to a problem? Please describe. We are using a lot of json fields in our postgres database. And it's hard to do the UPSERT with json column type. Currect solution I found is double casting the json string.

  insertStm := table.INSERT(table.AllColumns).MODEL(table).
  ON_CONFLICT(table.SomeColumn).DO_UPDATE(
  postgres.SET(
    table.JsonColumn.SET(postgres.StringExp(postgres.CAST(postgres.String(*data)).AS("json"))),
    ),

Describe the solution you'd like Add postgres.Json() func that would return StringExpression.

wexder avatar Jun 04 '22 12:06 wexder

I've create PR for this https://github.com/go-jet/jet/pull/161

wexder avatar Jun 04 '22 12:06 wexder

Hi @wexder. Yeah, it makes sense to have a json literal.

go-jet avatar Jun 06 '22 09:06 go-jet

Support added with v2.9.0 release.

go-jet avatar Sep 30 '22 12:09 go-jet