Skip to content

Commit 8c06bac

Browse files
Merge pull request #25 from sqlitecloud/#16-compression-enabled-by-default
feat(compression): enabled by default
2 parents 6068ae5 + 78b1e53 commit 8c06bac

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

src/sqlitecloud/datatypes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,8 @@ def __init__(self, connection_str: Optional[str] = None) -> None:
137137
# Socket connection timeout
138138
self.connect_timeout = SQLITECLOUD_DEFAULT.TIMEOUT.value
139139

140-
# Enable compression
141-
self.compression = False
140+
# Compression enabled by default
141+
self.compression = True
142142
# Tell the server to zero-terminate strings
143143
self.zerotext = False
144144
# Database will be created in memory

src/tests/unit/test_driver.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ def test_nonlinearizable_command_before_auth_with_account(
235235
)
236236

237237
run_command_mock.assert_called_once()
238-
assert run_command_mock.call_args[0][1] == expected_buffer
238+
assert expected_buffer in run_command_mock.call_args[0][1]
239239

240240
def test_nonlinearizable_command_before_auth_with_apikey(
241241
self, mocker: MockerFixture
@@ -255,4 +255,21 @@ def test_nonlinearizable_command_before_auth_with_apikey(
255255
expected_buffer = "SET CLIENT KEY NONLINEARIZABLE TO 1;AUTH APIKEY abc123;"
256256

257257
run_command_mock.assert_called_once()
258-
assert run_command_mock.call_args[0][1] == expected_buffer
258+
assert expected_buffer in run_command_mock.call_args[0][1]
259+
260+
def test_compression_enabled_by_default(self, mocker: MockerFixture):
261+
driver = Driver()
262+
263+
config = SQLiteCloudConfig()
264+
config.account = SQLiteCloudAccount()
265+
config.account.apikey = "abc123"
266+
267+
mocker.patch.object(driver, "_internal_connect", return_value=None)
268+
run_command_mock = mocker.patch.object(driver, "_internal_run_command")
269+
270+
driver.connect("myhost", 8860, config)
271+
272+
expected_buffer = "SET CLIENT KEY COMPRESSION TO 1;"
273+
274+
run_command_mock.assert_called_once()
275+
assert expected_buffer in run_command_mock.call_args[0][1]

0 commit comments

Comments
 (0)