修复sql小问题
This commit is contained in:
@@ -158,7 +158,6 @@ class ImageManager:
|
|||||||
type="emoji",
|
type="emoji",
|
||||||
description=description,
|
description=description,
|
||||||
timestamp=current_timestamp,
|
timestamp=current_timestamp,
|
||||||
# base64=image_base64,
|
|
||||||
)
|
)
|
||||||
# logger.debug(f"保存表情包元数据: {file_path}")
|
# logger.debug(f"保存表情包元数据: {file_path}")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@@ -230,7 +229,6 @@ class ImageManager:
|
|||||||
type="image",
|
type="image",
|
||||||
description=description,
|
description=description,
|
||||||
timestamp=current_timestamp,
|
timestamp=current_timestamp,
|
||||||
# base64=image_base64,
|
|
||||||
)
|
)
|
||||||
logger.debug(f"保存图片元数据: {file_path}")
|
logger.debug(f"保存图片元数据: {file_path}")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@@ -410,7 +408,6 @@ class ImageManager:
|
|||||||
image_id=image_id,
|
image_id=image_id,
|
||||||
emoji_hash=image_hash,
|
emoji_hash=image_hash,
|
||||||
path=file_path,
|
path=file_path,
|
||||||
# base64=image_base64,
|
|
||||||
type="image",
|
type="image",
|
||||||
timestamp=current_timestamp,
|
timestamp=current_timestamp,
|
||||||
vlm_processed=False,
|
vlm_processed=False,
|
||||||
|
|||||||
@@ -189,7 +189,7 @@ class Images(BaseModel):
|
|||||||
emoji_hash = TextField(index=True) # 图像的哈希值
|
emoji_hash = TextField(index=True) # 图像的哈希值
|
||||||
description = TextField(null=True) # 图像的描述
|
description = TextField(null=True) # 图像的描述
|
||||||
path = TextField(unique=True) # 图像文件的路径
|
path = TextField(unique=True) # 图像文件的路径
|
||||||
# base64 = TextField() # 图片的base64编码
|
base64 = TextField(null=True) # 图片的base64编码(可选)
|
||||||
count = IntegerField(default=1) # 图片被引用的次数
|
count = IntegerField(default=1) # 图片被引用的次数
|
||||||
timestamp = FloatField() # 时间戳
|
timestamp = FloatField() # 时间戳
|
||||||
type = TextField() # 图像类型,例如 "emoji"
|
type = TextField() # 图像类型,例如 "emoji"
|
||||||
@@ -419,7 +419,14 @@ def initialize_database():
|
|||||||
else:
|
else:
|
||||||
alter_sql += " NOT NULL"
|
alter_sql += " NOT NULL"
|
||||||
if hasattr(field_obj, "default") and field_obj.default is not None:
|
if hasattr(field_obj, "default") and field_obj.default is not None:
|
||||||
alter_sql += f" DEFAULT {field_obj.default}"
|
# 正确处理不同类型的默认值
|
||||||
|
default_value = field_obj.default
|
||||||
|
if isinstance(default_value, str):
|
||||||
|
alter_sql += f" DEFAULT '{default_value}'"
|
||||||
|
elif isinstance(default_value, bool):
|
||||||
|
alter_sql += f" DEFAULT {int(default_value)}"
|
||||||
|
else:
|
||||||
|
alter_sql += f" DEFAULT {default_value}"
|
||||||
db.execute_sql(alter_sql)
|
db.execute_sql(alter_sql)
|
||||||
logger.info(f"字段 '{field_name}' 添加成功")
|
logger.info(f"字段 '{field_name}' 添加成功")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user