createPKJsonObject method

String createPKJsonObject(
  1. String rows
)

Implementation

String createPKJsonObject(String rows) {
  // `json_build_object` introduces whitespaces
  // e.g. `{"a" : 5, "b" : 6}`
  // But the json produced by SQLite is `{"a":5,"b":6}`.
  // So this may lead to problems because we use this JSON string
  // of the primary key to compare local and remote entries.
  // But the changes for the same PK would be considered to be different PKs
  // if e.g. the local change is PG and the remote change is SQLite.
  // We use `json_strip_nulls` on the PK as it removes the whitespaces.
  // It also removes `null` values from the PK. Therefore, it is important
  // that the SQLite oplog triggers also remove `null` values from the PK.
  return 'json_strip_nulls(json_build_object($rows))';
}