by chaps · 3y ago · 0 comments
Any code using select * just breaks in the future with any new columns being added, no thanks.
For you, maybe. In my workflows this is really a non-issue for me.Maybe consider that we use SQL differently and your goals and challenges are different from mine.
(Edit: What's with the downvotes from people just disagreeing about preferences? So weird.)
Except for very rare fringe cases, using "SELECT *" in production code is universally considered bad practice.
In a query than returns result rows it could break the query as soon as you add columns with names that already exist in other tables you joined in the query.
1. Given that "select " is considered something to avoid except when necessary in edge cases
2. And "select 1" will accomplish the same goal
Anyone reading the "select
" version of the code will have to stop and consider whether it is using "select " for a reason, because "select 1" would be the normal choice. Using "select " is assumed to be conveying some intent (that isn't there) _because_ it's not the expected way to do it.I kind of see it like
if (thisField == thatField) ...
vs if ( (( true || false )) && ( 11 == 11 ) && thisField == thatField ) ...
Sure, they do the same thing... but you have to stop and look at the second one to make sure you're understanding what it does and if there's some reason its weird.If I was to guess why someone would downvote you, it wouldn't be for disagreeing with you, but more because you've subtly shifted from quite a strong objective stance ("this is not readable") to a subjective one ("this is not how I prefer to write it"), without really conceding anyone else's points.
Not really conceding because as far as 1 can see, everybody is coming from a position of familiarity.
So when you say "my flow is X" and your flow is inimical to maintaining it and extending it, people might get a bit irritated at the last dev that did the exact same thing.