user.settings: use execute_with_json

This reverts commit e3a6f2a542.
This commit is contained in:
Luna 2018-12-06 01:48:22 -03:00
parent e3a6f2a542
commit 3e43efab32
1 changed files with 4 additions and 8 deletions

View File

@ -1,3 +1,5 @@
import json
from quart import Blueprint, jsonify, request, current_app as app from quart import Blueprint, jsonify, request, current_app as app
from litecord.auth import token_check from litecord.auth import token_check
@ -29,16 +31,10 @@ async def patch_current_settings():
for key in j: for key in j:
val = j[key] val = j[key]
jsonb_cnv = ''
# force postgres to update to jsonb await app.storage.execute_with_json(f"""
# when the fields ARE jsonb.
if key in json_fields:
jsonb_cnv = '::jsonb'
await app.db.execute(f"""
UPDATE user_settings UPDATE user_settings
SET {key}=$1{jsonb_cnv} SET {key}=$1
WHERE id = $2 WHERE id = $2
""", val, user_id) """, val, user_id)