I just updated my version of SA by checking out what is in TRUNK, and
noticed the following which seems like a bug. I run the following
code:
uow = objectstore.begin()
s = Session()
s.secret = 'secret'
s.logon = 'testuser'
uow.commit()
# Works just fine
uow = objectstore.begin()
s2 = Session()
s2.secret = 'secret2'
s2.logon = 'testuser2'
uow.commit()
# Wroks just fine
uow = objectstore.begin()
s3 = Session()
s3.secret = 'secret3'
s3.logon = 'testuser3'
s3.timestamp = datetime.datetime.now()
uow.commit()
# Returns the following exception: TypeError: argument 1 must be
DateTime, not datetime.datetime
# and I continue
uow = objectstore.begin()
s4 = Session()
s4.secret = 'secret3'
s4.logon = 'testuser3'
uow.commit()
# The commit no longer works! As a matter of fact no new create of a
Session object works after the exception!
Now the exception arose because I was using datetime instead of mx's
DateTime, however it does seem strange that commits would stop working
because of an exception.
Below are all the definitions which I hope can help reproduce the problem:
CREATE TABLE sessions (
sess_id VARCHAR(128) NOT NULL PRIMARY KEY,
sess_logon TEXT NOT NULL,
sess_ts TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (sess_logon) REFERENCES users (usr_logon) ON DELETE
cascade ON UPDATE cascade
) WITHOUT OIDS;
CREATE TABLE users (
usr_id BIGSERIAL NOT NULL PRIMARY KEY,
usr_logon TEXT NOT NULL,
usr_name TEXT NOT NULL,
usr_passwd TEXT NOT NULL,
UNIQUE(usr_logon)
) WITHOUT OIDS;
users = Table('users', db,
Column('usr_id', Integer, Sequence('users_id_seq',optional=False),
primary_key=True),
Column('usr_logon', String, nullable=False),
Column('usr_pp', String, nullable=False),
Column('usr_name', String, nullable=False))
sessions = Table('sessions', db,
Column('sess_id', Integer,
Sequence('sessions_id_seq',optional=False), primary_key=True),
Column('sess_logon', String, ForeignKey('users.usr_logon'),
nullable=False),
Column('sess_ts', DateTime, nullable=True))
assign_mapper(Session, tables.sessions, properties={
'secret': tables.sessions.c.sess_id,
'logon': tables.sessions.c.sess_logon,
'timestamp': tables.sessions.c.sess_ts,})
assign_mapper(User, tables.users, properties={
'usr_id': tables.users.c.usr_id,
'logon': tables.users.c.usr_logon,
'passwd': tables.users.c.usr_passwd,
'name': tables.users.c.usr_name,})