PostgresSchema { public static void update(final QueryStatement statement, final CollectionName collection) throws QueryBuildException { try { Writer body = statement.getBodyWriter(); body.write("UPDATE "); body.write(collection.toString()); body.write(" SET "); body.write(DOCUMENT_COLUMN); body.write(" = ?::jsonb WHERE ("); body.write(getIdFieldPath(collection).toSQL()); body.write(") = to_json(?)::jsonb"); } catch (IOException e) { throw new QueryBuildException("Failed to build update body", e); } } private  PostgresSchema(); static void create(final QueryStatement statement, final CollectionName collection, final IObject options); static FieldPath getIdFieldPath(final CollectionName collection); static void insert(final QueryStatement statement, final CollectionName collection); static void update(final QueryStatement statement, final CollectionName collection); static void getById(final QueryStatement statement, final CollectionName collection); static void search(final QueryStatement statement, final CollectionName collection, final IObject criteria); static void delete(final QueryStatement statement, final CollectionName collection); static void count(final QueryStatement statement, final CollectionName collection, final IObject criteria); static final String DOCUMENT_COLUMN; static final String FULLTEXT_COLUMN; static final String ID_FIELD_PATTERN; static final String FTS_DICTIONARY; static final int DEFAULT_PAGE_SIZE; }
@Test public void testUpdate() throws QueryBuildException { PostgresSchema.update(statement, collection); assertEquals("UPDATE test_collection " + "SET document = ?::jsonb " + "WHERE (document#>'{test_collectionID}') = to_json(?)::jsonb", body.toString()); }