[sqlalchemy] Adding additional filters to non-declarative entities in passed around query

2017-11-06 Thread Jacob Magnusson
Hi, I have this function which returns a list of product variants and the first "seasons" they were introduced in (might be multiple on the same date, so I'm ranking by from_date in a CTE): *In [190]: def variants_first_seasons_query():* * ...: ranking_query = (* * ...:

Re: [sqlalchemy] Accessing data from an already executed query in a hybrid_property (using SQLAlchemy Transformer in the query)

2016-02-22 Thread Jacob Magnusson
parator > def latest_sku_shipment(cls): > return CustomerLatestShipmentTransformer(cls) > > also thanks for reminding me about query.with_transformation()! I had > zero recollection of this method or the recipe in hybrids! it's like > I'm reading it for the first time,

Re: [sqlalchemy] Accessing data from an already executed query in a hybrid_property (using SQLAlchemy Transformer in the query)

2016-02-19 Thread Jacob Magnusson
former(cls) > > also thanks for reminding me about query.with_transformation()! I had > zero recollection of this method or the recipe in hybrids! it's like > I'm reading it for the first time, very strange. > > > > On 02/19/2016 07:17 AM, Jacob Magnusson wrote: > > Hi,

[sqlalchemy] Re: Accessing data from an already executed query in a hybrid_property (using SQLAlchemy Transformer in the query)

2016-02-19 Thread Jacob Magnusson
I would like to add that it would look much more clean in my book if I wouldn't have to resort to *session.query(Customer, ProductSKUShipment)*. -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving

[sqlalchemy] Re: Accessing data from an already executed query in a hybrid_property (using SQLAlchemy Transformer in the query)

2016-02-19 Thread Jacob Magnusson
I would like to add that it would look much more clean in my book if I wouldn't have to resort to *session.query(Customer, ProductSKUShipment)*. . On Friday, February 19, 2016 at 1:17:34 PM UTC+1, Jacob Magnusson wrote: > > Hi, > > I have this case where I want to be ab

[sqlalchemy] Accessing data from an already executed query in a hybrid_property (using SQLAlchemy Transformer in the query)

2016-02-19 Thread Jacob Magnusson
Hi, I have this case where I want to be able to access a hybrid_property that points to a related model which is further filtered using a cte (utilizing a Transformer ) without having to trigger additional

Re: [sqlalchemy] Raise exception on implicit join

2015-11-24 Thread Jacob Magnusson
vid Allouche wrote: > >> On 28 Jul 2015, at 11:31, Jacob Magnusson <m...@jacobian.se > > wrote: > >> > >> I'm trying to avoid "implicit" joins (i.e. more than one entry in the > FROM clause) in my code and I'm wondering if you guys have a good idea

Re: How can I use ExecuteSQLOp?

2015-10-29 Thread Jacob Magnusson
On 10/28/15 1:57 PM, Jacob Magnusson wrote: > > Hi, > > > > I have a use-case where I need to execute a function called > > *audit_table* after a new table is created in my migrations. So I > > thought I would be able to use alembic.operations.ops.ExecuteSQLOp

How can I use ExecuteSQLOp?

2015-10-28 Thread Jacob Magnusson
Hi, I have a use-case where I need to execute a function called *audit_table* after a new table is created in my migrations. So I thought I would be able to use alembic.operations.ops.ExecuteSQLOp

Re: [sqlalchemy] Nested bundles, labels and "Ambiguous column name"

2015-09-08 Thread Jacob Magnusson
'id', Integer(), > table=, primary_key=True, nullable=False), which has the > same key. Consider use_labels for select() statements.* On Friday, April 10, 2015 at 12:19:31 AM UTC+2, Michael Bayer wrote: > > > > On 4/9/15 1:50 PM, Jacob Magnusson wrote: > > I have this ca

[sqlalchemy] Raise exception on implicit join

2015-07-28 Thread Jacob Magnusson
Hi guys, I'm trying to avoid implicit joins (i.e. more than one entry in the FROM clause) in my code and I'm wondering if you guys have a good idea on how to best achieve this. I want to raise an exception if a query changes to have more than one entry in the FROM clause. An alternative would

Re: [sqlalchemy] Access __tablename__ in server_defaults?

2015-04-27 Thread Jacob Magnusson
Of course it worked! I think I was a bit tired that day... On Thu, Apr 23, 2015 at 10:23 PM Mike Bayer mike...@zzzcomputing.com wrote: if you are using __tablename__ what happens if you just refer to cls.__tablename__ in that method ? On 4/23/15 3:46 PM, Jacob Magnusson wrote: Would

[sqlalchemy] Access __tablename__ in server_defaults?

2015-04-23 Thread Jacob Magnusson
Would it somehow be possible to access the __tablename__ in server_default? What I'm looking for is something like this: class PositionMixin(object): @declared_attrdef position(cls): return Column(Integer, server_default=text(nextval('%(__tablename__)s_id_seq'))) ​ -- You

Re: [sqlalchemy] Nested bundles, labels and Ambiguous column name

2015-04-09 Thread Jacob Magnusson
, 'category'), ]), single_entity=True, ) I'm guessing this could cause all kinds of side-effects... Right? On Thursday, April 9, 2015 at 8:29:15 PM UTC+2, Michael Bayer wrote: On 4/9/15 1:50 PM, Jacob Magnusson wrote: I have this case with a bundle that looks something like

[sqlalchemy] Re: Nested bundles, labels and Ambiguous column name

2015-04-09 Thread Jacob Magnusson
Thanks for the quick reply Michael. I would love to hear what you can find out about it. I have what I think is a pretty horrible and dirty “solution”. But it *seems* to work. What I’ve done is to assign the key attribute of columns like this: from collections import namedtuple

[sqlalchemy] Nested bundles, labels and Ambiguous column name

2015-04-09 Thread Jacob Magnusson
I have this case with a bundle that looks something like this: primate_bundle = Bundle( 'primate', Primate.name, Bundle('wooden_tool', *[ WoodenTool.id, WoodenTool.name, WoodenToolCategory.name.label('category'), ]), Bundle('solid_tool', *[