Allow Connecting to Databases with Slashes in the Name via Url Escaping#1406
Allow Connecting to Databases with Slashes in the Name via Url Escaping#1406bheni wants to merge 3 commits intogo-sql-driver:masterfrom dolthub:master
Conversation
This driver supports connecting to such database with I know this driver's DSN is not perfect and it can not be fixed without breaking backward compatibility.
But it isn't backward compatible, is it? |
|
You are correct, it is not backward compatible. Any DSN with a % in the database name would need to be updated from: /dbname%withpercent to /dbname%25withpercent But it still supports those databases with that small change. I can look at other methods of implementing this if that isn't acceptable. But if I took the time to fully reimplement ParseDSN so that this worked properly would you accept the changes? I thought this smaller change, which supports more database name characters, even if not backward compatible, might be more readily accepted. |
| // /dbname | ||
| buf.WriteByte('/') | ||
| buf.WriteString(cfg.DBName) | ||
| dbNameEncoded := url.QueryEscape(cfg.DBName) |
There was a problem hiding this comment.
This should be PathEscape rather than QueryEscape.
QueryEscape will escape many characters that we don't want to escape.
|
I want to fix DSN design in v2. But there is no plan for v2 now. |
|
Fixed in #1432. |
Description
Currently mysql will allow you to create a database with slashes in the name, however this driver does not provide any support for connecting to such databases. This change allows you to use url escaping to include slashes in your database name.
Pic showing mysql allows forward slashes in creation if backtick escaped:

Checklist