Skip to content

Commit

Permalink
fix: sql statement for non-nullable column (#85)
Browse files Browse the repository at this point in the history
  • Loading branch information
averikitsch committed Mar 12, 2024
1 parent 864f642 commit e143e14
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/langchain_google_cloud_sql_pg/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,9 +259,8 @@ async def ainit_vectorstore_table(
"{content_column}" TEXT NOT NULL,
"{embedding_column}" vector({vector_size}) NOT NULL"""
for column in metadata_columns:
query += f""",\n"{column.name}" {column.data_type}""" + (
"NOT NULL" if not column.nullable else ""
)
nullable = "NOT NULL" if not column.nullable else ""
query += f',\n"{column.name}" {column.data_type} {nullable}'
if store_metadata:
query += f""",\n"{metadata_json_column}" JSON"""
query += "\n);"
Expand Down Expand Up @@ -333,9 +332,8 @@ async def ainit_document_table(
{content_column} TEXT NOT NULL
"""
for column in metadata_columns:
query += f',\n"{column.name}" {column.data_type}' + (
"NOT NULL" if not column.nullable else ""
)
nullable = "NOT NULL" if not column.nullable else ""
query += f',\n"{column.name}" {column.data_type} {nullable}'
metadata_json_column = metadata_json_column or "langchain_metadata"
if store_metadata:
query += f',\n"{metadata_json_column}" JSON'
Expand Down

0 comments on commit e143e14

Please sign in to comment.