function testAttach_Error() {
  var scope = [j, e];
  var newJobId = 'SomeUniqueId';

  return tx.begin(scope)
      .then(function() {
    var q0 = db.select().from(j);
    return tx.attach(q0);
      })
      .then(function(results) {
    assertEquals(sampleJobs.length, results.length);

    // Adding a new job row.
    var newJob = j.createRow();
    newJob.setId(newJobId);
    var q1 = db.insert().into(j).values([newJob]);
    return tx.attach(q1);
  }).then(function() {
    var q2 = db.select().from(j).where(j.id.eq(newJobId));
    return tx.attach(q2);
  }).then(function(results) {
    assertEquals(1, results.length);

    var q3 = db.select().from(j);
    return tx.attach(q3);
  }).then(function(results) {
    assertEquals(sampleJobs.length + 1, results.length);

    // Attempting to add an employee row that already exists.
    var q4 = db.insert().into(e).values([sampleEmployees[0]]);
    return tx.attach(q4);
  }).then(null, function(e) {
    // 201: Duplicate keys are not allowed.
    assertEquals(201, e.code);

    // Checking that the transaction has been finalized.
    // 107: Invalid transaction state transition: {0} -> {1}.
    lf.testing.util.assertThrowsError(107, attachFn);
    lf.testing.util.assertThrowsError(107, commitFn);
    lf.testing.util.assertThrowsError(107, rollbackFn);
    lf.testing.util.assertThrowsError(107, beginFn);

    return lf.testing.util.selectAll(global, j);
          })
      .then(function(results) {
        // Checking that the entire transaction was rolled back, and therefore
        // that Job row that had been added does not appear on disk.
    assertEquals(sampleJobs.length, results.length);

    // Checking that all locks have been released, which will allow other
    // transactions referring to the same scope to execute successfully.
    return db.select().from(j).exec();
      })
      .then(function(results) {
    assertEquals(sampleJobs.length, results.length);
  });
}
Tests that if an attached query fails, the entire transaction is rolled back.
@return {!IThenable}