Closed kaihendry closed 5 years ago
Ok, I'm also asking SO https://stackoverflow.com/questions/55437279/sql-nullint64-to-json
I think I will just use *types / pointers for the optional values to get my JSON as I want it. https://stackoverflow.com/a/55437560/4534
If a schema is say just
age INT
I think you set the type sql.NullInt64. But this generates gnarly JSON mappings likeMy workaround is to then edit the generated type to for the optional value:
However I've noticed that go sets
0
(ZERO) in my JSON to DB mapping with this "workaround".If it was the original
sql.NullInt64
the value in DB would be:Which is more correct in terms of the DBMS, but then how does one handle the JSON ugliness?!
I also have a type issue when it comes to required values (name): https://s.natalian.org/2019-03-31/required.mp4