Skip to content

Commit

Permalink
clean up unused assigned vars and add test
Browse files Browse the repository at this point in the history
  • Loading branch information
bailliekova committed Jan 29, 2025
1 parent beba271 commit 6927fcb
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
1 change: 0 additions & 1 deletion gerrydb_meta/crud/column.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@ def set_values(
Raises:
ColumnValueTypeError: If column types do not match expected types.
"""
table_name=models.ColumnValue.__table__.name
val_column = COLUMN_TYPE_TO_VALUE_COLUMN[col.type]
now = datetime.now(timezone.utc)

Expand Down
1 change: 0 additions & 1 deletion gerrydb_meta/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
from sqlalchemy.dialects import postgresql
from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column, relationship, Session
from sqlalchemy.sql import func
from sqlalchemy.types import CHAR

from gerrydb_meta.enums import (
ColumnKind,
Expand Down
2 changes: 1 addition & 1 deletion gerrydb_meta/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@

def create_column_value_partition_text(geo_id: int):
table_name=models.ColumnValue.__table__.name
sql=f"CREATE TABLE IF NOT EXISTS {models.SCHEMA}_{table_name}_{geo_id} PARTITION OF {models.SCHEMA}.{table_name} FOR VALUES IN ({geo_id})"
sql=f"CREATE TABLE IF NOT EXISTS {models.SCHEMA}.{table_name}_{geo_id} PARTITION OF {models.SCHEMA}.{table_name} FOR VALUES IN ({geo_id})"
return text(sql)
9 changes: 9 additions & 0 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from gerrydb_meta.utils import create_column_value_partition_text
from sqlalchemy import text

def test_create_column_value_partition_text():
geo_id=42
got=create_column_value_partition_text(geo_id=geo_id)
wanted=text("CREATE TABLE IF NOT EXISTS gerrydb.column_value_42 PARTITION OF gerrydb.column_value FOR VALUES IN (42)")
#different object instances, so compare string form
assert str(got)==str(wanted)

0 comments on commit 6927fcb

Please sign in to comment.