agentgt / jirm

A Java Immutable object Relational Mapper focused on simplicity, convenience, and thread safety.
Apache License 2.0
66 stars 10 forks source link

SQL template partials #9

Closed agentgt closed 11 years ago

agentgt commented 11 years ago

Allow SQL template partials. The idea is that you often have a the select fields duplicated over and over again this would allow you to validate your selecting on the same fields but unfortunately require copy n' paste

SELECT from blah
-- { > stuff.sql }
blah as "stuff.blah",
foo as "fooBar"
-- { < }
where blah ....

Then stuff.sql would be from the same package or from an explicate classpath. The contents with in the comment would be validated with the contents in stuff.sql.

agentgt commented 11 years ago

Also allow creating partial blocks like:

In stuff.sql :

SELECT from blah
-- {#fields}
blah as "stuff.blah",
foo as "fooBar"
-- {/fields}
where blah ....

In some other SQL file.

SELECT from blah
-- { > stuff.sql#fields }
blah as "stuff.blah",
foo as "fooBar"
-- { < }
where blah ....