Empty result for WHERE id='ba6baf95-bf14-4020-b44c-0cad269fb5c9'

Description

CQL2PG converts CQL "id==ba6baf95-bf14-4020-b44c-0cad269fb5c9" to SQL "WHERE id='ba6baf95-bf14-4020-b44c-0cad269fb5c9'".
This is correct because id is the primary key, no need to look into the jsonb field.
PostgresClient always returns an empty result set for this, see this commented out test case:
https://github.com/folio-org/mod-users/blob/f9f1ab8d108d7d507e4df7eb703d001a7b8909a1/src/test/java/org/folio/moduserstest/RestVerticleIT.java#L311-L331

PostgresClient logs this in the log:
Skipping query due to no results expected! SELECT * FROM diku_mod_users.users WHERE id='ba6baf95-bf14-4020-b44c-0cad269fb5c9' LIMIT 10 OFFSET 0

CSP Request Details

None

CSP Rejection Details

None

Potential Workaround

None

Checklist

hide

TestRail: Results

Activity

Show:

Julian Ladisch October 16, 2018 at 1:52 PM

The key change is this line (old, new) in UsersAPI.java:

postgresClient.save(connection, tableName, entity,
postgresClient.save(connection, tableName, entity.getId(), entity,

The new line uses the id from the entity (= jsonb field) and copies it to the primary key field. That way they are the same.

Before the primary key field was initialized with a random UUID that was not used by mod-users so did no harm; but since last week we want to make use of the primary key for fastest single record access so we need them in sync.

Julian Ladisch October 16, 2018 at 11:40 AM

The pull request is ready for code review: https://github.com/folio-org/mod-users/pull/90

Julian Ladisch October 15, 2018 at 11:27 PM

A user record in the database table consists of the id field (primary key) and the jsonb field. mod_users saves the user id in jsonb->'id' whereas the primary key id field gets some random uuid value.

Done

Details

Assignee

Reporter

Tester Assignee

Priority

Development Team

Core: Platform

Fix versions

TestRail: Cases

Open TestRail: Cases

TestRail: Runs

Open TestRail: Runs
Created October 15, 2018 at 1:19 PM
Updated December 15, 2020 at 4:52 PM
Resolved October 16, 2018 at 10:07 PM
TestRail: Cases
TestRail: Runs