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

Issue with a dash (-) in the database name: No matching schemas found #176

Closed
Spamme1 opened this issue Apr 3, 2018 · 5 comments
Closed
Assignees

Comments

@Spamme1
Copy link

Spamme1 commented Apr 3, 2018

Environment

SchemaCrawler 14.20.03
Java 8 Update 161
Windows 8.1
SQL Server 2016
mssql-jdbc-6.2.2.jre8.jar

Issue

I have an automatically generated database from Jenkins with the name of the branch in the code repository. Now we have a new branch with a dash in the name (app-cfg) and the generated database name is obviously app-cfg. The executed command by Jenkins is

C:\Jenkins\workspace\DBSchema>C:\JenkinsTools\schemacrawler-14.20.03-distribution\_schemacrawler\schemacrawler.cmd -server=sqlserver -database=app-cfg -schemas=app-cfg.dbo -user=schemaspy -password=1234 -c=details -i=standard -fmt=htmlx -o=C:\Jenkins\workspace\DBSchema\schemacrawler\index.html
SchemaCrawler 14.20.03

Error: No matching schemas found

Re-run SchemaCrawler with just the
-?
option for help

Or, re-run SchemaCrawler with an additional
-loglevel=CONFIG
option for details on the error

Removing the dash from the database name works, but because it is an automated process I would like to know how to fix it. I tried to escape the dash with a backslash, by adding the square brackets, by putting it in double and single quotes, but nothing worked. When I took a look to the output I saw something strange:

Apr 03, 2018 11:03:16 AM schemacrawler.crawl.SchemaRetriever retrieveSchemas FINE: Excluding <"app-cfg".dbo> since it does not match /app-cfg.dbo/
Apr 03, 2018 11:03:16 AM schemacrawler.crawl.SchemaRetriever retrieveSchemas FINER: Excluding schema <"app-cfg".dbo>

The database name because of dash is enclosed in a double quote, I tried to use the regular expression matching the "app-cfg".dbo string, but it didn't work either. So is there a solution to this problem? Actually enclosing the database name in a double quote wouldn't be a solution in my case, because it would break all other builds with a branch name without dash in it. So what I'm looking for is for a solution which works with and without a dash in the name of the branch and therefore in the name of the database.

output.zip

@sualeh sualeh self-assigned this Apr 5, 2018
@sualeh
Copy link
Collaborator

sualeh commented Apr 5, 2018

Please try -schemas=\"?app-cfg\"?.dbo and let me know. Of course, your Jenkins process would have to substitute the actual database name instead of app-cfg.

@Spamme1
Copy link
Author

Spamme1 commented Apr 6, 2018

We replace the dash (-) with an underscore (_) when we create the database, so we have solved the problem in another way. Anyway thanks for the reply, but I haven't tested it, but from my knowledge about regular expressions, I don't understand why you try to escape the double quotes, they haven't any special meaning in regular expression, therefore it should be "?app-cfg"?\.dbo, because actually the dot has a special meaning and to match only the a dot, it should be escaped.

@sualeh
Copy link
Collaborator

sualeh commented Apr 6, 2018

I am glad you found a workaround. Thanks for using SchemaCrawler.

@sualeh sualeh closed this as completed Apr 6, 2018
@JuergenRB
Copy link

For everyone who has the same problem.

The string to be compared to the schema has the form "app-cfg".dbo", an effective solution is to replace the " with .
-schemas=.app-cfg..dbo

@hoogoo
Copy link

hoogoo commented Mar 31, 2021

I met a problem:
my database name is HELLO-TEST, all in uppercase,
and the table structure is user(id,name,comment),
then I use the following command to query,

./schemacrawler.sh --log-level=ALL --server=mysql --host=localhost --port=3306 --user=root --password=root --info-level=standard --command=schema --schemas=.HELLO-TEST.

But the table structure cannot be queried,
Then I downloaded the code for debugging (commandline model),
Found in the createTable method in TableRetriever.java

final String catalogName = normalizeCatalogName(results.getString("TABLE_CAT"));

What is returned is the lowercase database name hello-test,
I debugged it for a long time and didn't find the problem.
I changed the database to all lowercase hello-test, and it's fine

sc-create-table.png

@sualeh

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

4 participants