Opened 8 years ago

Last modified 4 years ago

#27708 closed Bug

Relation between tables in different schemas with big names — at Version 4

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 felipeps)

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():
    local_id = models.ForeignKey(EstoqueLocal, db_column='local_id')
    empresa_id = models.ForeignKey(Sced015, db_column='empresa_id')
    subcategoria_id = models.ForeignKey(ProdutoSubcategoria, db_column='subcategoria_id')
    produto_id = models.ForeignKey(ProdutoProduto, db_column='produto_id')
    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 (4)

comment:1 by felipeps, 8 years ago

Type: UncategorizedBug

comment:2 by felipeps, 8 years ago

Description: modified (diff)

comment:3 by Tim Graham, 8 years ago

Could you please give example models to reproduce the problem?

comment:4 by felipeps, 8 years ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.
Back to Top