Skip to content

can't convert sql == SELECT COUNT(*) AS "__count" FROM "user_user" WHERE "user_user"."is_superuser" #608

@Laurel-rao

Description

@Laurel-rao

One line description of the issue

Python script

<copy and paste code here>

access url  /admin/user/user/?is_superuser__exact=1

DATABASES = {
    'default': {
        'ENGINE': 'djongo',
        'NAME': 'testDB2',
        'ENFORCE_SCHEMA': True,
        'CLIENT': {
            'host': '1.1.1.1',
            'port': 27017,
            'username': 'root',
            'password': 'root',
        }
    }
}

Traceback

[29/Mar/2022 15:06:04] "POST /admin/login/?next=/admin/user/user/%3Fis_superuser__exact%3D1 HTTP/1.1" 302 0
Internal Server Error: /admin/user/user/
Traceback (most recent call last):
  File "D:\mypro\workdir\reeko_oa_project\venv\lib\site-packages\djongo\sql2mongo\query.py", line 857, in parse
    return handler(self, statement)
  File "D:\mypro\workdir\reeko_oa_project\venv\lib\site-packages\djongo\sql2mongo\query.py", line 933, in _select
    return SelectQuery(self.db, self.connection_properties, sm, self._params)
  File "D:\mypro\workdir\reeko_oa_project\venv\lib\site-packages\djongo\sql2mongo\query.py", line 116, in __init__
    super().__init__(*args)
  File "D:\mypro\workdir\reeko_oa_project\venv\lib\site-packages\djongo\sql2mongo\query.py", line 62, in __init__
    self.parse()
  File "D:\mypro\workdir\reeko_oa_project\venv\lib\site-packages\djongo\sql2mongo\query.py", line 152, in parse
    self.where = WhereConverter(self, statement)
  File "D:\mypro\workdir\reeko_oa_project\venv\lib\site-packages\djongo\sql2mongo\converters.py", line 27, in __init__
    self.parse()
  File "D:\mypro\workdir\reeko_oa_project\venv\lib\site-packages\djongo\sql2mongo\converters.py", line 122, in parse
    params=self.query.params
  File "D:\mypro\workdir\reeko_oa_project\venv\lib\site-packages\djongo\sql2mongo\operators.py", line 475, in __init__
    self._statement2ops()
  File "D:\mypro\workdir\reeko_oa_project\venv\lib\site-packages\djongo\sql2mongo\operators.py", line 438, in _statement2ops
    if prev_op.lhs is None:
AttributeError: 'NoneType' object has no attribute 'lhs'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "D:\mypro\workdir\reeko_oa_project\venv\lib\site-packages\djongo\cursor.py", line 56, in execute
    params)
  File "D:\mypro\workdir\reeko_oa_project\venv\lib\site-packages\djongo\sql2mongo\query.py", line 784, in __init__
    self._query = self.parse()
  File "D:\mypro\workdir\reeko_oa_project\venv\lib\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(*) AS "__count" FROM "user_user" WHERE "user_user"."is_superuser"
	Params: ()
	Version: 1.3.6

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "D:\mypro\workdir\reeko_oa_project\venv\lib\site-packages\django\db\backends\utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
  File "D:\mypro\workdir\reeko_oa_project\venv\lib\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 "D:\mypro\workdir\reeko_oa_project\venv\lib\site-packages\django\core\handlers\exception.py", line 47, in inner
    response = get_response(request)
  File "D:\mypro\workdir\reeko_oa_project\venv\lib\site-packages\django\core\handlers\base.py", line 181, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "D:\mypro\workdir\reeko_oa_project\venv\lib\site-packages\django\contrib\admin\options.py", line 616, in wrapper
    return self.admin_site.admin_view(view)(*args, **kwargs)
  File "D:\mypro\workdir\reeko_oa_project\venv\lib\site-packages\django\utils\decorators.py", line 130, in _wrapped_view
    response = view_func(request, *args, **kwargs)
  File "D:\mypro\workdir\reeko_oa_project\venv\lib\site-packages\django\views\decorators\cache.py", line 44, in _wrapped_view_func
    response = view_func(request, *args, **kwargs)
  File "D:\mypro\workdir\reeko_oa_project\venv\lib\site-packages\django\contrib\admin\sites.py", line 232, in inner
    return view(request, *args, **kwargs)
  File "D:\mypro\workdir\reeko_oa_project\venv\lib\site-packages\django\utils\decorators.py", line 43, in _wrapper
    return bound_method(*args, **kwargs)
  File "D:\mypro\workdir\reeko_oa_project\venv\lib\site-packages\django\utils\decorators.py", line 130, in _wrapped_view
    response = view_func(request, *args, **kwargs)
  File "D:\mypro\workdir\reeko_oa_project\venv\lib\site-packages\django\contrib\admin\options.py", line 1697, in changelist_view
    cl = self.get_changelist_instance(request)
  File "D:\mypro\workdir\reeko_oa_project\venv\lib\site-packages\django\contrib\admin\options.py", line 749, in get_changelist_instance
    sortable_by,
  File "D:\mypro\workdir\reeko_oa_project\venv\lib\site-packages\django\contrib\admin\views\main.py", line 100, in __init__
    self.get_results(request)
  File "D:\mypro\workdir\reeko_oa_project\venv\lib\site-packages\django\contrib\admin\views\main.py", line 235, in get_results
    result_count = paginator.count
  File "D:\mypro\workdir\reeko_oa_project\venv\lib\site-packages\django\utils\functional.py", line 48, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "D:\mypro\workdir\reeko_oa_project\venv\lib\site-packages\django\core\paginator.py", line 97, in count
    return c()
  File "D:\mypro\workdir\reeko_oa_project\venv\lib\site-packages\django\db\models\query.py", line 412, in count
    return self.query.get_count(using=self.db)
  File "D:\mypro\workdir\reeko_oa_project\venv\lib\site-packages\django\db\models\sql\query.py", line 519, in get_count
    number = obj.get_aggregation(using, ['__count'])['__count']
  File "D:\mypro\workdir\reeko_oa_project\venv\lib\site-packages\django\db\models\sql\query.py", line 504, in get_aggregation
    result = compiler.execute_sql(SINGLE)
  File "D:\mypro\workdir\reeko_oa_project\venv\lib\site-packages\django\db\models\sql\compiler.py", line 1175, in execute_sql
    cursor.execute(sql, params)
  File "D:\mypro\workdir\reeko_oa_project\venv\lib\site-packages\django\db\backends\utils.py", line 98, in execute
    return super().execute(sql, params)
  File "D:\mypro\workdir\reeko_oa_project\venv\lib\site-packages\django\db\backends\utils.py", line 66, in execute
    return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
  File "D:\mypro\workdir\reeko_oa_project\venv\lib\site-packages\django\db\backends\utils.py", line 75, in _execute_with_wrappers
    return executor(sql, params, many, context)
  File "D:\mypro\workdir\reeko_oa_project\venv\lib\site-packages\django\db\backends\utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
  File "D:\mypro\workdir\reeko_oa_project\venv\lib\site-packages\django\db\utils.py", line 90, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "D:\mypro\workdir\reeko_oa_project\venv\lib\site-packages\django\db\backends\utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
  File "D:\mypro\workdir\reeko_oa_project\venv\lib\site-packages\djongo\cursor.py", line 59, in execute
    raise db_exe from e
django.db.utils.DatabaseError
[29/Mar/2022 15:06:05] "GET /admin/user/user/?is_superuser__exact=1 HTTP/1.1" 500 235473

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions