goldmansachs / obevo

Obevo is a database deployment tool that handles enterprise scale schemas and complexity
Apache License 2.0
236 stars 56 forks source link

DB2: Allow schemas that have same name as keyword #179

Open shantstepanian opened 6 years ago

shantstepanian commented 6 years ago

A client defined a schema as CUBE and REF.

In schemacrawler, this comes back as "CUBE" or "REF", which our code isn't handling (note SchemaCrawler.java:426 and SchemaRetriever:181)

swayamraina commented 5 years ago

Hi @shantstepanian I would love to fix this. Can you explain a bit more about this?

shantstepanian commented 5 years ago

If someone defines a physical schema in DB2 as a keyword like CUBE, then it fails as the SQLs that Obevo generates may fail, e.g.

SET SCHEMA CUBE

CUBE is treated as a db2 keyword, and so you get a syntax error

Instead, something like the following would work: SET SCHEMA "CUBE"

We have some code that will get the physical schema (e.g. DbPlatform.getSchemaPrefix(...)) - may be best to figure out how to have one of these methods updated to include quotes if the schema is named as a keyword

FYI - this ticket could possibly be the most intricate/complex one to do compared to the other two you created (albeit, it could end up being less code ultimately). Potentially the others could be easiest to start (maybe the MySQL one, since you'll get an idea of how things work end-to-end)