Giter Club home page Giter Club logo

Comments (5)

aburgel avatar aburgel commented on September 28, 2024

do any of the non-rel backends support subqueries? i know appengine doesn't, so if the others also don't, we could raise an exception.

from djangotoolbox.

jonashaag avatar jonashaag commented on September 28, 2024

Wilfred, what happens if you put a len(...) around input number 8? Maybe Django swallows exceptions (if an exception happens in the backend, Django simply returns the empty list)

from djangotoolbox.

Wilfred avatar Wilfred commented on September 28, 2024
In [8]: len(Wheel.objects.filter(part_of__in=cars))
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
/home/wilfred/work/gap2/<ipython-input-8-072b023c1483> in <module>()
----> 1 len(Wheel.objects.filter(part_of__in=cars))

/home/wilfred/work/gap2/django/db/models/query.py in __len__(self)
     81                 self._result_cache = list(self._iter)
     82             else:
---> 83                 self._result_cache = list(self.iterator())
     84         elif self._iter:
     85             self._result_cache.extend(self._iter)

/home/wilfred/work/gap2/django/db/models/query.py in iterator(self)
    274         model = self.model
    275         compiler = self.query.get_compiler(using=db)
--> 276         for row in compiler.results_iter():
    277             if fill_cache:
    278                 obj, _ = get_cached_row(model, row,

/home/wilfred/work/gap2/djangotoolbox/db/basecompiler.py in results_iter(self)
    227         low_mark = self.query.low_mark
    228         high_mark = self.query.high_mark
--> 229         for entity in self.build_query(fields).fetch(low_mark, high_mark):
    230             yield self._make_result(entity, fields)
    231 

/home/wilfred/work/gap2/djangotoolbox/db/basecompiler.py in build_query(self, fields)
    287             fields = self.get_fields()
    288         query = self.query_class(self, fields)
--> 289         query.add_filters(self.query.where)
    290         query.order_by(self._get_ordering())
    291 

/home/wilfred/work/gap2/djangotoolbox/db/basecompiler.py in add_filters(self, filters)
     72         for child in children:
     73             if isinstance(child, Node):
---> 74                 self.add_filters(child)
     75                 continue
     76 

/home/wilfred/work/gap2/djangotoolbox/db/basecompiler.py in add_filters(self, filters)
     76 
     77             column, lookup_type, db_type, value = self._decode_child(child)
---> 78             self.add_filter(column, lookup_type, self._negated, db_type, value)
     79 
     80         if filters.negated:

/home/wilfred/work/gap2/djangoappengine/db/compiler.py in _func(*args, **kwargs)
     59     def _func(*args, **kwargs):
     60         try:
---> 61             return func(*args, **kwargs)
     62         except GAEError, e:
     63             raise DatabaseError, DatabaseError(str(e)), sys.exc_info()[2]

/home/wilfred/work/gap2/djangoappengine/db/compiler.py in add_filter(self, column, lookup_type, negated, db_type, value)
    241         elif lookup_type == 'in':
    242             # Create sub-query combinations, one for each value

--> 243             if len(self.gae_query) * len(value) > 30:
    244                 raise DatabaseError("You can't query against more than "
    245                                     "30 __in filter value combinations")

TypeError: object of type 'QueryWrapper' has no len()

from djangotoolbox.

jonashaag avatar jonashaag commented on September 28, 2024

Okay so we need a test in djangotoolbox for this and a fix in either djangoappengine or djangotoolbox, depending on which code is broken

from djangotoolbox.

wrwrwr avatar wrwrwr commented on September 28, 2024

An exception should be raised if a subquery is used with the recent changes. However, we could try to evaluate subqueries or avoid them when constructing queries.

from djangotoolbox.

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.