Skip to content

add_synonym with database link #2051

@davinlagerroos

Description

@davinlagerroos

First, thank you for all your work on this gem. Our institution has a large investment in oracle and this gem allows us to work in our preferred framework while taking advantage of the oracle resources and expertise of the institution.

While testing our upgrade to rails 6, we started getting errors like "DESC OTHER_USER.TABLE" failed; does it exist? After some time we traced the issue to models that were using a synonym that had a database link. With the removal of database link support in #1668 the synonyms were still getting built, but without the link, so the synonym was pointing to a non-existent object.

We've worked around the issue, but I wonder if there is a way to save other developers the debugging time.

Steps to reproduce

add_synonym "new_synonym" "other_user.table@dblink", force: true

Expected behavior

Not sure. Perhaps it should raise a error.

It looks like add_synonym uses quote_table_name, which is silently ignoring the link. Could quote_table_name instead raise like Connection#describe? That could also flag other legacy uses of db links as well.

Actual behavior

select * from user_synonyms

SYNONYM_NAME     TABLE_OWNER     TABLE_NAME       DB_LINK ORIGIN_CON_ID
---------------- --------------- ---------------- ------- -------------
NEW_SYNONYM      OTHER_USER      TABLE                    0

System configuration

Rails version: 6.0.3.2

Oracle enhanced adapter version: 6.0.4

Ruby version: ruby 2.6.5

Oracle Database version: Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions