On 02/19/2016 11:52 PM, [email protected] 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.
|
import sqlalchemy as sa
import sqlalchemy.orm as saorm
from sqlalchemy.ext.declarative import declarative_base
engine =
sa.create_engine('mssql+pymssql://badams:[email protected]: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
<[email protected] <mailto:[email protected]>> wrote:
On Fri, Feb 19, 2016 at 9:30 PM, <[email protected]
<mailto:[email protected]>> 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 [email protected]
<mailto:[email protected]>.
To post to this group, send email to [email protected]
<mailto:[email protected]>.
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 [email protected]
<mailto:[email protected]>.
To post to this group, send email to [email protected]
<mailto:[email protected]>.
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.