PostgresSchema { public static void getById(final QueryStatement statement, final CollectionName collection) throws QueryBuildException { try { Writer body = statement.getBodyWriter(); body.write("SELECT "); body.write(DOCUMENT_COLUMN); body.write(" FROM "); body.write(collection.toString()); body.write(" WHERE ("); body.write(getIdFieldPath(collection).toSQL()); body.write(") = to_json(?)::jsonb"); } catch (IOException e) { throw new QueryBuildException("Failed to build getById 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 testGetById() throws QueryBuildException { PostgresSchema.getById(statement, collection); assertEquals("SELECT document FROM test_collection " + "WHERE (document#>'{test_collectionID}') = to_json(?)::jsonb", body.toString()); }