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

Don't do any extra parsing, put the responsibility on the caller #10489

Merged
merged 4 commits into from
May 19, 2020

Conversation

aaomidi
Copy link
Contributor

@aaomidi aaomidi commented May 19, 2020

The responsibility to send valid URI should be on the caller. We shouldn't be doing weird parsing to try to make sense of it.

We should also avoid using 'boolean' for types of stuff that come externally. There is no guarantee they're a boolean in runtime. (e.g. in this case)

@aaomidi
Copy link
Contributor Author

aaomidi commented May 19, 2020

I don't know if anything is currently using this, but I think we should inform them and make this breaking change.

The code was technically broken before this anyway, and could've had questionable results.

@aaomidi aaomidi requested a review from shueybubbles May 19, 2020 01:21
@aaomidi
Copy link
Contributor Author

aaomidi commented May 19, 2020

@shueybubbles I heard this might break the work you're doing. Let's go over this so we don't get stuck maintaining bad logic forever.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.001%) to 33.941% when pulling 0d81cbc on amir/changeSqlParams into f73d81b on master.

Copy link
Contributor

@Charles-Gagnon Charles-Gagnon left a comment

Choose a reason for hiding this comment

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

Would be good to add a few more tests verifying that the different auth types are parsed correctly.

profile.authenticationType = args.integrated ? Constants.integrated : args.aad ? Constants.azureMFA : (profile.userName.length > 0) ? Constants.sqlLogin : Constants.integrated;
profile.databaseName = args.database ?? '';
profile.userName = args.user ?? '';
profile.authenticationType = args.authenticationType ?? Constants.integrated;
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess we'll just be fine with requiring outside callers to get the casing right too? All our internal code pretty much assumes that. Might be useful to do case insensitive check here and then convert to defined case-sensitive version in the profile.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure I'm a fan of that. We could explicitly say this is what we're expecting, these are the values that aren't going to change.

When I call any REST api for example, the REST api doesn't correct me if I make a casing mistake, it just flat out fails and tells me to go fix my stuff. That's kinda the philosophy I'm following here, if that makes sense?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah that's fine. I personally hate it when stuff requires me to have a specific casing - but I realize it's a pretty normal thing and the code is simpler because of it so it seems fine.

What happens if you give a auth type with invalid casing? The main problem I guess I see is that I highly doubt we handle it in any sane manner so it'd likely just fail in some obscure way along the line. But adding in special logic just for this case isn't super great either so I'm fine either way.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

While I was testing I actually made the mistake of incorrect casing. It simply pops up the connection pane with "unrecognized auth method" or something along those lines.

@aaomidi
Copy link
Contributor Author

aaomidi commented May 19, 2020

If anyone has any objections, I can revert this PR later on!

@aaomidi aaomidi merged commit b02b418 into master May 19, 2020
@aaomidi aaomidi deleted the amir/changeSqlParams branch May 19, 2020 19:18
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.

3 participants