-
Notifications
You must be signed in to change notification settings - Fork 192
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
Partial refactor of code base #170
Conversation
build.py
Outdated
targets[action]() | ||
current_action = action.lower() | ||
if current_action in targets: | ||
targets[current_action]() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should validate all actions and fail before we execute any action. #Closed
mssqlcli/mssqlclioptionsparser.py
Outdated
MSSQL_CLI_RC = u'MSSQL_CLI_RC' | ||
|
||
|
||
def initialize(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have two public methods that do the same thing: initialize and get_parser. Can we have a single method: create_parser? #Closed
mssqlcli/mssqlclioptionsparser.py
Outdated
return args_parser | ||
|
||
|
||
def get_parser(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
get_parser implies we are returning an existing instance. Since were creating a new one each call, I'd prefer we name this create_parser or build_parser. #Closed
mssqlcli/mssqlcliclient.py
Outdated
err=True, fg='yellow') | ||
logger.info(u'Unable to reset connection to server {0}; database {1}'.format( | ||
mssqlcli_client.server_name, | ||
mssqlcli_client.database)) | ||
exit(1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this logic can be moved into a reset instance method. #Closed
mssqlcli/mssqlcliclient.py
Outdated
@@ -335,19 +342,19 @@ def reset_connection_and_clients(sql_tools_client, *mssqlcliclients): | |||
try: | |||
sql_tools_client.shutdown() | |||
new_tools_client = SqlToolsClient() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A client should not reinitialize the sqltoolsservice process. Can we move this a reset method in the sqltoolsclient client? #Closed
mssqlcli/mssqlcliclient.py
Outdated
return owner_uri, error_messages | ||
|
||
def execute_multi_statement(self, query): | ||
# Try to run first as special command |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From and API standpoint, it would be nice if we had a single public method to execute on or more statements: execute_query. So execute_single_statement would become private. Any downside to this? #Closed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, no downsides other then background queries will run through additional code path but it wouldn't be harmful.
In reply to: 170340117 [](ancestors = 170340117)
@pensivebrian , YES I WANT TO MOVE MSSQLCLI INTO ITS OWN FILE :) , I can do this on the side in a separate PR as I'm prioritizing the packaging work now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🕐
Also, what are the code coverage numbers with this change?
67% code coverage |
mssqlcli/main.py
Outdated
|
||
click.secho('Reconnected!\nTry the command again.', fg='green') | ||
except Exception as e: | ||
click.secho(str(e), err=True, fg='red') | ||
|
||
def reset_connection(self): | ||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe just call this reset? #Closed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you change this, please update the method name in the logging below.
In reply to: 170392798 [](ancestors = 170392798)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It sounds more intuitive to have reset_connection because that is explicitly resetting, what do you think?
Having just reset can imply a lot of options to be reset for MssqlCli.
In reply to: 170392798 [](ancestors = 170392798)
mssqlcli/main.py
Outdated
self.mssqlcliclient_main.sql_tools_client = self.sqltoolsclient | ||
self.mssqlcliclient_main.is_connected = False | ||
self.mssqlcliclient_main.owner_uri = generate_owner_uri() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like we should clone the existing mssqlclient such that we know we're in a clean state. #Closed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
Can we file a GitHub issue to completely remove click once we are done with refactoring? #Resolved |
@abhisheksinha89 #171 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* Initial refactor from click to arg parser. * Refactoring mssqlcli client and renaming methods. * Refactoring mssqlcliclient. * Updating tests. * Updating import statement order. * Adding missing param and fixing pgsql ref. * Making build.py argument handling robust. * Addressing CR comments. * Renamed method for resetting connection and updated to use clone method. * Updating log message in reset.
* Initial refactor from click to arg parser. * Refactoring mssqlcli client and renaming methods. * Refactoring mssqlcliclient. * Updating tests. * Updating import statement order. * Adding missing param and fixing pgsql ref. * Making build.py argument handling robust. * Addressing CR comments. * Renamed method for resetting connection and updated to use clone method. * Updating log message in reset.
* Initial refactor from click to arg parser. * Refactoring mssqlcli client and renaming methods. * Refactoring mssqlcliclient. * Updating tests. * Updating import statement order. * Adding missing param and fixing pgsql ref. * Making build.py argument handling robust. * Addressing CR comments. * Renamed method for resetting connection and updated to use clone method. * Updating log message in reset.
Changes made:
Argument handling
Example: If no server is passed in, we automatically target master. This reduced checks and centralizes all options into a single file.
Tests
Miscellaneous