On Jan 8, 12:25 am, Michael Bayer <[EMAIL PROTECTED]> wrote:
> passivedefaults are reflected in 0.4 just as they are in 0.3, as much  
> as the underlying database allows them to be discovered.

Thanks for the quick reply.  I reduced this to a small example and it
seems the failure I'm encountering is specifically with NOT NULL
columns that default to the empty string:

CREATE TABLE `monkey` (
  `DefaultsToEmptyString` char(8) NOT NULL DEFAULT '',
  `Id` int(11) NOT NULL,
  PRIMARY KEY (`Id`)
) ENGINE=InnoDB;

#!/usr/bin/env python
from sqlalchemy import Table, MetaData, create_engine
from sqlalchemy.orm import mapper, sessionmaker

class Monkey(object):
    pass

engine = create_engine('mysql:...')
SessionMaker = sessionmaker(bind=engine, autoflush=True,
transactional=True)
session = SessionMaker()
metadata = MetaData(bind=engine)

monkey = Table('monkey', metadata, autoload=True)
mapper(Monkey, monkey)

george = Monkey()
george.Id = 1

session.save(george)
session.commit()

...yields the exception:
sqlalchemy.exceptions.OperationalError: (OperationalError) (1048,
"Column 'DefaultsToEmptyString' cannot be null") u'INSERT INTO monkey
(`DefaultsToEmptyString`, `Id`) VALUES (%s, %s)' [None, 1]

Again, if I add a PassiveDefault('') manually into a Table(), then
everything works fine under SA, which makes me think that SA is simply
not autoload'ing my DEFAULT '' for NOT NULL columns...

--~--~---------~--~----~------------~-------~--~----~
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