Support for database links
|Reported by:||Owned by:||nobody|
|Component:||Database layer (models, ORM)||Version:||master|
|Cc:||ian.g.kelly@…, diegobz, anssi.kaariainen@…||Triage Stage:||Accepted|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
Currently, Oracle with Django do not support database links (see Oracle documentation)
It's used this way in SQL:
select count(*) from "MY_TABLE"@"MY_DBLINK";
With Django, I tried to passe it through the db_name
class MyObject(models.Model): class Meta: managed = False db_table = u'"MY_TABLE"@"MY_DBLINK"'
However, when it comes to write sql, Django use db_table to specify the column names. Using db link, the generated command is not valid:
SELECT "MY_TABLE"@"MY_DBLINK"."COLUMN1", "MY_TABLE"@"MY_DBLINK"."COLUMN2" FROM "MY_TABLE"@"MY_DBLINK"
It should be:
SELECT "MY_TABLE"."COLUMN1"@"MY_DBLINK", "MY_TABLE"."COLUMN2"@"MY_DBLINK" FROM "MY_TABLE"@"MY_DBLINK"
I think it worth to add a new db_link Meta option, eg.
class MyObject(models.Model): class Meta: managed = False db_table = u'MY_TABLE' db_link = u'MY_DBLINK'
A workaround could be to define a new database access in Django settings. However, I guess in some cases, the remote database could be reached only from the bridge - not directly from Django application. That's why this options should be needed.
Change History (6)
comment:1 Changed 5 years ago by
|Triage Stage:||Unreviewed → Accepted|
comment:2 Changed 5 years ago by
|Summary:||[oracle] Support for database links → Support for database links|