doableware / djongo

Django and MongoDB database connector
https://www.djongomapper.com
GNU Affero General Public License v3.0
1.88k stars 355 forks source link

AttributeError: 'Identifier' object has no attribute 'get_parameters' #664

Open sig003 opened 1 year ago

sig003 commented 1 year ago

One line description of the issue

My system environment. Django==4.1.4 django-oauth-toolkit==2.2.0 djangorestframework==3.14.0 djongo==1.3.6 pymongo==3.12.3

Execute python manage.py cleartokens I got this error => AttributeError: 'Identifier' object has no attribute 'get_parameters' But I can't find a 'get_parameters' function.

Python script

```python python manage.py cleartokens ``` #### Traceback Traceback (most recent call last): File "/app/python_backend/.venv/lib/python3.10/site-packages/djongo/sql2mongo/query.py", line 857, in parse return handler(self, statement) File "/app/python_backend/.venv/lib/python3.10/site-packages/djongo/sql2mongo/query.py", line 933, in _select return SelectQuery(self.db, self.connection_properties, sm, self._params) File "/app/python_backend/.venv/lib/python3.10/site-packages/djongo/sql2mongo/query.py", line 116, in __init__ super().__init__(*args) File "/app/python_backend/.venv/lib/python3.10/site-packages/djongo/sql2mongo/query.py", line 62, in __init__ self.parse() File "/app/python_backend/.venv/lib/python3.10/site-packages/djongo/sql2mongo/query.py", line 123, in parse self.selected_columns = ColumnSelectConverter(self, statement) File "/app/python_backend/.venv/lib/python3.10/site-packages/djongo/sql2mongo/converters.py", line 44, in __init__ super().__init__(query, statement) File "/app/python_backend/.venv/lib/python3.10/site-packages/djongo/sql2mongo/converters.py", line 27, in __init__ self.parse() File "/app/python_backend/.venv/lib/python3.10/site-packages/djongo/sql2mongo/converters.py", line 53, in parse for sql_token in SQLToken.tokens2sql(tok, self.query): File "/app/python_backend/.venv/lib/python3.10/site-packages/djongo/sql2mongo/sql_tokens.py", line 49, in tokens2sql yield SQLFunc.token2sql(token, query) File "/app/python_backend/.venv/lib/python3.10/site-packages/djongo/sql2mongo/functions.py", line 24, in token2sql return CountFunc.token2sql(token, query) File "/app/python_backend/.venv/lib/python3.10/site-packages/djongo/sql2mongo/functions.py", line 78, in token2sql token[0].get_parameters()[0] AttributeError: 'Identifier' object has no attribute 'get_parameters' The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/app/python_backend/.venv/lib/python3.10/site-packages/djongo/cursor.py", line 51, in execute self.result = Query( File "/app/python_backend/.venv/lib/python3.10/site-packages/djongo/sql2mongo/query.py", line 784, in __init__ self._query = self.parse() File "/app/python_backend/.venv/lib/python3.10/site-packages/djongo/sql2mongo/query.py", line 885, in parse raise exe from e djongo.exceptions.SQLDecodeError: Keyword: None Sub SQL: None FAILED SQL: SELECT COUNT(*) FROM (SELECT "oauth2_provider_refreshtoken"."id" AS "col1" FROM "oauth2_provider_refreshtoken" WHERE "oauth2_provider_refreshtoken"."revoked" < %(0)s LIMIT 1000) subquery Params: (datetime.datetime(2023, 4, 17, 23, 33, 36, 264763),) Version: 1.3.6 The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/app/python_backend/.venv/lib/python3.10/site-packages/django/db/backends/utils.py", line 89, in _execute return self.cursor.execute(sql, params) File "/app/python_backend/.venv/lib/python3.10/site-packages/djongo/cursor.py", line 59, in execute raise db_exe from e djongo.database.DatabaseError The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/app/python_backend/MgBackApi/manage.py", line 22, in main() File "/app/python_backend/MgBackApi/manage.py", line 18, in main execute_from_command_line(sys.argv) File "/app/python_backend/.venv/lib/python3.10/site-packages/django/core/management/__init__.py", line 446, in execute_from_command_line utility.execute() File "/app/python_backend/.venv/lib/python3.10/site-packages/django/core/management/__init__.py", line 440, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/app/python_backend/.venv/lib/python3.10/site-packages/django/core/management/base.py", line 402, in run_from_argv self.execute(*args, **cmd_options) File "/app/python_backend/.venv/lib/python3.10/site-packages/django/core/management/base.py", line 448, in execute output = self.handle(*args, **options) File "/app/python_backend/.venv/lib/python3.10/site-packages/oauth2_provider/management/commands/cleartokens.py", line 10, in handle clear_expired() File "/app/python_backend/.venv/lib/python3.10/site-packages/oauth2_provider/models.py", line 682, in clear_expired revoked_deleted_no = batch_delete(revoked, revoked_query) File "/app/python_backend/.venv/lib/python3.10/site-packages/oauth2_provider/models.py", line 651, in batch_delete batch_length = flat_queryset.count() File "/app/python_backend/.venv/lib/python3.10/site-packages/django/db/models/query.py", line 621, in count return self.query.get_count(using=self.db) File "/app/python_backend/.venv/lib/python3.10/site-packages/django/db/models/sql/query.py", line 559, in get_count return obj.get_aggregation(using, ["__count"])["__count"] File "/app/python_backend/.venv/lib/python3.10/site-packages/django/db/models/sql/query.py", line 544, in get_aggregation result = compiler.execute_sql(SINGLE) File "/app/python_backend/.venv/lib/python3.10/site-packages/django/db/models/sql/compiler.py", line 1398, in execute_sql cursor.execute(sql, params) File "/app/python_backend/.venv/lib/python3.10/site-packages/django/db/backends/utils.py", line 103, in execute return super().execute(sql, params) File "/app/python_backend/.venv/lib/python3.10/site-packages/django/db/backends/utils.py", line 67, in execute return self._execute_with_wrappers( File "/app/python_backend/.venv/lib/python3.10/site-packages/django/db/backends/utils.py", line 80, in _execute_with_wrappers return executor(sql, params, many, context) File "/app/python_backend/.venv/lib/python3.10/site-packages/django/db/backends/utils.py", line 84, in _execute with self.db.wrap_database_errors: File "/app/python_backend/.venv/lib/python3.10/site-packages/django/db/utils.py", line 91, in __exit__ raise dj_exc_value.with_traceback(traceback) from exc_value File "/app/python_backend/.venv/lib/python3.10/site-packages/django/db/backends/utils.py", line 89, in _execute return self.cursor.execute(sql, params) File "/app/python_backend/.venv/lib/python3.10/site-packages/djongo/cursor.py", line 59, in execute raise db_exe from e django.db.utils.DatabaseError