mirror of
https://github.com/zhayujie/chatgpt-on-wechat.git
synced 2026-06-02 00:57:41 +08:00
fix: replace upsert syntax to support SQLite lower version
This commit is contained in:
@@ -341,19 +341,21 @@ class ConversationStore:
|
|||||||
conn = self._connect()
|
conn = self._connect()
|
||||||
try:
|
try:
|
||||||
with conn:
|
with conn:
|
||||||
# Upsert session row.
|
# INSERT OR IGNORE creates the row on first visit;
|
||||||
# channel_type is set only on INSERT (first time); subsequent
|
# the UPDATE always refreshes last_active.
|
||||||
# appends just update last_active to avoid overwriting the value.
|
# Avoids ON CONFLICT...DO UPDATE (requires SQLite >= 3.24).
|
||||||
conn.execute(
|
conn.execute(
|
||||||
"""
|
"""
|
||||||
INSERT INTO sessions
|
INSERT OR IGNORE INTO sessions
|
||||||
(session_id, channel_type, created_at, last_active, msg_count)
|
(session_id, channel_type, created_at, last_active, msg_count)
|
||||||
VALUES (?, ?, ?, ?, 0)
|
VALUES (?, ?, ?, ?, 0)
|
||||||
ON CONFLICT(session_id) DO UPDATE SET
|
|
||||||
last_active = excluded.last_active
|
|
||||||
""",
|
""",
|
||||||
(session_id, channel_type, now, now),
|
(session_id, channel_type, now, now),
|
||||||
)
|
)
|
||||||
|
conn.execute(
|
||||||
|
"UPDATE sessions SET last_active = ? WHERE session_id = ?",
|
||||||
|
(now, session_id),
|
||||||
|
)
|
||||||
|
|
||||||
# Determine starting seq for the new batch.
|
# Determine starting seq for the new batch.
|
||||||
row = conn.execute(
|
row = conn.execute(
|
||||||
|
|||||||
Reference in New Issue
Block a user