#30145: SQLCompiler do not escape names correctly
-------------------------------------+-------------------------------------
Reporter: Artem | Owner: nobody
Skoretskiy |
Type: Bug | Status: new
Component: Database | Version: master
layer (models, ORM) |
Severity: Normal | Keywords:
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
I generate custom SQL and I have tried to use `SQLCompiler` to escape
(quote) table names. But it does not work as expected:
{{{
>>> from django.contrib.auth.models import User
>>> qs = User.objects.all()
>>> compiler = qs.query.get_compiler(using=qs.db)
>>> name = 'b"; drop table "world'
>>> sql = 'alter table x rename column a to
{};'.format(compiler.quote_name_unless_alias(name))
>>> print(sql)
alter table x rename column a to "b"; drop table "world";
}}}
I would expect that it would return name that I could use in raw SQL.
You could try youself:
{{{
docker run -ti --rm python:3.7-alpine sh -c "pip install -q
https://github.com/django/django/archive/master.zip && django-admin.py
startproject project . && ./manage.py shell"
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/30145>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/050.7dfc309f62125b2b23007558c7c6b15f%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.