Provide Executable instances for TableQuery and BaseJoinQuery.

Backported from #782, fixes #746. Test in TemplateTest.testCompiled.

Review by @cvogt