Code Monkey home page Code Monkey logo

Comments (5)

thomaxxl avatar thomaxxl commented on August 13, 2024

well, this is a pretty unfortunate screwup.
I'll have to think how to fix this: problem is that the relationship can be either an instance of

  • AppenderBaseQuery (in the case the relation has been configured with lazy="dynamic". This would be ok
  • InstrumentedList, in which case I can't perform any more queries on it

anyway, following may fix it temporarily

            data = [item for item in relation if isinstance(item, SAFRSBase)]
            meta = {"direction": "TOMANY"}
            instances = jsonapi_filter(self.child_class)
            instances = jsonapi_sort(instances, self.child_class)
            #links, data, count = paginate(instances, self.child_class)
            links = {}
            count = len(data)

but there are obv other issues: no filtering and sorting and the lack of pagination means it will work badly for large relations

I'll have to investigate this a bit further

from safrs.

wicol avatar wicol commented on August 13, 2024

If it's an InstrumentedList perhaps one could construct a base query manually: self.child_class.query.filter(self.child_class.id.in_([item.id for item in relation])) or something (but with dynamic primary key name I guess).

Or maybe the lazyness can be overridden temporarily in this case..? Not sure how though.

from safrs.

thomaxxl avatar thomaxxl commented on August 13, 2024

I've commited a fix.
I should make the sort/filter/paginate more consistent eventually, but I think this will work for now.

from safrs.

wicol avatar wicol commented on August 13, 2024

Too bad filtering was omitted, but at least it works now 👍
Btw, opting for other loading techniques than dynamic at declaration time is basically a choice made not to enable filtering or sorting, isn't it? Considering that, it might be easier to allow these operations only when the relationship is of the query type.

from safrs.

thomaxxl avatar thomaxxl commented on August 13, 2024

I'll implement filtering and sorting too, but these have to reimplemented on list objects instead of query objects :/

from safrs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.