Conversation
| else: | ||
| self.row_limit = c['main'].as_int('row_limit') | ||
|
|
||
| self.row_limit = \ |
There was a problem hiding this comment.
Is this the right layer/place to make the fix? This seems like an option parsing concern and perhaps handled by argparse?
There was a problem hiding this comment.
So we definitely can add a check in argparse. However, we may want to keep logic elsewhere because we also accept a value from our config if there's no value for the --row-limit arg. Where that somewhere should be is open for debate.
I've considered main.py and the current location in mssqlcli.py. I picked the current location due to easier testability, also it seems like good design to have the constructor handle this logic.
There was a problem hiding this comment.
Let's fix this to args parse for now - seems like the right place.
Looks like a there are a number of issues reading values from our config so let's fix those in another PR at a later date.
There was a problem hiding this comment.
I take back my prior statement—I was able to move logic for checking the config value right in argparse. It seems to work well, once tests pass I'll update the PR.
| try: | ||
| # try/except block needed if shutdown is invoked before sqltoolsclient is defined. | ||
| # example: invalid row-limit argument is passed. | ||
| if self.sqltoolsclient: |
There was a problem hiding this comment.
This makes me nervous. In what situations will we raise an AttributeError?
There was a problem hiding this comment.
AttributeError is raised f the MssqlCli constructor exits due to invalid parameters. In this case, say we input a series of characters instead of an integer for --row-limit—we exit during class instantiation, and before sqltoolsclient gets instantiated. Therefore the class doesn't possess the sqltoolsclient attribute, thus raising an AttributeError.
|
|
||
| return args_parser | ||
|
|
||
| def check_positive_int(row_limit): |
There was a problem hiding this comment.
Can you add 'row_limit' to the method name? This way, it stands out from being a generic 'check_positive_int' method. Ideally, we have a generic method where check_row_limit calls check_positive_int('row_limit' value), and check positive can be resused.
|
I'm fairly certain recent failures are due to PR validation build pipelines using the master DB, which tests in this branch don't support. Best we wait until #441 is approved. |
|
Can you clarify what you mean by master db? master db should be read only, and tests should use their own database. |
Correct—with our stabilize DB PR, tests now generate a test DB if performing operations off of a database. Some tests were still performing commands off of the permanent DB we created, but that will all change once we merge #441. In anticipation of this change, I set up or PR validation pipelines to no longer use the permanent DB, so we could properly test #441. This impacts other PRs (like this one) so it's best we wait to merge until #441 is complete. |
12f5c56 to
b768690
Compare
Fixes #444.
The
--row-limitarg was breaking mssql-cli because our code attempted to use a number operator on a string. The fix requires casting the parsed option as an integer.Notes:
row_limitis validated in theMssqlCliconstructor, which uses a new_set_row_limitmethod to validate a positive integer._set_row_limitcallssys.exit(1)if an invalid value is provided.AttributeExceptionin the__del__method because shutdown is called on an uninstantiatedsqltoolsclient.