On 5/5/15 1:17 PM, Brecht Machiels wrote:
Oops, was a bit too quick there...

Here's the echo='debug' output:

2015-05-05 19:16:11,528 INFO sqlalchemy.engine.base.Engine SELECT * FROM group_counts WHERE group_id = 1
2015-05-05 19:16:11,528 INFO sqlalchemy.engine.base.Engine ()
2015-05-05 19:16:11,528 DEBUG sqlalchemy.engine.base.Engine Col ('group_id', 'value', 'count')
2015-05-05 19:16:11,528 DEBUG sqlalchemy.engine.base.Engine Row (1, 1, 6)
2015-05-05 19:16:11,528 DEBUG sqlalchemy.engine.base.Engine Row (1, 2, 12) 2015-05-05 19:16:11,528 DEBUG sqlalchemy.engine.base.Engine Row (1, 3, 103)

versus

2015-05-05 19:16:11,529 INFO sqlalchemy.engine.base.Engine SELECT group_counts.group_id AS group_counts_group_id, group_counts.value AS group_counts_value, group_counts.count AS group_counts_count
FROM group_counts
WHERE group_counts.group_id = ?
2015-05-05 19:16:11,529 INFO sqlalchemy.engine.base.Engine (1,)
2015-05-05 19:16:11,529 DEBUG sqlalchemy.engine.base.Engine Col ('group_counts_group_id', 'group_counts_value', 'group_counts_count')
2015-05-05 19:16:11,529 DEBUG sqlalchemy.engine.base.Engine Row (1, 1, 6)
2015-05-05 19:16:11,530 DEBUG sqlalchemy.engine.base.Engine Row (1, 2, 12) 2015-05-05 19:16:11,530 DEBUG sqlalchemy.engine.base.Engine Row (1, 3, 103)

Only the first item is returned, however.
these two queries are against the same table. I thought we were comparing the SELECT results from a set of real tables vs. views?

I'm not yet looking at what the specifics are yet, but keep in mind the ORM only returns full objects for rows that have a full primary key *and* it deduplicates on primary key, because we use an identity map. So if above, "group_counts_group_id" is your primary key, the ORM has no choice but to give you only one object back.





Brecht

On Tue, 05 May 2015 19:14:56 +0200, Brecht Machiels <brecht__gm...@mos6581.org> wrote:

On Tue, 05 May 2015 18:48:53 +0200, Mike Bayer <mike...@zzzcomputing.com> wrote:

On 5/5/15 11:24 AM, Brecht Machiels wrote:
Hello,

I'm running into a problem with a database view. Please see the attached script for a minimal example that reproduces the problem. The code and the comments should make clear what I want to achieve.

I expect the two queries at the end of the script to return the same result, but they don't.

Is this a bug, or am I just not understanding what is going on?

not sure. Try running your program with echo='debug' on your create_engine(), which will illustrate the SQL statements as well as the raw results coming back from each. If those don't match, then that's the problem.

They look equivalent to me:

2015-05-05 19:13:18,937 INFO sqlalchemy.engine.base.Engine SELECT * FROM group_counts WHERE group_id = 1
2015-05-05 19:13:18,937 INFO sqlalchemy.engine.base.Engine ()

versus

2015-05-05 19:13:18,938 INFO sqlalchemy.engine.base.Engine SELECT group_counts.group_id AS group_counts_group_id, group_counts.value AS group_counts_value, group_counts.count AS group_counts_count
 FROM group_counts
WHERE group_counts.group_id = ?
2015-05-05 19:13:18,938 INFO sqlalchemy.engine.base.Engine (1,)

Best regards,
Brecht


--
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/d/optout.

Reply via email to