Fix created_at field type in Variable and ApiKey models (#1792)
* Fix created_at field type in Variable model * Fix created_at field type in ApiKey model * Fix error handling in add_row_to_table function #1790 * Apply type hinting to nest_asyncio import in load.py
This commit is contained in:
parent
736ce22546
commit
3f07a39f5b
4 changed files with 10 additions and 4 deletions
|
|
@ -104,7 +104,7 @@ def run_flow_from_json(
|
|||
"""
|
||||
# Set all streaming to false
|
||||
try:
|
||||
import nest_asyncio
|
||||
import nest_asyncio # type: ignore
|
||||
|
||||
nest_asyncio.apply()
|
||||
except Exception as e:
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ class ApiKeyBase(SQLModel):
|
|||
|
||||
class ApiKey(ApiKeyBase, table=True):
|
||||
id: UUID = Field(default_factory=uuid4, primary_key=True, unique=True)
|
||||
created_at: datetime = Field(
|
||||
created_at: Optional[datetime] = Field(
|
||||
default=None, sa_column=Column(DateTime(timezone=True), server_default=func.now(), nullable=False)
|
||||
)
|
||||
api_key: str = Field(index=True, unique=True)
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ class Variable(VariableBase, table=True):
|
|||
description="Unique ID for the variable",
|
||||
)
|
||||
# name is unique per user
|
||||
created_at: datetime = Field(
|
||||
created_at: Optional[datetime] = Field(
|
||||
default=None,
|
||||
sa_column=Column(DateTime(timezone=True), server_default=func.now(), nullable=True),
|
||||
description="Creation time of the variable",
|
||||
|
|
|
|||
|
|
@ -101,10 +101,16 @@ def add_row_to_table(
|
|||
conn.execute(insert_sql, values)
|
||||
except Exception as e:
|
||||
# Log values types
|
||||
column_error_message = ""
|
||||
for key, value in validated_dict.items():
|
||||
logger.error(f"{key}: {type(value)}")
|
||||
if value in str(e):
|
||||
column_error_message = f"Column: {key} Value: {value} Error: {e}"
|
||||
|
||||
logger.error(f"Error adding row to table: {e}")
|
||||
if column_error_message:
|
||||
logger.error(f"Error adding row to {table_name}: {column_error_message}")
|
||||
else:
|
||||
logger.error(f"Error adding row to {table_name}: {e}")
|
||||
|
||||
|
||||
async def log_message(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue