Hacker News new | past | comments | ask | show | jobs | submit login

The addition of `sql.Null[T]` is great. I'll probably start using that in new projects. In current stuff, I'm relying on sqlboiler's null [0] whose API is very similar — it works the same way as `sql.Null` will, but has an additional `IsSet() bool` method that tells you whether or not the value was ever explicitly set, to help you distinguish "intentionally null" from "null due to uninitialization". (Sounds nice, but I've never once used it.)



Curious when you need to know when null is intentional or not. There's no corresponding type like that in the db.


For example when you are using partially populated record to update the database. If field is null intentionally it means it should be updated to it. If it's not set the update statement should not touch it.


This is a great explanation. Sqlboiler allows you to send an update that will infer which values have changed and should be written — I bet that’s related to this. TIL!


Thanks. That makes sense. I don't have that pattern in my code but I can see that some might.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: