Hi Guillaume,

Thanks for pointing this out. You're right, this is missing. There should
be overloaded methods like:

<T1> Result<Record1<T1>>     newResult(Field<T1> field1);

<T2> Result<Record2<T1, T2>> newResult(Field<T1> field1, Field<T2> field2);


Similar methods exist for constructing records, but not for constructing
Results. I have registered issue #3139 for this:
https://github.com/jOOQ/jOOQ/issues/3139

As a workaround, you can patch jOOQ to construct such Result objects
yourself. If you look at the existing newResult() method, it only does:

    @Override
    public <R extends Record> Result<R> newResult(Table<R> table) {
        return new ResultImpl<R>(configuration, table.fields());
    }

So you could make the ResultImpl accessible through reflection, and pass
your own set of fields to the constructor.

Hope this helps,
Lukas

2014-03-19 23:02 GMT+01:00 <[email protected]>:

> Hi !
>
> I'm trying to setup unit tests with jOOQ using MockDataProvider and
> MockConnection.
> I'm having issues setting up a simple unit test where my query does not
> return a simple Record.
>
> The documentation http://www.jooq.org/doc/3.2/manual/tools/jdbc-mocking/uses 
> the following:
>
>             Result<AuthorRecord> result = create.newResult(AUTHOR);
>             result.add(create.newRecord(AUTHOR));
>             result.get(0).setValue(AUTHOR.ID, 1);
>             result.get(0).setValue(AUTHOR.LAST_NAME, "Orwell");
>             mock[0] = new MockResult(1, result);
>
>
> However, if my jOOQ query is a simple
>
> create.select(DSL.count()).from(AUTHOR))
>
> How should I mock the result? I cannot use create.newResult(?)since the
> count isn't a Field in any Record.
> I haven't found a simple way to create a MockResult instance based on a
> bunch of fields that are not part of a Record object.
> Are there any examples of this online?
>
> Thanks !
> Guillaume
>
> --
> 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.
>

-- 
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