PostgreSQL Mixed-Case Schema Names Not Quoted in Queries (RowCount)
Brought to you by:
johncurrier
As stated, when SchemaSpy attempts to get the row count for tables in a schema with a name that has mixed-case characters ("SchemaName" instead of "schemaname"), the query fails and returns a value of -1 for all tables in that schema. Looking at the analysis logs, it appears that the schema name is not enclosed in quotes, whereas the table name is properly quoted.
Example from logs (redacted):
Note in the
Table.initColumnAutoUpdatewarning that includes the SQL statement sent to the database, the table name ("Notes") is properly quoted, while the schema name (Test) does not have quotation marks, even though it is mixed-case. ThePSQLExceptionbears this out in theERRORlines where we see that "relation "test.Notes" does not exist. The schema name has been converted to lower-case by the PostgreSQL database because it was not quoted in the actual SQL statement.Now, perhaps it's considered "bad form" to create mixed-case database object names. I don't know, and don't really care about opinions on database design theory and such at this point as this is the structure of the database I have to work with. Regardless, however, the fact that it is possible means that there will be those like me who actually have mixed-case object names like this. For example, the table identified in the sample above has a definition with a CREATE statement that looks like this:
Because PostgreSQL is actually (contrary to what you might find on the InterWebz) case-sensitive for all object names - database, schema, table, column, function, view, etc. - that were explicitly created in mixed case (created using quotation marks to define the name in mixed-case), all queries need some sort of parsing/validation for object names.
Last edit: G_Hosa_Phat 2019-01-17