assertj / assertj/assertj-db

How to check value on a Postgres JsonB field?

Open
#101 3 comments 0 reactions 1 assignee Claimed by @VanRoy View on GitHub
enhancement question
Dominant language
Java
Stars
130
Forks
21
PR merge metrics
No merged PRs in 30d

Description

I trying to check the values inserted on a table where a field is of the type `jsonb`.

When I run something like this:
```java
assertThat(eventsTable)
.row(0)
.value("data").isEqualTo("{\"key\": \"value\"}");
```
I get the following error:
```
[Value at index 0 (column name : DATA) of Row at index 0 of events table]
Expecting:
<{"key": "value"}>
to be of type
<[TEXT, NUMBER, DATE, TIME, DATE_TIME, UUID]>
but was of type
(org.postgresql.util.PGobject)
```

Here is the table content:
```
[events table]
|-----------|---------|-------------------------------------------------------|
| | | |
| | PRIMARY | DATA |
| | KEY | (NOT_IDENTIFIED : class org.postgresql.util.PGobject) |
| | | Index : 0 |
|-----------|---------|-------------------------------------------------------|
| Index : 0 | | {"key": "value"} |
|-----------|---------|-------------------------------------------------------|
```
Using assertj-db 2.0.0

Is there any way I can check the content of a PostgreSQL `jsonb` column?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.