Skip to content

Commit 21c7470

Browse files
committed
sanitize table names and add required keyword arguments
1 parent 3eeaf5d commit 21c7470

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

langchain_postgres/v2/async_chat_message_history.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ def __init__(
2222
pool: AsyncEngine,
2323
session_id: str,
2424
table_name: str,
25+
*,
2526
store_message: bool,
2627
schema_name: str = "public",
2728
):
@@ -96,8 +97,8 @@ async def create(
9697
engine._pool,
9798
session_id,
9899
table_name,
99-
store_message,
100-
schema_name,
100+
store_message=store_message,
101+
schema_name=schema_name,
101102
)
102103

103104
def _insert_query(self, message: BaseMessage) -> tuple[str, dict]:

langchain_postgres/v2/engine.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,8 @@ async def _ainit_chat_history_table(
391391
Returns:
392392
None
393393
"""
394+
table_name = self._escape_postgres_identifier(table_name)
395+
schema_name = self._escape_postgres_identifier(schema_name)
394396
create_table_query = f"""CREATE TABLE IF NOT EXISTS "{schema_name}"."{table_name}"(
395397
id SERIAL PRIMARY KEY,
396398
session_id TEXT NOT NULL,

0 commit comments

Comments
 (0)