On 02/20/2016 12:28 AM, Mike Bayer wrote:


On 02/19/2016 11:52 PM, bill.ad...@level12.io wrote:
I got a test case working. It seems that the limit/offset operations
have an effect. The script fails less than half the time and so far only
fails when I run python with the -R flag


this reproduces and is a critical issue captured in
https://bitbucket.org/zzzeek/sqlalchemy/issues/3657/positional-result-column-logic-failing.
  the full nature of the failure is not yet understood.

this issue, as well as the related issue of the "NoneType" exception not correctly reporting the failure (https://bitbucket.org/zzzeek/sqlalchemy/issues/3658/orm-load-when-col-is-missing-fails-to) are both resolved and ported to the 1.0 branch. These are both regressions that appeared due to optimizations local to the 1.0 series. Issue 3657 is specific only to the SQL Server and Oracle dialects and 3658 is more general, though would not normally appear outside of this issue and a few other edge cases. The fixes will be released in 1.0.13 which I will most likely try to release in the coming week.

Thanks very much for turning around a very good test case very quickly, for a very difficult issue to isolate no less!









|
import sqlalchemy as sa
import sqlalchemy.orm as saorm
from sqlalchemy.ext.declarative import declarative_base

engine =
sa.create_engine('mssql+pymssql://badams:password@192.168.56.101:1443/testdb',

echo=True)
session = saorm.sessionmaker(bind=engine)()

Base = declarative_base()

class Person(Base):
     __tablename__ = 'people'
     id = sa.Column(sa.Integer, primary_key=True)
     name = sa.Column(sa.String)

Base.metadata.create_all(engine)

session.query(Person).delete()

session.add(Person(name='foo'))
session.add(Person(name='bar'))

session.commit()

results = session.query(
     Person.name.label('person'),
).add_entity(
     Person
).order_by(
     Person.name
)

print results.count()
print results.limit(1).offset(1).all()



|

Thanks,
Bill


On Friday, February 19, 2016 at 11:20:44 PM UTC-5, Bill Adams wrote:

    Yes, that is what I was trying to describe. I've been trying to
    create a simple test case but have as of yet been unable to
    reproduce the problem in a simpler environment. I was hoping someone
    had encountered something similar before. I'll keep trying to get
    that MCVE "working"..

    Thanks,
    Bill

    On Fri, Feb 19, 2016 at 11:13 PM, Mike Bayer
    <clas...@zzzcomputing.com <mailto:clas...@zzzcomputing.com>> wrote:



        On Fri, Feb 19, 2016 at 9:30 PM, <bill.ad...@level12.io
        <mailto:bill.ad...@level12.io>> wrote:


            The issue seems to be occurring for queries where we use the
            add_entity() method to select a declarative model entity
            when a column from the same table is already in the query
            constructor and labeled.


        just to make sure, here is that:

        from sqlalchemy import *
        from sqlalchemy.orm import *
        from sqlalchemy.ext.declarative import declarative_base

        Base = declarative_base()


        class A(Base):
             __tablename__ = 'a'
             id = Column(Integer, primary_key=True)
             x = Column(Integer)

        e = create_engine("postgresql://scott:tiger@localhost/test",
        echo=True)
        Base.metadata.drop_all(e)
        Base.metadata.create_all(e)


        s = Session(e)

        s.add(A(x=5))
        s.commit()

        print s.query(A.x.label("foo")).add_entity(A).all()


        query output at the end:

        BEGIN (implicit)
        2016-02-19 23:12:33,455 INFO sqlalchemy.engine.base.Engine
        SELECT a.x AS foo, a.id <http://a.id> AS a_id, a.x AS a_x
        FROM a
        2016-02-19 23:12:33,455 INFO sqlalchemy.engine.base.Engine {}
        [(5, <__main__.A object at 0x7f0c2fd94990>)]


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




    --

    *Bill Adams*
    Developer
    Direct: 502.276.1006
    Office: 812.285.8766

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

--
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 https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to