Skip to content

Commit cd34018

Browse files
committed
feat(nonlinearizable): #13 - add alias for connection string
1 parent f41245c commit cd34018

File tree

4 files changed

+24
-4
lines changed

4 files changed

+24
-4
lines changed

src/sqlitecloud/driver.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,6 @@ def prepare_statement(
9797
Tuple[SQLiteCloudDataTypes], Dict[Union[str, int], SQLiteCloudDataTypes]
9898
],
9999
) -> str:
100-
# TODO: check for right exception is case of wrong number of parameters
101-
102100
# If parameters is a dictionary, replace the keys in the query with the values
103101
if isinstance(parameters, dict):
104102
for key, value in parameters.items():

src/sqlitecloud/types.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,10 @@ def _parse_connection_string(self, connection_string) -> None:
212212
else:
213213
value = value
214214

215+
# alias
216+
if opt == "nonlinearizable":
217+
opt = "non_linearizable"
218+
215219
if hasattr(self, opt):
216220
setattr(self, opt, value)
217221
elif hasattr(self.account, opt):

src/tests/unit/test_driver.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,7 @@ def test_prepare_statement_with_dict_parameters(self):
114114

115115
assert expected_result == result
116116

117-
# TODO: should rise exception
118-
def test_prepare_statement_with_missing_parameters(self):
117+
def test_prepare_statement_with_missing_parameters_does_not_raise_exception(self):
119118
driver = Driver()
120119

121120
query = "UPDATE users SET name = :name, age = :age WHERE id = :id"

src/tests/unit/test_types.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import pytest
2+
3+
from sqlitecloud.types import SQCloudConfig
4+
5+
6+
class TestSQCloudConfig:
7+
@pytest.mark.parametrize(
8+
"param, value",
9+
[
10+
("non_linearizable", True),
11+
("nonlinearizable", True),
12+
],
13+
)
14+
def test_parse_connection_string_with_nonlinarizable(self, param: str, value: any):
15+
connection_string = f"sqlitecloud://myhost.sqlitecloud.io?{param}={value}"
16+
17+
config = SQCloudConfig(connection_string)
18+
19+
assert config.non_linearizable

0 commit comments

Comments
 (0)