def _test_lastrow_accessor(self, table_, values, assertvalues):
    'Tests the inserted_primary_key and lastrow_has_id() functions.'

    def insert_values(engine, table_, values):
        '\n            Inserts a row into a table, returns the full list of values\n            INSERTed including defaults that fired off on the DB side and\n            detects rows that had defaults and post-fetches.\n            '
        if engine.dialect.implicit_returning:
            ins = table_.insert()
            comp = ins.compile(engine, column_keys=list(values))
            if (not set(values).issuperset((c.key for c in table_.primary_key))):
                is_(bool(comp.returning), True)
        result = engine.execute(table_.insert(), **values)
        ret = values.copy()
        for (col, id_) in zip(table_.primary_key, result.inserted_primary_key):
            ret[col.key] = id_
        if result.lastrow_has_defaults():
            criterion = and_(*[(col == id_) for (col, id_) in zip(table_.primary_key, result.inserted_primary_key)])
            row = engine.execute(table_.select(criterion)).first()
            for c in table_.c:
                ret[c.key] = row[c]
        return ret
    if testing.against('firebird', 'postgresql', 'oracle', 'mssql'):
        assert testing.db.dialect.implicit_returning
    if testing.db.dialect.implicit_returning:
        test_engines = [engines.testing_engine(options={'implicit_returning': False}), engines.testing_engine(options={'implicit_returning': True})]
    else:
        test_engines = [testing.db]
    for engine in test_engines:
        try:
            table_.create(bind=engine, checkfirst=True)
            i = insert_values(engine, table_, values)
            eq_(i, assertvalues)
        finally:
            table_.drop(bind=engine)
Tests the inserted_primary_key and lastrow_has_id() functions.
def _test_lastrow_accessor(self, table_, values, assertvalues):
    

    def insert_values(engine, table_, values):
        '\n            Inserts a row into a table, returns the full list of values\n            INSERTed including defaults that fired off on the DB side and\n            detects rows that had defaults and post-fetches.\n            '
        if engine.dialect.implicit_returning:
            ins = table_.insert()
            comp = ins.compile(engine, column_keys=list(values))
            if (not set(values).issuperset((c.key for c in table_.primary_key))):
                is_(bool(comp.returning), True)
        result = engine.execute(table_.insert(), **values)
        ret = values.copy()
        for (col, id_) in zip(table_.primary_key, result.inserted_primary_key):
            ret[col.key] = id_
        if result.lastrow_has_defaults():
            criterion = and_(*[(col == id_) for (col, id_) in zip(table_.primary_key, result.inserted_primary_key)])
            row = engine.execute(table_.select(criterion)).first()
            for c in table_.c:
                ret[c.key] = row[c]
        return ret
    if testing.against('firebird', 'postgresql', 'oracle', 'mssql'):
        assert testing.db.dialect.implicit_returning
    if testing.db.dialect.implicit_returning:
        test_engines = [engines.testing_engine(options={'implicit_returning': False}), engines.testing_engine(options={'implicit_returning': True})]
    else:
        test_engines = [testing.db]
    for engine in test_engines:
        try:
            table_.create(bind=engine, checkfirst=True)
            i = insert_values(engine, table_, values)
            eq_(i, assertvalues)
        finally:
            table_.drop(bind=engine)