Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NULL JSON field fails to Scan into json.RawMessage #3373

Open
Jille opened this issue May 10, 2024 · 0 comments
Open

NULL JSON field fails to Scan into json.RawMessage #3373

Jille opened this issue May 10, 2024 · 0 comments
Labels
bug Something isn't working triage New issues that hasn't been reviewed

Comments

@Jille
Copy link
Contributor

Jille commented May 10, 2024

Version

1.26.0

What happened?

I have a MariaDB table with a nullable JSON column but selecting it when the value is NULL fails to Scan() it into the field.

I'm using the github.com/go-sql-driver/mysql driver.

Relevant log output

sql: Scan error on column index 1, name "my_json_column": unsupported Scan, storing driver.Value type <nil> into type *json.RawMessage


### Database schema

```sql
CREATE TABLE authors (
  id   INT PRIMARY KEY,
  bio  JSON
);

SQL queries

-- name: GetAuthor :one
SELECT * FROM authors WHERE id = ?;

Configuration

No response

Playground URL

https://play.sqlc.dev/p/8e1085762b38b90fb51da2bdac5fe4d2b37d6b89cfae5562063e295d3a829a18

What operating system are you using?

Linux

What database engines are you using?

MySQL

What type of code are you generating?

Go

@Jille Jille added bug Something isn't working triage New issues that hasn't been reviewed labels May 10, 2024
@Jille Jille changed the title NULL JOSN NULL JSON field fails to Scan into json.RawMessage May 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage New issues that hasn't been reviewed
Projects
None yet
Development

No branches or pull requests

1 participant