5 ms·
According to the Pastebin dump, one user has a user_id = 0 Why would you even design an application to allow that? Even if the user was deleted (as potentially
by minimaxir 13y ago
According to the Pastebin dump, one user has a user_id = 0
Why would you even design an application to allow that? Even if the user was deleted (as potentially indicated by a null phone number), it's still a conflict.
- ronaldx 13y agoWhy do you allow an array index to start at 0? Although I agree that this is not ideal, zero is not null.
- X-Istence 13y agoWhy wouldn't you want a user_id being 0?
- supergauntlet 13y agoI believe it has to do with Unix-like OSes always assigning the UID 0 to root.
- lgas 13y agoThis doesn't make any sense unless for some reason you are creating unix users based on the users in your application and using the application user ID as the unix user ID which would be silly.
- mafuyu 13y agoThe convention of 0 as NULL is more likely, as UID 0 doesn't really make sense in this context.
- 14113 13y agoPerhaps some implementation might consider 0 to be a 'NULL' value, assume it's null data and thus ignore it.
- X-Istence 13y agoNULL != 0.
- thirsteh 13y agoThat never stopped JavaScript, Python and friends from giving them equal truthiness.
- dragonwriter 13y ago> That never stopped JavaScript, Python and friends from giving them equal truthiness. Implicit casts -- including to booleans -- are dangerous, but if you try to write APIs to try to avoid every bad thing that might happen with naive use of implicit casting in every language that might be used to consume your API, you won't be able to do anything at all.
- X-Istence 13y agoEhm, Python doesn't have a NULL: >>> NULL == 0 Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 'NULL' is not defined Even None, which is as close to NULL you are going to get in Python is not 0. >>> None == 0 False
- taway2012 13y agoThis is probably what the parent meant: >>> 'truthy' if None else 'falsy' 'falsy' >>> 'truthy' if False else 'falsy' 'falsy' >>> 'truthy' if 0 else 'falsy' 'falsy'
- aj 13y ago"truthiness" is true/false and NOT NULL! 0 != null null != false
- ijl 13y agoIn [1]: bool(0) Out[1]: False Idiomatic Python may say "if not user_id:" and erroneously skip this.
- GregorStocks 13y agoWhen possible, you should avoid having any userid that could be mistaken for a non-userid number - it prevents a lot of silly programming errors from going unnoticed or turning into bigger problems, and has very little downside. http://www.phabricator.com/docs/phabricator/article/Things_You_Should_Do_Now.html http://www.phabricator.com/docs/phabricator/article/Things_Y...