Chris McGrath’s Blog

Just another Developer’s Blog

Archive for August 2009

SQL Generators

leave a comment »

SQL Generators are known for how many brackets they love to put in. So many in fact it made a simple query hard to understand.

Like most professional developers I don’t spend too much time using generators, I much prefer to write the query myself. And I generally stay away from DataSets completely. But today I had to paste my SQL into a query in a DataSet, and I noticed how Microsoft had tried to optimise the Builder so when it reformatted my SQL it didn’t have so many brackets.

The problem was it removed the useful brackets and added useless ones.

Here’s what I entered…

(x1 = x2 AND y1 = y2) OR (n1 = n2 AND m1 = m2)

And here’s what it optimised it to…

(x1 = x2) AND (y1 = y2) OR (n1 = n2) AND (m1 = m2)

How completely stupid! The main reason anyone adds brackets in SQL is to make the order of operations absolutely clear. Yet it removes those ones and adds sets around single statements.

The query might be correct but a human has trouble – not everyone knows the order of operations with booleans.

Written by Chris McGrath

August 31, 2009 at 4:16 pm

Posted in Blog

Tagged with ,

New Domain.

leave a comment »

I’ve finally decided to buy a proper domain. So my site is now at http://cpmcgrath.com. Still setting everything up but this site is now obsolete.

Written by Chris McGrath

August 13, 2009 at 4:56 pm

Posted in Blog