ooops 

in 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 <https://docs.djangoproject.com/en/1.8/ref/databases/#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/management/__init__.py",
>  
> line 363, in execute_from_command_line
> utility.execute()
> File 
> "/Users/cadu/Envs/dj_datadictionary/lib/python2.7/site-packages/django/core/management/__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/management/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/management/base.py",
>  
> line 330, in execute
> output = self.handle(*args, **options)
> File 
> "/Users/cadu/Envs/dj_datadictionary/lib/python2.7/site-packages/django/core/management/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...
> ^
>

-- 
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 [email protected].
To post to this group, send email to [email protected].
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/ed23ff7b-4bca-4ded-a65d-009c285579e9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to