|
8 | 8 | """ |
9 | 9 |
|
10 | 10 | # ruff: noqa: S608 |
11 | | -# ruff: noqa: E501 |
12 | 11 |
|
13 | 12 | from collections.abc import AsyncIterator, Sequence |
14 | 13 | from contextlib import contextmanager |
@@ -256,7 +255,7 @@ def _setup_collection(self, *, collection: str) -> None: |
256 | 255 | _ = self._sanitize_collection(collection=collection) |
257 | 256 |
|
258 | 257 | # Create the main table if it doesn't exist |
259 | | - table_sql = f"CREATE TABLE IF NOT EXISTS {self._table_name} (collection VARCHAR(255) NOT NULL, key VARCHAR(255) NOT NULL, value JSONB NOT NULL, ttl DOUBLE PRECISION, created_at TIMESTAMPTZ, expires_at TIMESTAMPTZ, PRIMARY KEY (collection, key))" |
| 258 | + table_sql = f"CREATE TABLE IF NOT EXISTS {self._table_name} (collection VARCHAR(255) NOT NULL, key VARCHAR(255) NOT NULL, value JSONB NOT NULL, ttl DOUBLE PRECISION, created_at TIMESTAMPTZ, expires_at TIMESTAMPTZ, PRIMARY KEY (collection, key))" # noqa: E501 |
260 | 259 |
|
261 | 260 | # Create index on expires_at for efficient TTL queries |
262 | 261 | # Ensure index name <= 63 chars (PostgreSQL identifier limit) |
@@ -370,7 +369,8 @@ def _put_managed_entry(self, *, key: str, collection: str, managed_entry: Manage |
370 | 369 | sanitized_collection = self._sanitize_collection(collection=collection) |
371 | 370 |
|
372 | 371 | with self._acquire_connection() as conn: |
373 | | - upsert_sql = f"INSERT INTO {self._table_name} (collection, key, value, ttl, created_at, expires_at) VALUES ($1, $2, $3, $4, $5, $6) ON CONFLICT (collection, key) DO UPDATE SET value = EXCLUDED.value, ttl = EXCLUDED.ttl, expires_at = EXCLUDED.expires_at" # pyright: ignore[reportUnknownMemberType] |
| 372 | + upsert_sql = f"INSERT INTO {self._table_name} (collection, key, value, ttl, created_at, expires_at) VALUES ($1, $2, $3, $4, $5, $6) ON CONFLICT (collection, key) DO UPDATE SET value = EXCLUDED.value, ttl = EXCLUDED.ttl, expires_at = EXCLUDED.expires_at" # noqa: E501 |
| 373 | + # pyright: ignore[reportUnknownMemberType] |
374 | 374 | conn.execute( |
375 | 375 | upsert_sql, |
376 | 376 | sanitized_collection, |
@@ -415,7 +415,8 @@ def _put_managed_entries( |
415 | 415 |
|
416 | 416 | with self._acquire_connection() as conn: |
417 | 417 | # Use executemany for batch insert |
418 | | - batch_upsert_sql = f"INSERT INTO {self._table_name} (collection, key, value, ttl, created_at, expires_at) VALUES ($1, $2, $3, $4, $5, $6) ON CONFLICT (collection, key) DO UPDATE SET value = EXCLUDED.value, ttl = EXCLUDED.ttl, expires_at = EXCLUDED.expires_at" # pyright: ignore[reportUnknownMemberType] |
| 418 | + batch_upsert_sql = f"INSERT INTO {self._table_name} (collection, key, value, ttl, created_at, expires_at) VALUES ($1, $2, $3, $4, $5, $6) ON CONFLICT (collection, key) DO UPDATE SET value = EXCLUDED.value, ttl = EXCLUDED.ttl, expires_at = EXCLUDED.expires_at" # noqa: E501 |
| 419 | + # pyright: ignore[reportUnknownMemberType] |
419 | 420 | conn.executemany(batch_upsert_sql, values) |
420 | 421 |
|
421 | 422 | @override |
|
0 commit comments