#33789: Table and colums with more then 30 chars can no longer be found on
Oracle.
-------------------------------------+-------------------------------------
Reporter: Paul in 't Hout | Owner: nobody
Type: Bug | Status: closed
Component: Database layer | Version: 4.0
(models, ORM) |
Severity: Normal | Resolution: needsinfo
Keywords: oracle | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Paul in 't Hout):
Here are 2 fictitious models that would have this problem.
In our case they would have been created with a django 1.x , but for this
bug I would think 3.2 would also reproduce.
1. Create migration in 3.2.13
2. Migrate
3. Upgrade to 4.0.5
4. Query the models
{{{
class LongColumnName( models.Model):
id = models.AutoField(primary_key=True)
name = models.CharField(max_length=100, db_index=True, unique=True)
my_very_long_boolean_field_setting =
models.BooleanField(default=False)
class Meta:
db_table = "long_column_name"
app_label = "my_app"
ordering = ["id", "name"]
}}}
And for a long table name
{{{
class LongTableName( models.Model):
id = models.AutoField(primary_key=True)
name = models.CharField(max_length=100, db_index=True, unique=True)
short_field = models.BooleanField(default=False)
class Meta:
db_table = "my_very_long_table_name_for_demo"
app_label = "my_app"
ordering = ["id", "name"]
}}}
I have now gone ahead with a workaround. Which, for the above tables,
would look like this:
1. Get the table and column name as defined in the database for the long
fields and table names:
MY_VERY_LONG_BOOLEAN_FIELD76a5
MY_VERY_LONG_TABLE_NAME_FOd906
2. Update the models with the table_name and db_column name attributes:
{{{
class LongColumnName( models.Model):
id = models.AutoField(primary_key=True)
name = models.CharField(max_length=100, db_index=True, unique=True)
my_very_long_boolean_field_setting =
models.BooleanField(default=False,
db_column="MY_VERY_LONG_BOOLEAN_FIELD76a5"
)
class Meta:
db_table = "long_column_name"
app_label = "my_app"
ordering = ["id", "name"]
class LongTableName( models.Model):
id = models.AutoField(primary_key=True)
name = models.CharField(max_length=100, db_index=True, unique=True)
short_field = models.BooleanField(default=False)
class Meta:
db_table = "MY_VERY_LONG_TABLE_NAME_FOd906"
app_label = "my_app"
ordering = ["id", "name"]
}}}
3. Create a migration
4. Update to Django 4.0.5
5. Fake the migration.
I needed to auto-fake , so I added an empty apply / unapply method as
described here (https://stackoverflow.com/questions/49150541/auto-fake-
django-migration)
--
Ticket URL: <https://code.djangoproject.com/ticket/33789#comment:6>
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 view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/010701818004a62e-b4da39c1-52c0-4eaf-9c73-14dd5718b143-000000%40eu-central-1.amazonses.com.