Hi,

  When using jOOQ within the Nashorn JavaScript engine, the subsequent 
queries are surrounding the table names with quotation marks.  It should be 
noted that the existing jOOQ code *all works outside of the Nashorn engine*, 
and we have a ton of code already in our code base successfully using many 
different functions of jOOQ.  We saw the following blog entry:

blog.jooq.org/2014/06/06/java-8-friday-javascript-goes-sql-with-nashorn-and-jooq/

  We decided to try to extend our implementation to allow JavaScript to 
dynamically retrieve entries from our database.  However, even when setting 
the render name style as RenderNameStyle.AS_IS, the queries within the 
Nashorn engine surrounds the table names with quotation marks and seems to 
ignore the Settings altogether.

[select * from "example_table" order by example_table.name asc limit ? 
offset ?]; You have an error in your SQL syntax; check the manual that 
corresponds to your MySQL server version for the right syntax to use near 
'"example_table" order by example_table.name asc limit 100 offset 0' at 
line 1
var Tables = Java.type('com.jooq.generated.Tables');

function query() {
 // THIS WORKS:
 // return dsl.fetch('select * from example_table').intoMaps();
 
 // THIS DOES NOT WORK:
 settings.setRenderNameStyle(AS_IS);
 var dsl = jooq.getAtomicDSLContextWithSetting(settings);
 
 return dsl.select().from(Tables.EXAMPLE_TABLE)
 .orderBy(Tables.EXAMPLE_TABLE.NAME)
 .limit(100)
 .offset(0)
 .fetch()
 .intoMaps();
}


  Again, the jOOQ code works outside of the Nashorn engine.  Only when it's 
evaluated through Nashorn does this error surface.  Here is some sample 
code to run the Nashorn engine:

ScriptEngineManager factory = new ScriptEngineManager();
ScriptEngine engine = factory.getEngineByName("JavaScript");
engine.put("jooq", this.jooqUtils);

Settings s = new Settings();
s.setExecuteLogging(true);
s.setRenderNameStyle(RenderNameStyle.AS_IS);
engine.put("settings", s);

Invocable inv = (Invocable) engine;
engine.eval(file);
// invoke the global function named "query"
List<Map<String, Object>> results = (List<Map<String, Object>>) 
inv.invokeFunction("query");
if (results != null) {
Gson gson = new GsonBuilder().create();
return gson.toJson(results);
}


  Has anyone tried running jOOQ within Nashorn and/or ran into these types 
of problems?

Thanks,

Matt














-- 
You received this message because you are subscribed to the Google Groups "jOOQ 
User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to