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

[BUG] Panic when json field is null #42

Closed
jedvardsson opened this issue Apr 24, 2024 · 2 comments
Closed

[BUG] Panic when json field is null #42

jedvardsson opened this issue Apr 24, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@jedvardsson
Copy link

A panic is thrown when a json field is null.

To Reproduce
Steps to reproduce the behavior:

  1. user.json
[
  {
    "user_id": "1",
    "first_name": null,
    "last_name": null,
  }
]
  1. sqly --sql "select * from user limit 1" --csv user.json
goroutine 1 [running]:
github.com/nao1215/sqly/domain/model.(*JSON).ToTable(0x1400010aed0)
	/Users/bob/go/pkg/mod/github.com/nao1215/sqly@v0.5.2/domain/model/json.go:32 +0x5d8
github.com/nao1215/sqly/shell.CommandList.importCommand(0x5?, 0x1400014c8c0, {0x1400007e280?, 0x14000026960?, 0x14000026950?})
	/Users/bob/go/pkg/mod/github.com/nao1215/sqly@v0.5.2/shell/import.go:45 +0x50c
github.com/nao1215/sqly/shell.(*Shell).init(0x1400014c8c0)
	/Users/bob/go/pkg/mod/github.com/nao1215/sqly@v0.5.2/shell/shell.go:128 +0xb0
github.com/nao1215/sqly/shell.(*Shell).Run(0x1400014c8c0)
	/Users/bob/go/pkg/mod/github.com/nao1215/sqly@v0.5.2/shell/shell.go:80 +0x34
main.run({0x140000120f0?, 0x1049cd220?, 0x104d9b068?})
	/Users/bob/go/pkg/mod/github.com/nao1215/sqly@v0.5.2/main.go:30 +0xb4
main.main()
	/Users/bob/go/pkg/mod/github.com/nao1215/sqly@v0.5.2/main.go:16 +0x34

Expected behavior
one row of csv data

user_id,person_name
1,,

Desktop (please complete the following information):

  • macOS Sonoma 14.4.1 (23E224)
  • go version go1.22.2 darwin/arm64
  • sqly v0.5.2

Additional context
Add any other context about the problem here.

@jedvardsson jedvardsson added the bug Something isn't working label Apr 24, 2024
@nao1215
Copy link
Owner

nao1215 commented Apr 26, 2024

@jedvardsson
Thanks for writing two bug reports. It takes time to fix bugs.

@nao1215
Copy link
Owner

nao1215 commented Apr 29, 2024

Fix this bug at PR #46.

@nao1215 nao1215 closed this as completed Apr 29, 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
Projects
None yet
Development

No branches or pull requests

2 participants