python - SQLAlchemy - Using 'aliased' in query with custom primaryjoin relationship -


I am using SQLAlchemy (0.9.4) in my flask application. There are two tables with soft removal support in the application

  class A (SoftDeleteMixin, db.Model). B = id = A.b_id ') Class B (SoftDeleteMixin, db.Model): id = db. Column (db.BigInteger, primary_key = true) PARENT_ID = db.Column (db.BigInteger, db.ForeignKey ('b.id')) parent = soft_delete_relationship (remote (id), PARENT_ID, 'B.id', ' B.Parent_id ') Children = soft_delete_relationship (Remote (PARENT_ID), ID,' B.parent_id ',' B.id ')   

SoftDeleteMixin Limiting is based on () Pre: Return Query.get (self.populate_existing (), President) def __iter __ (self): return query .__ iter__def (self, president ) (Self.private ()) def-self (self, * ent): return question .from_self (self.private (), * ent) def private Auto): mzero = self._mapper_zero () if there is no mzero and hasattr (mzero, 'class_'): soft_deleted = getattr (mzero.class_, 'soft_deleted', none) return self.enable_assertions (false) .filter ( relationship with soft_deleted.is_ (false)) and the rest self-soft_deleted if: auto return

and soft_delete_relationship custom primaryjoin (for non-soft_deleted) Make them First, ARR and EASTENCE (second, ARR): Other, other copying = First split ('. ') _this, this CDblum = seconds split ('. ') Primeroin = & amp; '. Format (other)]) Other: other, other_column = args [0] .split ('[} (=} {}}' format (first, second), '{} .soft_deleted.is_ (false) . ') _this, this_column = args [1] .split ('. ') Primaryjoin = lambda: (first == seconds) & amp; getattr (second.table.c, 'soft_deleted'). is_ (false) kwargs ['primaryjoin'] = Primary Relationship Relationships back (other, ** kwargs)

The problem occurs when I write a query with LISD B:

  b_parent = aliased (b) Exercise.joint (ab). oterjoines (b_perter, bpr)   

I follow SQL:

 Add b.id = a.b_id to A bonus B from SELECT ... at b_1 b_1 b_1.id = b.parent_id and * b *. soft_deleted IS is wrong   

but I expect the following:

  from SELECT ... on a bonus B on b.id = a.b_id left External contact BAS b_1 at b_1.id = b.parent_id and * b_1 * .soft_deleted IS incorrectly   

When I explicitly type:

  .query.join (ab). Otterjoin (B_perter, (BIPRIIDID == BPrint_ID) and BPPrint.Software Dated .Isi (false)   

I got the right query.

How can I get the proper nickname for b_1 in the question without a clear assignment attachment? BTW, SQLLM was expected to have 0.7.9 SQL.

OK, I thought it. getattr (second.table.c, 'soft_deleted') should also be accompanied by the remote () annotation.

In other words, look like primaryjoin relationship should look like B.parent :

< p> (Remote (BID) == B.parent_id) & amp; Remote (B.Soft_Delated) .is_ (false)

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -