OpenGamma / ElSql

Manage external SQL files in Java with a little DSL goodness
Other
101 stars 26 forks source link

Ability to reference the "elsql" file to another folder #14

Closed marcosdefontes closed 9 years ago

marcosdefontes commented 9 years ago

I have a folder structure:

- src/test/java
  -- TestC.java
  -- TestC.elsql

My code is:

    ElSqlBundle bundle = ElSqlBundle.of(ElSqlConfig.POSTGRES, TestC.class);
    String sql = bundle.getSql("SelectTest");
    System.out.println(sql);

And it works!

However with the scructure:

- src/test/java
  -- TestC.java
- src/test/resources
 -- META-INF
  ---- TestC.elsql

I got an error:

    java.lang.IllegalArgumentException: Unknown fragment name: SelectTest
        at com.opengamma.elsql.ElSqlBundle.getFragment(ElSqlBundle.java:233)    
jodastephen commented 9 years ago

As seen in the code here, the elqsl file is looked up on the classpath, so must be in the same classpath location as the class. This will work:

- src/test/java
  - TestC.java
- src/test/resources
  - TestC.elsql

as will this:

- src/test/java
  - com/foo/bar
    - TestC.java
- src/test/resources
  - com/foo/bar
    - TestC.elsql