On Sat, Oct 26, 2013 at 05:41:04PM -0400, Michael Bayer wrote:
> I’ve released (hopefully without mistakes…) SQLAlchemy 0.8.3 and 0.9.0b1.

Having just updated to 0.8.3 I'm seeing a new SAWarning.  (I'm not quite
sure whether this qualifies as a bug, or whether maybe I was just doing
it wrong.)

Here's the shortest example I've come up with which elicits the warning:

    import sqlalchemy as sa
    from sqlalchemy.ext.declarative import declarative_base

    Base = declarative_base()

    class ModelBase(Base):
        __tablename__ = 'ModelBases'
        id = sa.Column(sa.Integer, primary_key=True)
        model_type = sa.Column(sa.Integer)
        __mapper_args__ = {'polymorphic_on': model_type}

    class Model(ModelBase):
        __tablename__ = 'Models'
        __mapper_args__ = {'polymorphic_identity': 1}
        id = sa.Column(sa.ForeignKey(ModelBase.id), primary_key=True)

    sess = sa.orm.Session()

    model_exists = sess.query(Model).exists()

The last line produces:

[...]/site-packages/sqlalchemy/sql/expression.py:2491: SAWarning: Column 'id' 
on table <sqlalchemy.sql.expression.Select at 0x4203f50; Select object> being 
replaced by Column(u'id', Integer(), table=<Select object>, primary_key=True, 
nullable=False), which has the same key.  Consider use_labels for select() 
statements.
  self[column.key] = column

Adding .with_labels() to the last line quiets the warning:

    model_exists = sess.query(Model).with_labels().exists()

as does changing the name of the ``id`` column to something (anything)
else.

-- 
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 sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to