by scrollaway · 8y ago · 0 comments
For example: Let's say you have a piece of code that does: id, value = query("select * from tbl").fetch_one(). Now that works great if you know you have exactly the columns id and value in there. But let's say they swap places (possible in mysql), or a third column is added, and you don't update your code alongside it. Now that code breaks. Had you done "select id, value from tbl", it wouldn't break.
PS: The sibling answers are also all correct; there's more reasons not to use select * outside of the shell.
Well thank you for explaining your reasons.
Maybe that's the antipattern! But it's also a feature so I feel like you're better off avoiding the
. Also, if someone adds additional big columns, you may incur additional, unnecessary costBut doctor, it hurts when I [don't use an ORM/ORM-generated queries]
Don't litter in the streets, don't litter in your code. If you make an unmaintainable mess and it hurts, you are entirely responsible for owning it.