--
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 jooq-user+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
There's definitely room for improving the documentation around the MockDataProvider... There are MANY cases where I would like to use the bind values to help determine the result sets and that is not documented anywhere other than playing with the API. I will try to write up some concise docs on using the bind values as well as the query matching to be added. Other than that, I imagine it would be ideal to just somehow pass an identifier somehow so that you can explicitly choose a mock result for each query... I'm not sure what that would look like or how it could be implemented; but I will think on it..
Pull request cancelled and recreated after implementing unit tests and more debugging.
Also, looks like the TravisCI builds are all passing and so it appears there will be no regressions by incorporating these changes...
Woot!
class MyLocalProvider implements MockDataProvider {int selector;@Overridepublic MockResult[] execute(MockExecuteContext c) throws SQLException {DSLContext ctx = DSL.using(SQLDialect.POSTGRES);Field<Object> field = DSL.field("one");Result<Record1<Object>> result = ctx.newResult(field);result.add(ctx.newRecord(field));if (selector == 0) {result.get(0).setValue(field, 1);return new MockResult[] { new MockResult(1, result) };}else {// Sneaky bug emulationresult.get(0).setValue(field, 2);return new MockResult[] { new MockResult(0, result) };}}}MyLocalProvider p = new MyLocalProvider();
// Note: INSERT .. RETURNING is hard to mock for all dialects...DSLContext ctx = DSL.using(new MockConnection(p), SQLDialect.POSTGRES);p.selector = 0;System.out.println(ctx.selectOne().fetch());p.selector = 1;System.out.println(ctx.selectOne().fetch());
+----+| one|+----+| 1|+----++----+| one|+----+| 2|+----+
--