Opened 8 years ago
Closed 4 years ago
#27708 closed Bug (fixed)
Relation between tables in different schemas with big names
Reported by: | felipeps | Owned by: | nobody |
---|---|---|---|
Component: | Migrations | Version: | dev |
Severity: | Normal | Keywords: | different schema relation |
Cc: | Triage Stage: | Accepted | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description (last modified by )
I'm using Django 1.9.7 with Postgresql.
When I try to migrate a relation between two tables in different schemas, for example: a table named product, which is in a schema named dataflex and another table named client_product_sale_stc in another schema.
I got this error:
django.db.utils.ProgrammingError: ERRO: syntax error at or near "dataflex"
LINE 1: ...CONSTRAINT "client_product_setor_id_52aad07a_fk_"dataflex"....
After sometime trying to figure It out a solution for this problem, I tried to change the schemas's name to just df instead of dataflex and It worked perfectly.
I also tried to decreased table's name size and It worked just like when I decreased schema's name size, so It seems to be a problem with big constraints names.
I'm using the following syntax:
db_table = '"dataflex"."product"'
setor_id is the name of the field of the relation in client_product_sale_stx model/table.
product model/table does not have a field for the relation.
Examples models:
class ClientProductSaleStc(): setor_id = models.ForeignKey(Product, db_column='setor_id') class Meta: db_table = 'client_product_sale_stc' class Product(): recnum = models.BigIntegerField(unique=True) hor_due = models.DecimalField(max_digits=2, decimal_places=0) min_due = models.DecimalField(max_digits=2, decimal_places=0) class Meta: db_table = '"dataflex"."product"'
Change History (8)
comment:1 by , 8 years ago
Type: | Uncategorized → Bug |
---|
comment:2 by , 8 years ago
Description: | modified (diff) |
---|
follow-up: 5 comment:3 by , 8 years ago
comment:4 by , 8 years ago
Description: | modified (diff) |
---|
comment:5 by , 8 years ago
Replying to Tim Graham:
Could you please give example models to reproduce the problem?
Sure, I updated the ticket with the example models.
comment:6 by , 8 years ago
Needs tests: | set |
---|---|
Triage Stage: | Unreviewed → Accepted |
Version: | 1.9 → master |
I believe this was fixed by 69b7d4b116e3b70b250c77829e11038d5d55c2a8, could you confirm this is the case?
Adapting the Oracle only test to also perform similar assertions on PostgreSQL using schemas was something I proposed on the PR but didn't enforce to avoid overloading the initial contributor. @felipeps, is this something you could do for PostgreSQL?
comment:7 by , 8 years ago
Description: | modified (diff) |
---|
comment:8 by , 4 years ago
Needs tests: | unset |
---|---|
Resolution: | → fixed |
Status: | new → closed |
Fixed in ee85ef8315db839e5723dea19d8b971420a2ebb4 and 69b7d4b116e3b70b250c77829e11038d5d55c2a8.
Regression test was added in 2e8941b6f90e65ffad3f07083b8de59e8ed29767.
Could you please give example models to reproduce the problem?