-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6927fcb
commit d11a400
Showing
5 changed files
with
26 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
from sqlalchemy import text | ||
from gerrydb_meta import models | ||
|
||
|
||
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})" | ||
return text(sql) | ||
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})" | ||
return text(sql) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,12 @@ | ||
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) | ||
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) |