[sqlalchemy] Re: Complex Constraints in Many to Many relationships

2019-09-04 Thread Derek Lambert
If I'm understanding correctly... You're on the right track. I'd use a composite primary key on |team_person|, consisting of foreign keys from |person| and |team|, and another composite key (or unique index) on the |team| to |tournament| table. This lets the database do all the work. -Derek

[sqlalchemy] Re: Include total count in query results with limit and offset

2019-04-03 Thread Derek Lambert
.all() return { 'total_count': count, 'data':data } On Monday, April 1, 2019 at 11:10:52 AM UTC-5, Derek Lambert wrote: > > Is it possible to return a query's results as a dictionary containing the > total count and a limited por

[sqlalchemy] Value deleter in examples/vertical/dictlike-polymorphic.py

2018-10-22 Thread Derek Lambert
I've implemented some property objects based on the dictlike-polymorphic.py example. I'm writing unit tests for my code and noticed the value deleter is attempting to call an undefined method _set_value. What was intended here? I've got some jankey code I'm using to delete properties from the

Re: [sqlalchemy] Missing synonyms with multi-inheritance

2018-10-20 Thread Derek Lambert
fix > > On Fri, Oct 19, 2018 at 4:38 PM Mike Bayer > wrote: > > > > On Fri, Oct 19, 2018 at 2:30 PM Derek Lambert > wrote: > > > > > > I'm replying to my original post since it's related. > > > > > > I'm still seeing missing s

Re: [sqlalchemy] Missing synonyms with multi-inheritance

2018-10-19 Thread Derek Lambert
define AnotherChild identical to ActiveDirectoryGroup, but there are additional synonyms on ActiveDirectoryGroup they both should have. Thanks, Derek On Wednesday, May 9, 2018 at 2:16:22 PM UTC-5, Derek Lambert wrote: > > That was my conclusion too after consulting the googles. > &g

Re: [sqlalchemy] How to customize base declarative class to add naming conventions

2018-09-05 Thread Derek Lambert
Just define the naming convention dict in a separate file and import it into each declarative base? On Wednesday, September 5, 2018 at 4:18:44 AM UTC-5, René-paul Debroize wrote: > > It would have been great to be able to do it via a mixin, I have several > DB using decalarative base

Re: [sqlalchemy] Re: Deleting child object in one-to-many relationship trying to load relationship?

2018-08-06 Thread Derek Lambert
Doh that's exactly what I need. Need to read through the docs again, I missed that parameter. Thanks! On Monday, August 6, 2018 at 4:46:57 PM UTC-5, Mike Bayer wrote: > > On Mon, Aug 6, 2018 at 4:14 PM, Derek Lambert > wrote: > > I do want it to tell me when stuff is being ea

[sqlalchemy] Re: Deleting child object in one-to-many relationship trying to load relationship?

2018-08-06 Thread Derek Lambert
side I get the warning: SAWarning: On Person.category, 'passive_deletes' is normally configured on one-to-many, one-to-one, many-to-many relationships only. If I move the passive_deletes to the "one" side I get the exception again. On Friday, August 3, 2018 at 2:29:45 PM UTC-5, Derek Lam

[sqlalchemy] Deleting child object in one-to-many relationship trying to load relationship?

2018-08-03 Thread Derek Lambert
When deleting a child object in a one-to-many relationship retrieved with the raiseload('*') query option an exception is raised. Adding passive_deletes=True to the relationship on the child prevents the exception, but that seems like a hack. I can remove the option from the query, but I'm

Re: [sqlalchemy] Query filter for class in inheritance mapping?

2018-05-30 Thread Derek Lambert
('Design')), ... ... ) ) instead of performing multiple queries. On Wednesday, May 30, 2018 at 12:50:40 PM UTC-5, Mike Bayer wrote: > > On Wed, May 30, 2018 at 12:39 PM, Derek Lambert > > wrote: > > Outside of checking the discriminator value is it

[sqlalchemy] Query filter for class in inheritance mapping?

2018-05-30 Thread Derek Lambert
Outside of checking the discriminator value is it possible to filter a query by a class in an inheritance mapping? class Employee(Base): __tablename__ = 'employee' id = Column(Integer, primary_key=True) name = Column(String(50)) type = Column(String(20)) __mapper_args__ = {

Re: [sqlalchemy] Missing synonyms with multi-inheritance

2018-05-09 Thread Derek Lambert
That was my conclusion too after consulting the googles. I've done as you suggested and things are working as expected. Thanks! On Monday, April 30, 2018 at 4:26:02 PM UTC-5, Mike Bayer wrote: > > On Mon, Apr 30, 2018 at 4:18 PM, Derek Lambert > <dlam...@dereklambert

Re: [sqlalchemy] Missing synonyms with multi-inheritance

2018-04-30 Thread Derek Lambert
s, Derek On Monday, April 30, 2018 at 1:30:51 PM UTC-5, Mike Bayer wrote: > On Mon, Apr 30, 2018 at 1:33 PM, Derek Lambert > <dlam...@dereklambert.com > wrote: > > I'm running into an issue in a hierarchy of single-table inheritance > objects > > with multiple

[sqlalchemy] Missing synonyms with multi-inheritance

2018-04-30 Thread Derek Lambert
I'm running into an issue in a hierarchy of single-table inheritance objects with multiple inheritance. The objects represent users/groups/etc. from various directories and applications. Retrieving the list of synonyms from an object at the bottom of the inheritance tree doesn't return the

[sqlalchemy] Re: Foreign key not set when appending related object to collection using a variable?

2018-03-23 Thread Derek Lambert
, 2018 at 2:02:00 PM UTC-5, Derek Lambert wrote: > > I'm probably overlooking something simple, looking for feedback before > opening an issue. > > I have some objects with relationships defined between. When I create a > new related object and pass it in the append() method

[sqlalchemy] Foreign key not set when appending related object to collection using a variable?

2018-03-17 Thread Derek Lambert
I'm probably overlooking something simple, looking for feedback before opening an issue. I have some objects with relationships defined between. When I create a new related object and pass it in the append() method of the collection everything works as expected, the foreign key is set. When I

[sqlalchemy] Re: SQLAlchemy utility function to evaluate a string

2018-03-17 Thread Derek Lambert
I created a parser using pyparser that takes a filter string similar to what you'd pass to Query.filter(), and returns an object you can pass to Query.filter(). ex. "Child.last_name == 'Smith' AND Child.first_name LIKE 'J%' OR Child.parent_id IS NULL". This was to allow storing the query

[sqlalchemy] Association proxy to plain @property

2018-02-27 Thread Derek Lambert
Michael (or anyone listening), In my example code in #4202 (https://bitbucket.org/zzzeek/sqlalchemy/issues/4202/associationproxy-no-longer-resolved-to) you mentioned the assocaition proxy to the plain members @property is probably not a supported pattern. It's working in my code, but I'd