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

fall back to master when connected to secondary #854

Merged
merged 2 commits into from
Aug 22, 2019
Merged

Conversation

shueybubbles
Copy link
Contributor

If the database name in the connection string doesn't match any database found in sys.databases, fall back to master for the database node in Object Explorer.

@ranasaria
Copy link
Contributor

Is the fallback to master a feature of SSMS currently?

@shueybubbles
Copy link
Contributor Author

SSMS doesn't have this issue because its object explorer root is not database-scoped. It always displays the full result of sys.databases query regardless of whether the connection string has an initial catalog.

@ranasaria
Copy link
Contributor

Is this behavior change a good change then? I worry that this might surprise (not necessarily pleasantly) the user. Consider a scenario where a user has database1, database2 and master on her server. Further assume that that database1 is production, database2 is pre-production and master is her development test instance, so all there has same user database objects and schema. Now when she mistypes database1 and database2 in her connection strings to db1 and db2 or some such, she silently gets connected to master and she may not realize that this has happened for quite some time since a lot of child nodes on the database would have the object that she expects!

@shueybubbles
Copy link
Contributor Author

if "initial catalog=somename" is in the string, and "somename" doesn't exist on the server at all, the connection attempt itself will fail.
if "somename" refers to the readable secondary master, the connection will succeed, but queries to sys.databases won't return "somename".

@shueybubbles
Copy link
Contributor Author

ie we still get this dialog: System.Data.SqlClient.SqlException (0x80131904): Cannot open database "myfunky" requested by the login. The login failed.
Login failed for user 'user'.
at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance,

Copy link
Contributor

@ranasaria ranasaria left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

Copy link
Contributor

@kevcunnane kevcunnane left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great. :shipit: and then let's get a build to release it so we can pull into latest Insiders. Thanks David!

@shueybubbles shueybubbles merged commit 4f92813 into master Aug 22, 2019
@coveralls
Copy link

Coverage Status

Coverage increased (+4.06%) to 76.802% when pulling ca94070 on readablesecond into b01bdeb on master.

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

Successfully merging this pull request may close these issues.

None yet

5 participants