Working with Postgres Jsonb
- Dominant language
- Clojure
- Stars
- 576
- Forks
- 48
- PR merge metrics
- No merged PRs in 30d
Description
I'm trying to integrate Toucan into a project that uses Postgres, but I can't insert into a Jsonb column. Here's the model:
```
(m/add-type! :json
:in json/generate-string
:out #(json/parse-string % keyword))
(m/defmodel Integration :integrations
m/IModel
(m/types [_]
{:data :json}))
```
And here's the error:
```
user=> (db/insert! Integration {:registration "123" :data {"a" "b"}})
(db/insert! Integration {:registration "123" :data {"a" "b"}})
2019-04-09 19:04:13,218 [nRepl-session-f8c664bb-fa71-4a5c-b061-be9ef18ff331] DEBUG toucan.db - DB Call: INSERT INTO "integrations" ("registration", "data") VALUES (?, ())
Execution error (PSQLException) at org.postgresql.core.v3.QueryExecutorImpl/receiveErrorResponse (QueryExecutorImpl.java:2477).
ERROR: syntax error at or near ")"
Position: 66
```
I've followed the docs to the letter, but it doesn't work. Thanks!
@camsaul
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the `m/add-type!` JSON registration, the `Integration` model's `:data :json` type, and the `db/insert!` call shown in the report. Reproduce the generated INSERT against PostgreSQL and determine what change is needed for the Jsonb value to be inserted without the reported syntax error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- clojure, postgresql
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100