Query preparation improvements

 * Avoids double preparation of array values (bug fix)
 * Prepare mapped, embedded objects (new feature)

The test case is based on #611, which this PR supersedes.