On Fri, Sep 27, 2019 at 09:03:53AM -0400, Mike Bayer wrote:
>
>
> On Fri, Sep 27, 2019, at 6:26 AM, Julien Cigar wrote:
> > On Thu, Sep 26, 2019 at 11:39:52AM -0400, Mike Bayer wrote:
> > > that's not supported, I would suggest trying to solve your problem in a
> > > different way.
> > >
> >
> > Ok, that's what I thought.. thanks!
> >
> > I have a typical joined table inheritance, with Content being the "base"
> > class, and childs as Document, Folder, Event, etc.
> >
> > I have added a transparent translation package with the "one translation
> > table per entity" approach (also using joined table inheritance),
> > and hybrid properties.
> >
> > So I have ContentTranslation being the "base" class, and childs like
> > DocumentTranslation, FolderTranslation, EventTranslation, etc. which
> > contain translation fields specific to each class.
> >
> > You helped me some weeks ago on this and I ended with (1), in which two
> > relationships were added to every children of Content
> > ("current_translation" and "translations"), and hybrid properties
> > pointing to their dedicated translation class.
> >
> > It works well, the only minor issue is that I don't have any
> > relationship on the base Content class (as you told me in the past that
> > overriding relationships could be problematic).
> >
> > I made some modifications (2) in which the relationships are now
> > prefixed with the class name, and added two properties which point to
> > the class relationship, so that in the end:
> >
> > - Content has a "content_current_translation" and
> > "content_translations" relationships, and two property
> > "current_translation" and "translations" pointing to them
> >
> > - Document has a "document_current_translation" and
> > "document_translations" with also two property current_translation and
> > translations pointing to them, but the minor issue is that the
> > content_current_translation is also joined loaded, which I'd like to
> > avoid.. and I'm wondering what would be the best approach.
> >
> > I don't know if it's clear, but if it is not I could make a test case
>
> I'm not sure what the problem is, the code I can see has "lazy='joined'" in
> some spots, you'd make that into "lazy='select'" if that's the lazy loading
> you want.
>
> if this is some kind of automatic-generation issue where some of these
> generations need to apply a different kind of default loader then you would
> need to add parameterization to your code generation scheme, such as
> additional arguments to your setup_relationships() function.The problem I have if that the "current_translation" should always be lazy='joined' within it's context. In the base class (Content) "current_translation" points to the "content_current_translation" relationship. In a child class (Document) "current_translation" points to "document_current_translation" relationship, but a child class also contain the "content_current_translation", as Document inherits from Content and that the property has already been setup. So both relationships are joinedloaded at the same time when I'm session.query(Document). For example when I'm querying for a Document SQLAlchemy generates two queries for the translations (1) and (2). The JOIN on the document_translation table should happend in (1). When I'm setting the mapping for a child class (Document, Event, Folder, etc) I'm looking for a way to either 1) remove the "content_current_translation" relationship or 2) disable joined loading for this relationship. But when I'm dbsession.query(Content) the "content_current_translation" must be joined loaded (1) https://gist.github.com/silenius/482f6a0f46427580aae12ba32b836ee5 (2) https://gist.github.com/silenius/511f3069a871dd17d6e202c6b92edaf8 > > > > > > (1) > > https://github.com/silenius/amnesia_multilingual/blob/master/amnesia_multilingual/builders.py > > > > (2) > > https://github.com/silenius/amnesia_multilingual/blob/dev/amnesia_multilingual/builders.py > > > > Thank you :) > > > > Julien > > > > > > > > > > > On Thu, Sep 26, 2019, at 11:25 AM, Julien Cigar wrote: > > > > Hello, > > > > > > > > I'd like to change a lazy property of an existing relationship (from > > > > 'joined' to 'noload'). I tried the following: > > > > > > > > mapper = orm.class_mapper(MyClass) > > > > prop = mapper.get_property('some_relationship') > > > > prop.lazy = 'noload' > > > > > > > > but it doesn't seems to work, as the property is still loaded > > > > > > > > Any idea if this is possible? > > > > > > > > Thanks, > > > > Julien > > > > > > > > > > > > -- > > > > Julien Cigar > > > > Belgian Biodiversity Platform (http://www.biodiversity.be) > > > > PGP fingerprint: EEF9 F697 4B68 D275 7B11 6A25 B2BB 3710 A204 23C0 > > > > No trees were killed in the creation of this message. > > > > However, many electrons were terribly inconvenienced. > > > > > > > > -- > > > > SQLAlchemy - > > > > The Python SQL Toolkit and Object Relational Mapper > > > > > > > > http://www.sqlalchemy.org/ > > > > > > > > To post example code, please provide an MCVE: Minimal, Complete, and > > > > Verifiable Example. See http://stackoverflow.com/help/mcve for a full > > > > description. > > > > --- > > > > 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 [email protected]. > > > > To view this discussion on the web visit > > > > https://groups.google.com/d/msgid/sqlalchemy/20190926152504.GB1535%40p52s. > > > > > > > > > > -- > > > SQLAlchemy - > > > The Python SQL Toolkit and Object Relational Mapper > > > > > > http://www.sqlalchemy.org/ > > > > > > To post example code, please provide an MCVE: Minimal, Complete, and > > > Verifiable Example. See http://stackoverflow.com/help/mcve for a full > > > description. > > > --- > > > 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 [email protected]. > > > To view this discussion on the web visit > > > https://groups.google.com/d/msgid/sqlalchemy/dab6e523-675f-4a88-aa6d-c303360a50e6%40www.fastmail.com. > > > > -- > > Julien Cigar > > Belgian Biodiversity Platform (http://www.biodiversity.be) > > PGP fingerprint: EEF9 F697 4B68 D275 7B11 6A25 B2BB 3710 A204 23C0 > > No trees were killed in the creation of this message. > > However, many electrons were terribly inconvenienced. > > > > -- > > SQLAlchemy - > > The Python SQL Toolkit and Object Relational Mapper > > > > http://www.sqlalchemy.org/ > > > > To post example code, please provide an MCVE: Minimal, Complete, and > > Verifiable Example. See http://stackoverflow.com/help/mcve for a full > > description. > > --- > > 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 [email protected]. > > To view this discussion on the web visit > > https://groups.google.com/d/msgid/sqlalchemy/20190927102658.GA16334%40home.lan. > > > > > > *Attachments:* > > * signature.asc > > -- > SQLAlchemy - > The Python SQL Toolkit and Object Relational Mapper > > http://www.sqlalchemy.org/ > > To post example code, please provide an MCVE: Minimal, Complete, and > Verifiable Example. See http://stackoverflow.com/help/mcve for a full > description. > --- > 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 [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/sqlalchemy/31539116-6f4d-4ed3-84cd-e0111c5b69b0%40www.fastmail.com. -- Julien Cigar Belgian Biodiversity Platform (http://www.biodiversity.be) PGP fingerprint: EEF9 F697 4B68 D275 7B11 6A25 B2BB 3710 A204 23C0 No trees were killed in the creation of this message. However, many electrons were terribly inconvenienced. -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example code, please provide an MCVE: Minimal, Complete, and Verifiable Example. See http://stackoverflow.com/help/mcve for a full description. --- 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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/sqlalchemy/20190927133408.GB16334%40home.lan.
signature.asc
Description: PGP signature
