| 1 | OperationalError Traceback (most recent call last)
|
|---|
| 2 | File ~/PycharmProjects/dataviz/.venv/lib/python3.12/site-packages/django/db/backends/utils.py:105, in CursorWrapper._execute(self, sql, params, *ignored_wrapper_args)
|
|---|
| 3 | 104 else:
|
|---|
| 4 | --> 105 return self.cursor.execute(sql, params)
|
|---|
| 5 |
|
|---|
| 6 | File ~/PycharmProjects/dataviz/.venv/lib/python3.12/site-packages/django/db/backends/sqlite3/base.py:360, in SQLiteCursorWrapper.execute(self, query, params)
|
|---|
| 7 | 359 query = self.convert_query(query, param_names=param_names)
|
|---|
| 8 | --> 360 return super().execute(query, params)
|
|---|
| 9 |
|
|---|
| 10 | OperationalError: Expression tree is too large (maximum depth 1000)
|
|---|
| 11 |
|
|---|
| 12 | The above exception was the direct cause of the following exception:
|
|---|
| 13 |
|
|---|
| 14 | OperationalError Traceback (most recent call last)
|
|---|
| 15 | Cell In[4], line 1
|
|---|
| 16 | ----> 1 x = list(Organisation.objects.all().prefetch_related("roles__project"))
|
|---|
| 17 |
|
|---|
| 18 | File ~/PycharmProjects/dataviz/.venv/lib/python3.12/site-packages/django/db/models/query.py:384, in QuerySet.__iter__(self)
|
|---|
| 19 | 369 def __iter__(self):
|
|---|
| 20 | 370 """
|
|---|
| 21 | 371 The queryset iterator protocol uses three nested iterators in the
|
|---|
| 22 | 372 default case:
|
|---|
| 23 | (...) 382 - Responsible for turning the rows into model objects.
|
|---|
| 24 | 383 """
|
|---|
| 25 | --> 384 self._fetch_all()
|
|---|
| 26 | 385 return iter(self._result_cache)
|
|---|
| 27 |
|
|---|
| 28 | File ~/PycharmProjects/dataviz/.venv/lib/python3.12/site-packages/django/db/models/query.py:1951, in QuerySet._fetch_all(self)
|
|---|
| 29 | 1949 self._result_cache = list(self._iterable_class(self))
|
|---|
| 30 | 1950 if self._prefetch_related_lookups and not self._prefetch_done:
|
|---|
| 31 | -> 1951 self._prefetch_related_objects()
|
|---|
| 32 |
|
|---|
| 33 | File ~/PycharmProjects/dataviz/.venv/lib/python3.12/site-packages/django/db/models/query.py:1328, in QuerySet._prefetch_related_objects(self)
|
|---|
| 34 | 1326 def _prefetch_related_objects(self):
|
|---|
| 35 | 1327 # This method can only be called once the result cache has been filled.
|
|---|
| 36 | -> 1328 prefetch_related_objects(self._result_cache, *self._prefetch_related_lookups)
|
|---|
| 37 | 1329 self._prefetch_done = True
|
|---|
| 38 |
|
|---|
| 39 | File ~/PycharmProjects/dataviz/.venv/lib/python3.12/site-packages/django/db/models/query.py:2397, in prefetch_related_objects(model_instances, *related_lookups)
|
|---|
| 40 | 2394 obj_to_fetch = [obj for obj in obj_list if not is_fetched(obj)]
|
|---|
| 41 | 2396 if obj_to_fetch:
|
|---|
| 42 | -> 2397 obj_list, additional_lookups = prefetch_one_level(
|
|---|
| 43 | 2398 obj_to_fetch,
|
|---|
| 44 | 2399 prefetcher,
|
|---|
| 45 | 2400 lookup,
|
|---|
| 46 | 2401 level,
|
|---|
| 47 | 2402 )
|
|---|
| 48 | 2403 # We need to ensure we don't keep adding lookups from the
|
|---|
| 49 | 2404 # same relationships to stop infinite recursion. So, if we
|
|---|
| 50 | 2405 # are already on an automatically added lookup, don't add
|
|---|
| 51 | 2406 # the new lookups from relationships we've seen already.
|
|---|
| 52 | 2407 if not (
|
|---|
| 53 | 2408 prefetch_to in done_queries
|
|---|
| 54 | 2409 and lookup in auto_lookups
|
|---|
| 55 | 2410 and descriptor in followed_descriptors
|
|---|
| 56 | 2411 ):
|
|---|
| 57 |
|
|---|
| 58 | File ~/PycharmProjects/dataviz/.venv/lib/python3.12/site-packages/django/db/models/query.py:2598, in prefetch_one_level(instances, prefetcher, lookup, level)
|
|---|
| 59 | 2592 if additional_lookups:
|
|---|
| 60 | 2593 # Don't need to clone because the manager should have given us a fresh
|
|---|
| 61 | 2594 # instance, so we access an internal instead of using public interface
|
|---|
| 62 | 2595 # for performance reasons.
|
|---|
| 63 | 2596 rel_qs._prefetch_related_lookups = ()
|
|---|
| 64 | -> 2598 all_related_objects = list(rel_qs)
|
|---|
| 65 | 2600 rel_obj_cache = {}
|
|---|
| 66 | 2601 for rel_obj in all_related_objects:
|
|---|
| 67 |
|
|---|
| 68 | File ~/PycharmProjects/dataviz/.venv/lib/python3.12/site-packages/django/db/models/query.py:384, in QuerySet.__iter__(self)
|
|---|
| 69 | 369 def __iter__(self):
|
|---|
| 70 | 370 """
|
|---|
| 71 | 371 The queryset iterator protocol uses three nested iterators in the
|
|---|
| 72 | 372 default case:
|
|---|
| 73 | (...) 382 - Responsible for turning the rows into model objects.
|
|---|
| 74 | 383 """
|
|---|
| 75 | --> 384 self._fetch_all()
|
|---|
| 76 | 385 return iter(self._result_cache)
|
|---|
| 77 |
|
|---|
| 78 | File ~/PycharmProjects/dataviz/.venv/lib/python3.12/site-packages/django/db/models/query.py:1949, in QuerySet._fetch_all(self)
|
|---|
| 79 | 1947 def _fetch_all(self):
|
|---|
| 80 | 1948 if self._result_cache is None:
|
|---|
| 81 | -> 1949 self._result_cache = list(self._iterable_class(self))
|
|---|
| 82 | 1950 if self._prefetch_related_lookups and not self._prefetch_done:
|
|---|
| 83 | 1951 self._prefetch_related_objects()
|
|---|
| 84 |
|
|---|
| 85 | File ~/PycharmProjects/dataviz/.venv/lib/python3.12/site-packages/django/db/models/query.py:91, in ModelIterable.__iter__(self)
|
|---|
| 86 | 88 compiler = queryset.query.get_compiler(using=db)
|
|---|
| 87 | 89 # Execute the query. This will also fill compiler.select, klass_info,
|
|---|
| 88 | 90 # and annotations.
|
|---|
| 89 | ---> 91 results = compiler.execute_sql(
|
|---|
| 90 | 92 chunked_fetch=self.chunked_fetch, chunk_size=self.chunk_size
|
|---|
| 91 | 93 )
|
|---|
| 92 | 94 select, klass_info, annotation_col_map = (
|
|---|
| 93 | 95 compiler.select,
|
|---|
| 94 | 96 compiler.klass_info,
|
|---|
| 95 | 97 compiler.annotation_col_map,
|
|---|
| 96 | 98 )
|
|---|
| 97 | 99 model_cls = klass_info["model"]
|
|---|
| 98 |
|
|---|
| 99 | File ~/PycharmProjects/dataviz/.venv/lib/python3.12/site-packages/django/db/models/sql/compiler.py:1623, in SQLCompiler.execute_sql(self, result_type, chunked_fetch, chunk_size)
|
|---|
| 100 | 1621 cursor = self.connection.cursor()
|
|---|
| 101 | 1622 try:
|
|---|
| 102 | -> 1623 cursor.execute(sql, params)
|
|---|
| 103 | 1624 except Exception:
|
|---|
| 104 | 1625 # Might fail for server-side cursors (e.g. connection closed)
|
|---|
| 105 | 1626 cursor.close()
|
|---|
| 106 |
|
|---|
| 107 | File ~/PycharmProjects/dataviz/.venv/lib/python3.12/site-packages/django/db/backends/utils.py:122, in CursorDebugWrapper.execute(self, sql, params)
|
|---|
| 108 | 120 def execute(self, sql, params=None):
|
|---|
| 109 | 121 with self.debug_sql(sql, params, use_last_executed_query=True):
|
|---|
| 110 | --> 122 return super().execute(sql, params)
|
|---|
| 111 |
|
|---|
| 112 | File ~/PycharmProjects/dataviz/.venv/lib/python3.12/site-packages/django/db/backends/utils.py:79, in CursorWrapper.execute(self, sql, params)
|
|---|
| 113 | 78 def execute(self, sql, params=None):
|
|---|
| 114 | ---> 79 return self._execute_with_wrappers(
|
|---|
| 115 | 80 sql, params, many=False, executor=self._execute
|
|---|
| 116 | 81 )
|
|---|
| 117 |
|
|---|
| 118 | File ~/PycharmProjects/dataviz/.venv/lib/python3.12/site-packages/django/db/backends/utils.py:92, in CursorWrapper._execute_with_wrappers(self, sql, params, many, executor)
|
|---|
| 119 | 90 for wrapper in reversed(self.db.execute_wrappers):
|
|---|
| 120 | 91 executor = functools.partial(wrapper, executor)
|
|---|
| 121 | ---> 92 return executor(sql, params, many, context)
|
|---|
| 122 |
|
|---|
| 123 | File ~/PycharmProjects/dataviz/.venv/lib/python3.12/site-packages/django/db/backends/utils.py:100, in CursorWrapper._execute(self, sql, params, *ignored_wrapper_args)
|
|---|
| 124 | 98 warnings.warn(self.APPS_NOT_READY_WARNING_MSG, category=RuntimeWarning)
|
|---|
| 125 | 99 self.db.validate_no_broken_transaction()
|
|---|
| 126 | --> 100 with self.db.wrap_database_errors:
|
|---|
| 127 | 101 if params is None:
|
|---|
| 128 | 102 # params default might be backend specific.
|
|---|
| 129 | 103 return self.cursor.execute(sql)
|
|---|
| 130 |
|
|---|
| 131 | File ~/PycharmProjects/dataviz/.venv/lib/python3.12/site-packages/django/db/utils.py:91, in DatabaseErrorWrapper.__exit__(self, exc_type, exc_value, traceback)
|
|---|
| 132 | 89 if dj_exc_type not in (DataError, IntegrityError):
|
|---|
| 133 | 90 self.wrapper.errors_occurred = True
|
|---|
| 134 | ---> 91 raise dj_exc_value.with_traceback(traceback) from exc_value
|
|---|
| 135 |
|
|---|
| 136 | File ~/PycharmProjects/dataviz/.venv/lib/python3.12/site-packages/django/db/backends/utils.py:105, in CursorWrapper._execute(self, sql, params, *ignored_wrapper_args)
|
|---|
| 137 | 103 return self.cursor.execute(sql)
|
|---|
| 138 | 104 else:
|
|---|
| 139 | --> 105 return self.cursor.execute(sql, params)
|
|---|
| 140 |
|
|---|
| 141 | File ~/PycharmProjects/dataviz/.venv/lib/python3.12/site-packages/django/db/backends/sqlite3/base.py:360, in SQLiteCursorWrapper.execute(self, query, params)
|
|---|
| 142 | 358 param_names = list(params) if isinstance(params, Mapping) else None
|
|---|
| 143 | 359 query = self.convert_query(query, param_names=param_names)
|
|---|
| 144 | --> 360 return super().execute(query, params)
|
|---|
| 145 |
|
|---|
| 146 | OperationalError: Expression tree is too large (maximum depth 1000)
|
|---|