Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question about synonym #7

Open
kicaj opened this issue Feb 15, 2016 · 4 comments
Open

Question about synonym #7

kicaj opened this issue Feb 15, 2016 · 4 comments

Comments

@kicaj
Copy link

kicaj commented Feb 15, 2016

Your driver work with synonyms?

@snelg
Copy link
Owner

snelg commented Feb 16, 2016

Hmm, no doesn't look like it does right now. It goes straight to the Oracle system table ALL_TAB_COLUMNS to determine the table's structure, without stopping to see if the given tablename actually exists.
Tables and Views are both described in that Oracle system table, but not synonyms.

So for now, you'll have to use the actual table (or view) name.

@snelg
Copy link
Owner

snelg commented Feb 16, 2016

Oh, and to re-emphasize a point in the README:
Say you have a synonym "FOO" that points to table "BAR" in the schema "OTHER".
This driver won't yet let you simply write

class FoosTable extends Table
{
}

which would be ideal.

But you can specify the actual table name like this

class FoosTable extends Table
{
    public function initialize(array $config)
    {
        $this->table('other.bar');
    }
}

Not a perfect solution, but better than nothing :)

@kicaj
Copy link
Author

kicaj commented Feb 16, 2016

I think it's will be simple to rebuild for work with Oracle Synonyms, based on http://stackoverflow.com/a/3089110/182823, columns are good described.

When I fount a little time, i try create pull request

@snelg
Copy link
Owner

snelg commented Feb 16, 2016

Yes, that bit of SQL works if you already know that the given "tablename" is a synonym.
The tricky part is how the Cake 3 "describe table" works.
The Cake core code asks my driver "Here is a table name. Please give me a single SQL statement that will describe each of the columns in that table."
So we have at least two options:

  1. Create a more complex single SQL statement that will return all column data for a table, view, or synonym. It would have to handle name collisions, i.e. if a user has a table, view, or synonym that has the same name as a public synonym.
  2. Figure out a good place to insert a "pre-check" when Cake first tries to "describe" a table. This pre-check would look at the "table name" and query ALL_SYNONYMS, USER_TABLES, ALL_TABLES, etc. to determine which actual table/view is being referenced.

Those are the first solutions that I thought of, but there are probably more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants