Skip to content

Commit

Permalink
avoid interpolating values into sql queries (#18181)
Browse files Browse the repository at this point in the history
* avoid interpolating values into sql queries

* Update data_store.py
  • Loading branch information
altendky committed Jun 18, 2024
1 parent 51cc569 commit a9dfc75
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions chia/data_layer/data_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -636,14 +636,14 @@ async def get_last_tree_root_by_hash(
self, store_id: bytes32, hash: Optional[bytes32], max_generation: Optional[int] = None
) -> Optional[Root]:
async with self.db_wrapper.reader() as reader:
max_generation_str = f"AND generation < {max_generation} " if max_generation is not None else ""
max_generation_str = "AND generation < :max_generation " if max_generation is not None else ""
node_hash_str = "AND node_hash == :node_hash " if hash is not None else "AND node_hash is NULL "
cursor = await reader.execute(
"SELECT * FROM root WHERE tree_id == :tree_id "
f"{max_generation_str}"
f"{node_hash_str}"
"ORDER BY generation DESC LIMIT 1",
{"tree_id": store_id, "node_hash": hash},
{"tree_id": store_id, "node_hash": hash, "max_generation": max_generation},
)
row = await cursor.fetchone()

Expand Down

0 comments on commit a9dfc75

Please sign in to comment.