codenotary / immudb

immudb - immutable database based on zero trust, SQL/Key-Value/Document model, tamperproof, data change history
https://immudb.io
Other
8.54k stars 341 forks source link

openSession method does not lower the databaseName. #1721

Closed HugoLePoisson closed 10 months ago

HugoLePoisson commented 1 year ago

What happened I'm currently using the SDK immudb4j. I tried to open a session (defaultdb, immudb, immudb). Then create a new database. Close the session. And open a new one with the new DB.


immuClient.openSession("defaultdb", "immudb", "immudb");

immuClient.createDatabase("hG82t45Plm", true);

immuClient.closeSession();

immuClient.openSession("hG82t45Plm", "immudb", "immudb");

Database name are case sensitive or more precisely the are create in lowercase The createDatabase method lower the string "hG82t45Plm" But the openSession method does not So there is an Exception : UNKNOWN: database does not exist


What you expected to happen

I do not really know if it is a bug or not but we can expect the method openSession, as the createDatabase, lower the Database name field.

How to reproduce it (as minimally and precisely as possible)

Environment

# run "immu* [v1.4.1]" and copy/paste the output here

Additional info (any other context about the problem)

jeroiraz commented 1 year ago

thanks a lot for reporting it @HugoLePoisson

rubiagatra commented 10 months ago

Let me try to fix it

rubiagatra commented 10 months ago

Can you help me @jeroiraz for figuring out where createDatabase lower their name?

https://github.com/codenotary/immudb/blob/4b1d3b1c7bcbf5b34425ea1e0b4bd47d6051c5c4/cmd/immuclient/immuc/setcommands.go#L268?

Or just I lower the string directly in https://github.com/codenotary/immudb/blob/4b1d3b1c7bcbf5b34425ea1e0b4bd47d6051c5c4/test/document_storage_tests/documents_tests/actions/session.go#L28 ?

jeroiraz commented 10 months ago

Can you help me @jeroiraz for figuring out where createDatabase lower their name?

https://github.com/codenotary/immudb/blob/4b1d3b1c7bcbf5b34425ea1e0b4bd47d6051c5c4/cmd/immuclient/immuc/setcommands.go#L268

? Or just I lower the string directly in

https://github.com/codenotary/immudb/blob/4b1d3b1c7bcbf5b34425ea1e0b4bd47d6051c5c4/test/document_storage_tests/documents_tests/actions/session.go#L28

?

thanks @rubiagatra

The fix may need to be done In server package: https://github.com/codenotary/immudb/blob/4b1d3b1c7bcbf5b34425ea1e0b4bd47d6051c5c4/pkg/server/session.go#L31

After checking the request is not nil, the database name attribute may be force to lower case...

rubiagatra commented 10 months ago

I already made the PR #1839 let me know what you think @jeroiraz, Thank you!