This test fails (any idea why?):

---

from sqlalchemy.orm import scoped_session, sessionmaker, relation
from sqlalchemy import exceptions, create_engine, MetaData, Table,
Column, types

metadata = MetaData()

users_table = Table("users", metadata,
    Column("id", types.Integer, primary_key=True),
    Column("host", types.String(16), nullable=False),
    Column("name", types.String(16), nullable=False),
)

class User (object):

    def __init__ (self, **kwargs):
        self.id = kwargs.get("id")
        self.name = kwargs.get("name")
        self.host = kwargs.get("host")

Session = scoped_session(sessionmaker(transactional=True,
autoflush=True))

Session.mapper(User, users_table, properties=dict(
    id = users_table.c.id,
    name = users_table.c.name,
    host = users_table.c.host,
))

def test_host ():
    metadata.bind = create_engine("sqlite:///:memory:")
    metadata.create_all()
    user = User(name="monty", host="localhost")
    Session.commit()
    metadata.drop_all()
    metadata.create_all()
    user = User(name="python")
    assert user.host is None
    try:
        Session.commit()
    except exceptions.IntegrityError:
        pass
    else:
        assert False
    Session.close()
    metadata.drop_all()


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to