#6522·knex

PG: toPathForJson complex path

Author: jbnoblotCreated Aug 27, 2026Updated Aug 27, 2026

Hello,

I think i find a bug in toPathForJson for pg dialect cause in my code i try to this.knexConn.jsonSet("status", "$.object1.object2.object3.property", 2);

but result in my jsonb column after update i don't have

javascript
object1: {
 object2: {
  object3: {
    property: 2
  }
 }
}

BUT

javascript
object1: {
 object2: {
  object3: {
    property: 0
  }
 }
"object2.object3.property": 2
}

AFTER look in code i think this line is an error

https://github.com/knex/knex/blob/e25d54bcb707714a17f5a5744eba5c4246bb4d1d/lib/dialects/postgres/index.js#L340

in js doc:

If pattern is a string, only the first occurrence will be replaced.

so maybe use a regex like .replace(/\./g, ',')

thanks a lot for your amazing library