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
Can Active Record stop treating blank? as nil in #9999
Labels
Comments
|
|
Cool! will do, first thing next week. |
SamSaffron
added a commit
to SamSaffron/rails
that referenced
this issue
Apr 3, 2013
…for empty? as opposed to blank? This is both faster and more correct, added tests to make sure this is not reverted again.
|
@tenderlove @carlosantoniodasilva , sent through a PR, also corrected the test suite so this is not reverted again. Only breaking change is on booleans, time and data are functionally equivalent. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have been looking at some very minor perf issues that have been bugging me in Active Record.
In particular this revert by @carlosantoniodasilva :
111611b#commitcomment-2894962
At Discourse I notices blank? on string is being called a lot:
This is mostly originating from the reverted change in AR, once you replace apply the changes in the reverted commit the cost drops way down:
Let's pretend String#blank? was empty?

The revert bothers me cause its pointlessly slower and dictates a rather odd semantics:
Any unicode space is always treated as nil for boolean columns.
A single char that is not a unicode space is treated as false
@tenderlove agrees that treating non empty strings as null is odd and a db adapter issue as opposed to something that should be handled in core.
I can go ahead and put a PR in place that reverts this, and nukes some of the odd tests for this behavior like.
7f160b0
introduced with the resolution of:
#6045
For Discourse I am working around this by implementing blank? natively, https://github.com/SamSaffron/fast_blank ... and staying consistent with .strip.length == 0 ... treating odd unicode spaces as text.
However, this odd AR behaviour kind of bothers me, and I am not sure why:
"\r\n\v\f\r\s\u00A0\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000"really means NULL and "\u1999" means not NULLCan we revert
connection_adapters/column.rbto do empty? checks instead, reverting all the problem tests?The text was updated successfully, but these errors were encountered: