Skip to content

Commit a69ace4

Browse files
committed
Handle query params as tuples, not as lists - fix #211
1 parent 4a63bd7 commit a69ace4

2 files changed

Lines changed: 17 additions & 13 deletions

File tree

src/DatabaseLibrary/assertion.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14-
from typing import List, Optional
14+
from typing import Optional, Tuple
1515

1616
from robot.api import logger
1717

@@ -27,7 +27,7 @@ def check_if_exists_in_database(
2727
sansTran: bool = False,
2828
msg: Optional[str] = None,
2929
alias: Optional[str] = None,
30-
parameters: Optional[List] = None,
30+
parameters: Optional[Tuple] = None,
3131
):
3232
"""
3333
Check if any row would be returned by given the input ``selectStatement``. If there are no results, then this will
@@ -64,7 +64,7 @@ def check_if_not_exists_in_database(
6464
sansTran: bool = False,
6565
msg: Optional[str] = None,
6666
alias: Optional[str] = None,
67-
parameters: Optional[List] = None,
67+
parameters: Optional[Tuple] = None,
6868
):
6969
"""
7070
This is the negation of `check_if_exists_in_database`.
@@ -103,7 +103,7 @@ def row_count_is_0(
103103
sansTran: bool = False,
104104
msg: Optional[str] = None,
105105
alias: Optional[str] = None,
106-
parameters: Optional[List] = None,
106+
parameters: Optional[Tuple] = None,
107107
):
108108
"""
109109
Check if any rows are returned from the submitted ``selectStatement``. If there are, then this will throw an
@@ -140,7 +140,7 @@ def row_count_is_equal_to_x(
140140
sansTran: bool = False,
141141
msg: Optional[str] = None,
142142
alias: Optional[str] = None,
143-
parameters: Optional[List] = None,
143+
parameters: Optional[Tuple] = None,
144144
):
145145
"""
146146
Check if the number of rows returned from ``selectStatement`` is equal to the value submitted. If not, then this
@@ -178,7 +178,7 @@ def row_count_is_greater_than_x(
178178
sansTran: bool = False,
179179
msg: Optional[str] = None,
180180
alias: Optional[str] = None,
181-
parameters: Optional[List] = None,
181+
parameters: Optional[Tuple] = None,
182182
):
183183
"""
184184
Check if the number of rows returned from ``selectStatement`` is greater than the value submitted. If not, then
@@ -216,7 +216,7 @@ def row_count_is_less_than_x(
216216
sansTran: bool = False,
217217
msg: Optional[str] = None,
218218
alias: Optional[str] = None,
219-
parameters: Optional[List] = None,
219+
parameters: Optional[Tuple] = None,
220220
):
221221
"""
222222
Check if the number of rows returned from ``selectStatement`` is less than the value submitted. If not, then this

src/DatabaseLibrary/query.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import inspect
1616
import re
1717
import sys
18-
from typing import List, Optional
18+
from typing import List, Optional, Tuple
1919

2020
from robot.api import logger
2121

@@ -31,7 +31,7 @@ def query(
3131
sansTran: bool = False,
3232
returnAsDict: bool = False,
3333
alias: Optional[str] = None,
34-
parameters: Optional[List] = None,
34+
parameters: Optional[Tuple] = None,
3535
):
3636
"""
3737
Runs a query with the ``selectStatement`` and returns the result as a list of rows.
@@ -98,7 +98,7 @@ def row_count(
9898
selectStatement: str,
9999
sansTran: bool = False,
100100
alias: Optional[str] = None,
101-
parameters: Optional[List] = None,
101+
parameters: Optional[Tuple] = None,
102102
):
103103
"""
104104
Uses the input ``selectStatement`` to query the database and returns the number of rows from the query.
@@ -137,7 +137,7 @@ def description(
137137
selectStatement: str,
138138
sansTran: bool = False,
139139
alias: Optional[str] = None,
140-
parameters: Optional[List] = None,
140+
parameters: Optional[Tuple] = None,
141141
):
142142
"""
143143
Uses the input ``selectStatement`` to query a table in the db which will be used to determine the description.
@@ -364,7 +364,7 @@ def execute_sql_string(
364364
sqlString: str,
365365
sansTran: bool = False,
366366
alias: Optional[str] = None,
367-
parameters: Optional[List] = None,
367+
parameters: Optional[Tuple] = None,
368368
omitTrailingSemicolon: Optional[bool] = None,
369369
):
370370
"""
@@ -547,7 +547,11 @@ def call_stored_procedure(
547547
db_connection.client.rollback()
548548

549549
def __execute_sql(
550-
self, cur, sql_statement: str, omit_trailing_semicolon: Optional[bool] = None, parameters: Optional[List] = None
550+
self,
551+
cur,
552+
sql_statement: str,
553+
omit_trailing_semicolon: Optional[bool] = None,
554+
parameters: Optional[Tuple] = None,
551555
):
552556
"""
553557
Runs the `sql_statement` using `cur` as Cursor object.

0 commit comments

Comments
 (0)