?

Log in

No account? Create an account
July 25th, 2008 - Adventures in Engineering — LiveJournal
The wanderings of a modern ronin.

Ben Cantrick
  Date: 2008-07-25 16:03
  Subject:   SELECT * considered problematic.
Public
  Tags:  reddit

Self-Documentation Lost

If you've ever had the task of diving into someone else's code in the attempt to make bugfixes, changes or even just understand it then you may have run across SQL queries such as:

SELECT *
FROM products
WHERE prod_id = n;

Very nice, legal SQL, sure. But what are we getting back? 1 field? 10? 100? What are the field names and in which order do they appear? Yes, you may have the luck of having a whole db layout right in front of you, but maybe not. Maybe there is some internal documentation, but maybe it's from last August when the db was built and maybe it's changed since then. Maybe there is no documentation except the database itself. Bad practice? Sure, but welcome to the real world.

Either you're going to have to dig through the docs or you're going to have to connect to the db and figure out what the table looks like. However, even though you now have the table layout in front of you, you still don't know what assumptions the original coder was making nor which data he intends to actually use until he uses it.


http://parseerror.com/sql/select*isevil.html
3 Comments | Post A Comment | | Link



browse
May 2015