{{{
>>> 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.
* status: new => closed
* resolution: => invalid
Comment:
`SQLCompiler` isn't a public API. Any usage is at your own risk.
--
Ticket URL: <https://code.djangoproject.com/ticket/30145#comment:1>