Skip to content

Commit

Permalink
Handle query params as tuples, not as lists - fix #211
Browse files Browse the repository at this point in the history
  • Loading branch information
amochin committed Feb 28, 2024
1 parent 4a63bd7 commit a69ace4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
14 changes: 7 additions & 7 deletions src/DatabaseLibrary/assertion.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from typing import List, Optional
from typing import Optional, Tuple

from robot.api import logger

Expand All @@ -27,7 +27,7 @@ def check_if_exists_in_database(
sansTran: bool = False,
msg: Optional[str] = None,
alias: Optional[str] = None,
parameters: Optional[List] = None,
parameters: Optional[Tuple] = None,
):
"""
Check if any row would be returned by given the input ``selectStatement``. If there are no results, then this will
Expand Down Expand Up @@ -64,7 +64,7 @@ def check_if_not_exists_in_database(
sansTran: bool = False,
msg: Optional[str] = None,
alias: Optional[str] = None,
parameters: Optional[List] = None,
parameters: Optional[Tuple] = None,
):
"""
This is the negation of `check_if_exists_in_database`.
Expand Down Expand Up @@ -103,7 +103,7 @@ def row_count_is_0(
sansTran: bool = False,
msg: Optional[str] = None,
alias: Optional[str] = None,
parameters: Optional[List] = None,
parameters: Optional[Tuple] = None,
):
"""
Check if any rows are returned from the submitted ``selectStatement``. If there are, then this will throw an
Expand Down Expand Up @@ -140,7 +140,7 @@ def row_count_is_equal_to_x(
sansTran: bool = False,
msg: Optional[str] = None,
alias: Optional[str] = None,
parameters: Optional[List] = None,
parameters: Optional[Tuple] = None,
):
"""
Check if the number of rows returned from ``selectStatement`` is equal to the value submitted. If not, then this
Expand Down Expand Up @@ -178,7 +178,7 @@ def row_count_is_greater_than_x(
sansTran: bool = False,
msg: Optional[str] = None,
alias: Optional[str] = None,
parameters: Optional[List] = None,
parameters: Optional[Tuple] = None,
):
"""
Check if the number of rows returned from ``selectStatement`` is greater than the value submitted. If not, then
Expand Down Expand Up @@ -216,7 +216,7 @@ def row_count_is_less_than_x(
sansTran: bool = False,
msg: Optional[str] = None,
alias: Optional[str] = None,
parameters: Optional[List] = None,
parameters: Optional[Tuple] = None,
):
"""
Check if the number of rows returned from ``selectStatement`` is less than the value submitted. If not, then this
Expand Down
16 changes: 10 additions & 6 deletions src/DatabaseLibrary/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import inspect
import re
import sys
from typing import List, Optional
from typing import List, Optional, Tuple

This comment has been minimized.

Copy link
@PaulBrandUWV

PaulBrandUWV Feb 28, 2024

I think the List import is not used anymore

This comment has been minimized.

Copy link
@amochin

amochin Feb 28, 2024

Author Collaborator

not for the query params, but it's needed for other things in the file


from robot.api import logger

Expand All @@ -31,7 +31,7 @@ def query(
sansTran: bool = False,
returnAsDict: bool = False,
alias: Optional[str] = None,
parameters: Optional[List] = None,
parameters: Optional[Tuple] = None,
):
"""
Runs a query with the ``selectStatement`` and returns the result as a list of rows.
Expand Down Expand Up @@ -98,7 +98,7 @@ def row_count(
selectStatement: str,
sansTran: bool = False,
alias: Optional[str] = None,
parameters: Optional[List] = None,
parameters: Optional[Tuple] = None,
):
"""
Uses the input ``selectStatement`` to query the database and returns the number of rows from the query.
Expand Down Expand Up @@ -137,7 +137,7 @@ def description(
selectStatement: str,
sansTran: bool = False,
alias: Optional[str] = None,
parameters: Optional[List] = None,
parameters: Optional[Tuple] = None,
):
"""
Uses the input ``selectStatement`` to query a table in the db which will be used to determine the description.
Expand Down Expand Up @@ -364,7 +364,7 @@ def execute_sql_string(
sqlString: str,
sansTran: bool = False,
alias: Optional[str] = None,
parameters: Optional[List] = None,
parameters: Optional[Tuple] = None,
omitTrailingSemicolon: Optional[bool] = None,
):
"""
Expand Down Expand Up @@ -547,7 +547,11 @@ def call_stored_procedure(
db_connection.client.rollback()

def __execute_sql(
self, cur, sql_statement: str, omit_trailing_semicolon: Optional[bool] = None, parameters: Optional[List] = None
self,
cur,
sql_statement: str,
omit_trailing_semicolon: Optional[bool] = None,
parameters: Optional[Tuple] = None,
):
"""
Runs the `sql_statement` using `cur` as Cursor object.
Expand Down

0 comments on commit a69ace4

Please sign in to comment.