Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/psycopack/_repack.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ def __init__(
lock_timeout: datetime.timedelta = datetime.timedelta(seconds=10),
schema: str = "public",
allow_empty: bool = False,
skip_permissions_check: bool = False,
) -> None:
self.conn = conn
self.cur = cur
Expand All @@ -152,7 +153,8 @@ def __init__(
self.table = table
self.schema = schema
self._check_table_exists()
self._check_user_permissions()
if not skip_permissions_check:
self._check_user_permissions()

self.batch_size = batch_size
self.post_backfill_batch_callback = post_backfill_batch_callback
Expand Down
24 changes: 24 additions & 0 deletions tests/test_repack.py
Original file line number Diff line number Diff line change
Expand Up @@ -2026,3 +2026,27 @@ def test_populate_backfill_log(
)
result = cur.fetchall()
assert result == expected_ranges


def test_with_skip_permissions_check(
connection: _psycopg.Connection,
) -> None:
with _cur.get_cursor(connection, logged=True) as cur:
factories.create_table_for_repacking(
connection=connection,
cur=cur,
table_name="to_repack",
rows=100,
)

with mock.patch.object(
Psycopack, "_check_user_permissions", autospec=True
) as mocked:
Psycopack(
table="to_repack",
batch_size=1,
conn=connection,
cur=cur,
skip_permissions_check=True,
)
mocked.assert_not_called()
Loading