-
Notifications
You must be signed in to change notification settings - Fork 270
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
Serialize ''(empty) string to empty database value #66
Conversation
Also you can use empty string as 'no value' state because of avoiding NULL in MySQL (http://dev.mysql.com/doc/refman/5.6/en/data-size.html) |
Hey @Romamo thanks for the pull request (and sorry for the delay)—I'm trying to reproduce this on my end but having trouble. Could you send over a test case that might help me debug this? Here's what I've got, but I'm not sure I'm capturing the issue:
|
Hey @Romamo feel free to re-open this if you can help come up with a test case I can add. We've had a lot of edge-case regressions with empty strings (""), so I don't want to make this change without one. If you can help me with the test case that demonstrates this issue, I should be able to get this fixed. |
My patch supports stored empty string in database (not "[]"). Storing "empty"(sure []) JSON will be saved as empty zero-length string in database. I think this is more friendly to use, to create new fields and saves some disk space and performance. |
@Romamo I'm working my way through some of the high priority issues and do plan on exploring this more—however this needs to be tested really well (specifically because we've had a bunch of bugs around an empty JSON object being None/""/{}/[]/etc...) I plan on addressing this but the tests + research are the limiting factor. Any help there is appreciated and will help this get fixed sooner. Thanks! |
First you must define what is empty JSON object. May be empty == default ? json = JSONField(default='""') So, '""' will be stored in DB as empty zero-sized string. [] is empty but not default and will be stored as []. |
Hey guys, I'm getting burned by this bug right now o n Postgres 9.3. |
A test would really help speed this along. I'm slammed right now so just haven't been able to get to it—and last time testing/repeating the bug was the blocker. If someone can put a failing case together I'll be able to get this knocked out sooner. |
@bradjasper this package is quite helpful so it's no wonder it's popularity has exploded. |
Happy to add more collaborators if anyone is interested. Are you volunteering @tutuca? :) |
Please reopen this pull request with an updated diff against version 2.0.0 if there is still interest. |
Uses ""(empty) string in database to store empty json ([]).
You can use empty value as default for your table fields.
You will have no overhead in database if you have no data.