Thanks Simon,
I tryied to find some issue related but found nothing.
The ticket #28792 seems exactly the case ...
I'll take a couple of hours (at work), but I'll try that patch
and regenarate the migrations.
thanks again.
---------------------------------------------------------------------
Cadu Leite
Cadu Leite
| Twitter | Medium Blog | Google + |
| @cadu_leite | @cadu_leite | +CarlosLeite |On Tue, Nov 28, 2017 at 4:14 AM, Simon Charette <charette.s@gmail.com> wrote:
Hey Carlos,
I believe the trailing quote truncation issue might be solved in the yet to be released
1.11.8[0][1] version.
Could you confirm whether or not it's the case? You'll have to regenerate your migration.
Best,
Simon
[0] https://github.com/django/django/commit/ a35ab95ed4eec5c62fa19bdc69ecfe 0eff3e1fca
[1] https://code.djangoproject.com/ticket/28792
Le lundi 27 novembre 2017 23:24:59 UTC-5, Carlos Leite a écrit :ooopsin the migration 0007 the index name seems badly formed```python...migrations.AddIndex(
model_name='publisher',
index=models.Index(fields=['name'], name='"big_name-w_name_cd0539_ idx'), # <<<<<<< there is a " in plus. and its never closed.
),```
On Tuesday, November 28, 2017 at 2:01:56 AM UTC-2, Carlos Leite wrote:I was making some introspections on meta attributes from a Model class
jsut to check what changes when we set some attributes on Meta class and etc...
TO check the Meta.db_name
I read the docs and saw that I could use quoted strings as told ..
"
... o prevent such transformations, use a quoted name as the value for db_table:
> db_table = '"name_left_in_lowercase"'
Such quoted names can also be used with Django's other supported database backends; except for Oracle, however, the quotes have no effect. See the Oracle notes for more details.
"
at https://docs.djangoproject.com/en/1.8/ref/models/options/# db-table
Well, when I tried to *migrate* I got the error, during the index creation, described below.
Is it a bug ? or I miss soething ?
I just tried to set a custom name for a table, with quotes and hyphens 8P
'"big_name-with-hyphen-left_in_lowercase"' the error hapends when PostgreSQL tries to create an index and Django named with part of the tables name.
### The Model Class
class Publisher(models.Model):
"""
Book's Author - author is a Book's model supplement.
"""
name = models.CharField(verbose_name='publisher name', max_length=50, null=False)
class Meta:
db_table = '"big_name-with-hyphen-left_in_lowercase"'
get_latest_by = "name"
ordering = ['name', ]
verbose_name = 'Publiser'
verbose_name_plural = 'Publishers'
indexes = [
models.Index(fields=['name', ]),
]
### The Migration 0007
# -*- coding: utf-8 -*-
# Generated by Django 1.11 on 2017-11-28 03:15
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('testapp', '0006_auto_20171127_1927'),
]
operations = [
migrations.RemoveIndex(
model_name='publisher',
name='testapp_pub_name_88e073_idx',
),
migrations.AddIndex(
model_name='publisher',
index=models.Index(fields=['name'], name='"big_name-w_name_cd0539_ idx'),
),
migrations.AlterModelTable(
name='publisher',
table='"big_name-with-hyphen-left_in_lowercase"',
),
]
### traceback
$python manage.py makemigrations
System check identified some issues:
Migrations for 'testapp':
testproject/testapp/migrations/0007_auto_20171128_0315.py
- Remove index testapp_pub_name_88e073_idx from publisher
- Create index "big_name-w_name_cd0539_idx on field(s) name of model publisher
- Rename table for publisher to "big_name-with-hyphen-left_in_lowercase"
(dj_datadictionary) 20171125.Sat01:15:52cadu>/Volumes/p10G/prj/dj_datadictionary _testproject/testproject>
$python manage.py migrate
System check identified some issues:
Operations to perform:
Apply all migrations: admin, auth, contenttypes, sessions, testapp
Running migrations:
Applying testapp.0007_auto_20171128_0315...Traceback (most recent call last):
File "manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
File "/Users/cadu/Envs/dj_datadictionary/lib/python2.7/site- packages/django/core/managemen t/__init__.py", line 363, in execute_from_command_line
utility.execute()
File "/Users/cadu/Envs/dj_datadictionary/lib/python2.7/site- packages/django/core/managemen t/__init__.py", line 355, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Users/cadu/Envs/dj_datadictionary/lib/python2.7/site- packages/django/core/managemen t/base.py", line 283, in run_from_argv
self.execute(*args, **cmd_options)
File "/Users/cadu/Envs/dj_datadictionary/lib/python2.7/site- packages/django/core/managemen t/base.py", line 330, in execute
output = self.handle(*args, **options)
File "/Users/cadu/Envs/dj_datadictionary/lib/python2.7/site- packages/django/core/managemen t/commands/migrate.py", line 204, in handle
fake_initial=fake_initial,
File "/Users/cadu/Envs/dj_datadictionary/lib/python2.7/site- packages/django/db/migrations/ executor.py", line 115, in migrate
state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial)
File "/Users/cadu/Envs/dj_datadictionary/lib/python2.7/site- packages/django/db/migrations/ executor.py", line 145, in _migrate_all_forwards
state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial)
File "/Users/cadu/Envs/dj_datadictionary/lib/python2.7/site- packages/django/db/migrations/ executor.py", line 244, in apply_migration
state = migration.apply(state, schema_editor)
File "/Users/cadu/Envs/dj_datadictionary/lib/python2.7/site- packages/django/db/migrations/ migration.py", line 129, in apply
operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
File "/Users/cadu/Envs/dj_datadictionary/lib/python2.7/site- packages/django/db/migrations/ operations/models.py", line 785, in database_forwards
schema_editor.add_index(model, self.index)
File "/Users/cadu/Envs/dj_datadictionary/lib/python2.7/site- packages/django/db/backends/ base/schema.py", line 330, in add_index
self.execute(index.create_sql(model, self))
File "/Users/cadu/Envs/dj_datadictionary/lib/python2.7/site- packages/django/db/backends/ base/schema.py", line 119, in execute
cursor.execute(sql, params)
File "/Users/cadu/Envs/dj_datadictionary/lib/python2.7/site- packages/django/db/backends/ utils.py", line 80, in execute
return super(CursorDebugWrapper, self).execute(sql, params)
File "/Users/cadu/Envs/dj_datadictionary/lib/python2.7/site- packages/django/db/backends/ utils.py", line 65, in execute
return self.cursor.execute(sql, params)
File "/Users/cadu/Envs/dj_datadictionary/lib/python2.7/site- packages/django/db/utils.py", line 94, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/Users/cadu/Envs/dj_datadictionary/lib/python2.7/site- packages/django/db/backends/ utils.py", line 65, in execute
return self.cursor.execute(sql, params)
django.db.utils.ProgrammingError: zero-length delimited identifier at or near """"
LINE 1: CREATE INDEX ""big_name-w_name_cd0539_idx" ON "testapp_publi...
^To view this discussion on the web visit https://groups.google.com/d/--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com .
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users .msgid/django-users/059d8feb- .45dd-4f30-aa7f-cfc3a71659d5% 40googlegroups.com
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAEM6-QLi3MseEpM63_tqs7RSbnTMzXUB6-JDq2T1tvAsdOr7Eg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment