Moved all SqlQuery creation into SqlDialect

After going back and forth on this, I think it's better to encapsulate
all this in SqlDialect. There are some things it's just not reasonable
to do in Session so it's not like we could get rid of SqlDialect anyway.