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

Same Table / View names, different Databases, Collision Problem #497

Closed
MichalisDBA opened this issue Apr 20, 2024 · 8 comments
Closed

Same Table / View names, different Databases, Collision Problem #497

MichalisDBA opened this issue Apr 20, 2024 · 8 comments
Assignees
Labels
enhancement New feature or request fixed-waiting-feedback Issue resolved pending final review.
Milestone

Comments

@MichalisDBA
Copy link

Hello.

There is a problem when you start db2rest and the user account has access to multiple databases and these databases have tables or views that have same names.

For example. We have in a MySQL server 2 databases.

DB1 and DB2.

Both these databases have a table named users.

So the schema looks like this

DB1.users and DB2.users

When you start db2rest with a user account that has access to these 2 databases, only the latest table name that is fetched is cached. In this example only DB2.users will be available in http://localhost:8080/users endpoint

I believe the API endpoint must change as @kdhrubo said to something like /db/schema_catalog/table

@kdhrubo
Copy link
Owner

kdhrubo commented Apr 23, 2024

@MichalisDBA @thadguidry
There can be headers to specify the catalog and schema.
Then a lookup will pick the correct table.

The schema thing was removed to enable joining across tables in a different schema. A restriction can be added if a schema is specified explicitly then only tables in that schema would be considered.

@thadguidry
Copy link
Collaborator

Sure, and later we'll just need to mention in Docs that schema restriction mechanism is not a replacement for good security practices with user account management in a DB and that our schema restriction config is only provided as a convenience option

@MichalisDBA
Copy link
Author

So @kdhrubo will this solve the problem? Will be there a way to query both tables that have the same name but they are in different schemas?

@grabdoc
Copy link
Collaborator

grabdoc commented Apr 23, 2024

This should solve the problem.

  • for GET use header Accept-Profile to specify schema.

Then two different tables can be queried.

GET /users HTTP/1.1
Accept-Profile: DB1
GET /users HTTP/1.1
Accept-Profile: DB2

Joins are using POST and can ignore such header for now to allow multi-schema joins.

@kdhrubo
Copy link
Owner

kdhrubo commented Apr 24, 2024

@MichalisDBA this will work hope to make a release with these changes in a week.

@kdhrubo kdhrubo self-assigned this Apr 24, 2024
@kdhrubo kdhrubo added the enhancement New feature or request label Apr 24, 2024
@kdhrubo kdhrubo added this to the April2024 milestone Apr 24, 2024
@kdhrubo
Copy link
Owner

kdhrubo commented Apr 24, 2024

Closing this ticket with reference to the documentation/web project

kdhrubo/db2rest-web#45

@kdhrubo kdhrubo closed this as completed Apr 24, 2024
@kdhrubo kdhrubo reopened this Apr 24, 2024
kdhrubo pushed a commit that referenced this issue Apr 25, 2024
kdhrubo pushed a commit that referenced this issue Apr 27, 2024
kdhrubo pushed a commit that referenced this issue Apr 27, 2024
kdhrubo pushed a commit that referenced this issue Apr 27, 2024
@kdhrubo kdhrubo added the fixed-waiting-feedback Issue resolved pending final review. label Apr 27, 2024
@kdhrubo
Copy link
Owner

kdhrubo commented Apr 27, 2024

To be available in release 0.3.1

@MichalisDBA
Copy link
Author

MichalisDBA commented Apr 29, 2024

Hello.

Can confirm that now it is working.

With Accept-Profile: DB1 and Accept-Profile: DB2, tables that have the same name can now be queried. Also they appear at $schemas endpoint correctly.

Please mention it in the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request fixed-waiting-feedback Issue resolved pending final review.
Projects
None yet
Development

No branches or pull requests

4 participants