cockroachdb / cockroachdb/cockroach
Inconsistent `null value not allowed for object key` error from `jsonb_object_agg` function
- Dominant language
- Go
- Stars
- 32.5k
- Forks
- 4.1k
- PR merge metrics
- PR metrics pending
Description
**Describe the problem**
Inconsistent `null value not allowed for object key` error from `jsonb_object_agg` function
**To Reproduce**
The following code errors on the second select statement, but not the first:
```sql
CREATE TABLE foo (
tags JSONB NOT NULL
);
INSERT INTO foo VALUES ('{}');
SELECT jsonb_object_agg(key, value)
FROM jsonb_each('{}'::JSONB)
WHERE FALSE;
SELECT (
SELECT jsonb_object_agg(key, value)
FROM jsonb_each(tags)
WHERE FALSE
)
FROM foo;
```
**Expected behavior**
I don't see any functional difference between the two statements so I expect both to work
**Additional data / screenshots**
Both select statements succeed in postgres: https://onecompiler.com/postgresql/42tjfgu8r
**Environment:**
- CockroachDB version 24.2.3
- Server OS: CockroachDB Cloud
- Client app: psql
Jira issue: CRDB-42607
Contributor guide
Assessment
This issue has not been assessed yet.