Re: [sqlalchemy] Selected subqueries with table inheritance don't correlate correctly

2017-10-02 Thread Michael Williamson
On Mon, 2 Oct 2017 10:00:43 -0400 Mike Bayer <mike...@zzzcomputing.com> wrote: > On Mon, Oct 2, 2017 at 7:18 AM, Michael Williamson > <michael.william...@healx.io> wrote: > > I'm trying to select a value using a correlated subquery that uses > > table inheritance,

[sqlalchemy] Selected subqueries with table inheritance don't correlate correctly

2017-10-02 Thread Michael Williamson
I'm trying to select a value using a correlated subquery that uses table inheritance, but the generated query seems to leak the table from the subquery into the outer query. For instance, suppose employee is a table, engineer inherits from employee, and each employee has a foreign key to a

Re: [sqlalchemy] Using CTEs inside union()

2017-02-22 Thread Michael Williamson
On Wed, 22 Feb 2017 11:15:05 -0500 mike bayer <mike...@zzzcomputing.com> wrote: > > > On 02/22/2017 10:17 AM, Michael Williamson wrote: > > Using CTEs directly inside union() (or similar functions such as > > intersect()) causes an error: > > > > &g

[sqlalchemy] Using CTEs inside union()

2017-02-22 Thread Michael Williamson
Using CTEs directly inside union() (or similar functions such as intersect()) causes an error: import os from sqlalchemy.event import listens_for from sqlalchemy import * from sqlalchemy.orm import * from sqlalchemy.ext.declarative import declarative_base Base =

Re: [sqlalchemy] Selecting from polymorphic tables without selecting polymorphic columns

2017-01-17 Thread Michael Williamson
a point release > where it has an admittedly very low chance of breaking someone's > application. > > > > On 01/17/2017 04:19 AM, Michael Williamson wrote: > > Thanks! Is there any plan for a 1.2 release in the near future? > > > > On Mon, 16 Jan 2017 12:54:05

Re: [sqlalchemy] Selecting from polymorphic tables without selecting polymorphic columns

2017-01-17 Thread Michael Williamson
ed. Targeted at 1.2 as it will break applications unknowingly > relying upon the bug right now. > > For now say func.count(Manager.employee_id), e.g. put the entity in > the columns clause. > > > > On 01/16/2017 12:23 PM, Michael Williamson wrote: > > Hello! > > > &

[sqlalchemy] Selecting from polymorphic tables without selecting polymorphic columns

2017-01-16 Thread Michael Williamson
Hello! I have a use case where I want to select from a polymorphic table, but without selecting any columns from that table. As a simple example, consider selecting the count of all rows. When I write something like: sess.query(func.count(1)).select_from(Manager).all() It seems to be

Re: [sqlalchemy] Bundles and selecting from polymorphic tables

2016-12-20 Thread Michael Williamson
Great, thanks! On Mon, 19 Dec 2016 12:43:26 -0500 mike bayer <mike...@zzzcomputing.com> wrote: > thanks, this is > https://bitbucket.org/zzzeek/sqlalchemy/issues/3874/bundle-does-not-provide-entities-fails-on > > and the gerrit should merge today. > > > > O

[sqlalchemy] Bundles and selecting from polymorphic tables

2016-12-19 Thread Michael Williamson
Hello! When selecting from a polymorphic table using a bundle, the query seems to drop the condition on the discriminator. For instance, suppose we have an Employee class that has a name column, with subclasses Manager and Engineer. When I query for Manager.name, I get back the names of just the

Re: [sqlalchemy] Re: Polymorphic properties with joined table inheritance

2016-11-16 Thread Michael Williamson
On Wed, 16 Nov 2016 12:02:41 -0500 mike bayer <mike...@zzzcomputing.com> wrote: > > > On 11/16/2016 11:58 AM, Michael Williamson wrote: > > > > Thanks, that seems to get most of the way there. The only problem is > > that calling .name on the instance return

Re: [sqlalchemy] Re: Polymorphic properties with joined table inheritance

2016-11-16 Thread Michael Williamson
On Wed, 16 Nov 2016 11:38:20 -0500 mike bayer <mike...@zzzcomputing.com> wrote: > > > On 11/16/2016 11:29 AM, Michael Williamson wrote: > >> I have no idea what you are trying to accomplish. Why not use > >> joined inheritance normally? When you query for Emp

Re: [sqlalchemy] Re: Polymorphic properties with joined table inheritance

2016-11-16 Thread Michael Williamson
> I have no idea what you are trying to accomplish. Why not use > joined inheritance normally? When you query for Employee, you will > get Engineer / Manager objects back, they will have .name. > > If you're trying to make it so that only one SELECT is emitted in > order to get fully populated

[sqlalchemy] Re: Polymorphic properties with joined table inheritance

2016-11-16 Thread Michael Williamson
reate_all(engine) session = Session(engine) session.add(Engineer(name="Jim")) session.add(Manager(name="Jules")) session.commit() print(session.query(Employee).all()) On Wed, 16 Nov 2016 15:18:54 + Michael Williamson <mich...@healx.io> wr

[sqlalchemy] Polymorphic properties with joined table inheritance

2016-11-16 Thread Michael Williamson
When using AbstractConcreteBase to implement inheritance with a separate table per type (and no common table), it seems like properties that are present on all of the subtypes are lifted up onto the super type. Is there a way to get the same behaviour when using joined table inheritance? For

[sqlalchemy] Using relationship with hybrid_property

2016-11-14 Thread Michael Williamson
Is there a way to use relationship() with hybrid properties? When using foreign() to mark the foreign key and trying to set the relationship, it seems to treat the underlying column as the foreign key rather than the hybrid property. For instance (apologies for triteness): from __future__

Re: [sqlalchemy] Setting key of hybrid_property to attribute name rather than function name

2016-11-14 Thread Michael Williamson
On Fri, 11 Nov 2016 13:27:09 -0500 mike bayer <mike...@zzzcomputing.com> wrote: > > > On 11/11/2016 12:18 PM, Michael Williamson wrote: > > > > That still requires the repetition of the name of the attribute, > > which I'd rather avoid. I've put together a varia

Re: [sqlalchemy] Setting key of hybrid_property to attribute name rather than function name

2016-11-11 Thread Michael Williamson
On Fri, 11 Nov 2016 11:59:52 -0500 mike bayer <mike...@zzzcomputing.com> wrote: > > > On 11/11/2016 07:20 AM, Michael Williamson wrote: > > I'm using hybrid_property, and would like the key of the property > > to be set to the attribute name, rather than

Re: [sqlalchemy] Setting key of hybrid_property to attribute name rather than function name

2016-11-11 Thread Michael Williamson
On Friday, November 11, 2016 at 2:22:28 PM UTC, Simon King wrote: > > On Fri, Nov 11, 2016 at 1:53 PM, Michael Williamson <mic...@healx.io > > wrote: > > > >> I think your code is basically fine, you've just got a mistake on the > >> last lin

Re: [sqlalchemy] Setting key of hybrid_property to attribute name rather than function name

2016-11-11 Thread Michael Williamson
> I think your code is basically fine, you've just got a mistake on the > last line. Presumably you meant to query Person, not Person.born? > I want Person.born so that I don't have to get the entire object. It doesn't make much difference in this example, but is quite important for us in

[sqlalchemy] Setting key of hybrid_property to attribute name rather than function name

2016-11-11 Thread Michael Williamson
I'm using hybrid_property, and would like the key of the property to be set to the attribute name, rather than the name of the getter. This is because I'm generating a getter function based on some args, rather than having the caller directly defining the getter. As a minimal example: from

Re: [sqlalchemy] Using bulk_update_mappings when primary key column has distinct key and name

2016-11-10 Thread Michael Williamson
ayer wrote: > > this is a bug and the good news is that using the column names is not a > > workaround, so nobody would be doing that either. > > > > > > On 11/10/2016 07:17 AM, Michael Williamson wrote: > >> Using bulk_update_mappings when the primary

[sqlalchemy] Using bulk_update_mappings when primary key column has distinct key and name

2016-11-10 Thread Michael Williamson
Using bulk_update_mappings when the primary key column has a distinct key and name seems to cause an error. Specifically, running this code: from __future__ import unicode_literals import os from sqlalchemy import create_engine, Column, Integer, Unicode from sqlalchemy.ext.declarative import

Re: [sqlalchemy] Delegating to _declarative_constructor

2016-07-26 Thread Michael Williamson
On Monday, July 25, 2016 at 2:29:21 PM UTC+1, Mike Bayer wrote: > > > > On 07/25/2016 09:12 AM, Michael Williamson wrote: > > Hello! For one of our models, I've defined a custom implementation for > > `__init__`. Since it should largely behave the same as the

[sqlalchemy] Delegating to _declarative_constructor

2016-07-25 Thread Michael Williamson
Hello! For one of our models, I've defined a custom implementation for `__init__`. Since it should largely behave the same as the default constructor, it delegates to `_declarative_constructor`, and then runs some extra code. However, this feels like relying on some of the internals of

Re: [sqlalchemy] with_session and subquery loading

2016-06-28 Thread Michael Williamson
On Tuesday, June 28, 2016 at 2:57:08 PM UTC+1, Mike Bayer wrote: > > > > On 06/28/2016 05:28 AM, mic...@healx3.com wrote: > > Hello! I sometimes find it more convenient to create to construct a > > query without a session, and then to add the session at the end using > > `with_session`. In