'Test merge with replace of a unique-field'

def testMergeReplaceUnique(self):

    assertEqual = self.assertEqual
    assertNotEqual = self.assertNotEqual
    assertTrue = self.assertTrue
    assertFalse = self.assertFalse
    tablename = self.tablename
    resource = current.s3db.resource(tablename)
    success = resource.merge(self.id1, self.id2, replace=['name'])
    assertTrue(success)
    db = current.db
    table = db[tablename]
    row1 = db((table.id == self.id1)).select(table.name, table.deleted, table.deleted_rb, limitby=(0, 1)).first()
    row2 = db((table.id == self.id2)).select(table.name, table.deleted, table.deleted_rb, limitby=(0, 1)).first()
    assertNotEqual(row1, None)
    assertNotEqual(row2, None)
    assertFalse(row1.deleted)
    assertTrue(row2.deleted)
    assertEqual(str(self.id1), str(row2.deleted_rb))
    assertEqual(row1.name, 'TestRecord2')
    assertEqual(row2.name, 'TestRecord1')
