Given this example, I would expect that in both cases the default value of 
user.admin gets set.

from sqlalchemy import *
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker, scoped_session

engine = create_engine('sqlite:///:memory:', echo=True)
Base = declarative_base(bind=engine)
Session = scoped_session(sessionmaker(engine))

metadata = Base.metadata

user = Table('user', metadata,
Column('id', Integer),
Column('name', String),
Column('admin', Boolean, default=False)
)

metadata.create_all()

print insert(user).values({'id': 1, 'name': 'Max'})

# this is a contrived example, but it demonstrates the problem
print insert(user).from_select([user.c.id, user.c.name], select([user.c.id, 
user.c.name]).where(user.c.name=='Max'))


The first insert() gets resolved to
> INSERT INTO user (id, name, admin) VALUES (?, ?, ?)

which is fine, but the second intert().from_select() does not gets admin 
set.
> INSERT INTO user (id, name) SELECT user.id, user.name FROM user WHERE 
user.name = ?


-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to