Merge pull request #2377 from svenjacobs/master
[#2374] INSERT .. RETURNING always returns null for dynamically created tables - Canonical implementation contributed by Steven Jacobs
This commit is contained in:
commit
eb34ebf4d7
@ -35,6 +35,7 @@
|
||||
*/
|
||||
package org.jooq.impl;
|
||||
|
||||
import static org.jooq.impl.Utils.field;
|
||||
import static org.jooq.impl.Utils.fieldArray;
|
||||
import static org.jooq.util.sqlite.SQLiteFactory.rowid;
|
||||
|
||||
@ -383,6 +384,21 @@ abstract class AbstractStoreQuery<R extends Record> extends AbstractQuery implem
|
||||
.where(field.in(ids))
|
||||
.fetchInto(into);
|
||||
}
|
||||
|
||||
// We don't have an identity, maybe because the table has been dynamically created
|
||||
// with Factory#tableByName(). In that case return an "anonymous" result which contains
|
||||
// the generated ids.
|
||||
} else {
|
||||
final Field<Object> idField = field(null);
|
||||
final ResultImpl<R> result = new ResultImpl<R>(configuration, idField);
|
||||
|
||||
for (final Object value : values) {
|
||||
final Record record = Utils.newRecord(RecordImpl.class, new Field[] {idField});
|
||||
record.setValue(idField, value);
|
||||
result.addRecord((R) record);
|
||||
}
|
||||
|
||||
returned = result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user