Spaces:
Sleeping
Sleeping
Update main.py
Browse filesHandle delete and update separately
main.py
CHANGED
@@ -185,11 +185,16 @@ async def sms_posts(instance: ResultItem, idx: str = None, action: str = "add")
|
|
185 |
|
186 |
try:
|
187 |
if checker:
|
188 |
-
if action == "
|
|
|
|
|
|
|
|
|
189 |
await session.delete(existing) # Asynchronous
|
190 |
await session.commit()
|
191 |
-
else:
|
192 |
-
|
|
|
193 |
await session.commit()
|
194 |
await session.refresh(instance)
|
195 |
result = instance
|
|
|
185 |
|
186 |
try:
|
187 |
if checker:
|
188 |
+
if action == "add":
|
189 |
+
session.add(instance) # Not asynchronous
|
190 |
+
await session.commit()
|
191 |
+
result = instance
|
192 |
+
elif action == "delete":
|
193 |
await session.delete(existing) # Asynchronous
|
194 |
await session.commit()
|
195 |
+
else: # update
|
196 |
+
existing.update(instance)
|
197 |
+
session.add(existing) # Not asynchronous
|
198 |
await session.commit()
|
199 |
await session.refresh(instance)
|
200 |
result = instance
|