mirror of
https://github.com/lnbits/lnbits.git
synced 2025-10-06 04:25:25 +02:00
fix livestream for postgres compatibility
fix producers create returning id
This commit is contained in:
committed by
fiatjaf
parent
1c0a4e252a
commit
4ce0ed63c0
@@ -160,14 +160,21 @@ async def add_producer(livestream: int, name: str) -> int:
|
|||||||
user = await create_account()
|
user = await create_account()
|
||||||
wallet = await create_wallet(user_id=user.id, wallet_name="livestream: " + name)
|
wallet = await create_wallet(user_id=user.id, wallet_name="livestream: " + name)
|
||||||
|
|
||||||
result = await db.execute(
|
returning = "" if db.type == SQLITE else "RETURNING ID"
|
||||||
"""
|
method = db.execute if db.type == SQLITE else db.fetchone
|
||||||
|
|
||||||
|
result = await method(
|
||||||
|
f"""
|
||||||
INSERT INTO livestream.producers (livestream, name, "user", wallet)
|
INSERT INTO livestream.producers (livestream, name, "user", wallet)
|
||||||
VALUES (?, ?, ?, ?)
|
VALUES (?, ?, ?, ?)
|
||||||
|
{returning}
|
||||||
""",
|
""",
|
||||||
(livestream, name, user.id, wallet.id),
|
(livestream, name, user.id, wallet.id),
|
||||||
)
|
)
|
||||||
|
if db.type == SQLITE:
|
||||||
return result._result_proxy.lastrowid
|
return result._result_proxy.lastrowid
|
||||||
|
else:
|
||||||
|
return result[0]
|
||||||
|
|
||||||
|
|
||||||
async def get_producer(producer_id: int) -> Optional[Producer]:
|
async def get_producer(producer_id: int) -> Optional[Producer]:
|
||||||
|
Reference in New Issue
Block a user