Improve SQLTemplates usage in codegen