Skip to content

Weird save() crash and bad error from Gel #845

@1st1

Description

@1st1

this script

from __future__ import annotations
import asyncio
import uuid, json, typing, pydantic, gel  # noqa: E401, F401
from typing import TypeVar, Generic, Any
from models import default
import models.std as std
import models as m
from rich import print


client = gel.create_client()._with_debug(save_postcheck=True)

alice = client.get(default.User.filter(name="Alice"))
tsl = default.TestSingleLinks(
    req_wprop_friend=default.TestSingleLinks.req_wprop_friend.link(alice, strength=100),
    req_friend=alice,
    opt_friend=alice,
    opt_wprop_friend=default.TestSingleLinks.opt_wprop_friend.link(alice, strength=50),
)

client.save(tsl)

billie = client.get(default.User.filter(name="Billie"))
tsl2 = client.get(
    default.TestSingleLinks.select(
        "*",
        req_wprop_friend=True,
        req_friend=True,
        opt_friend=True,
        opt_wprop_friend=True,
        comp_req_wprop_friend=True,
        comp_req_friend=True,
        comp_opt_friend=True,
        comp_opt_wprop_friend=True,
    ).filter(id=tsl.id)
)

tsl2.req_wprop_friend = default.TestSingleLinks.req_wprop_friend.link(billie)
tsl2.opt_wprop_friend = default.TestSingleLinks.opt_wprop_friend.link(billie)

# Save the changes
client.save(tsl2)

crashes with

Traceback (most recent call last):
  File "/Users/yury/dev/edge/geltest/t.py", line 42, in <module>
    client.save(tsl2)
  File "/Users/yury/dev/edge/edgedb-python/gel/blocking_client.py", line 675, in save
    batch_ids = tx.wait()
                ^^^^^^^^^
  File "/Users/yury/dev/edge/edgedb-python/gel/blocking_client.py", line 610, in wait
    return iter_coroutine(self._wait())
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/yury/dev/edge/edgedb-python/gel/blocking_client.py", line 76, in iter_coroutine
    coro.send(None)
  File "/Users/yury/dev/edge/edgedb-python/gel/blocking_client.py", line 616, in _wait
    return await self._connection.batch_query(ops)  # type: ignore [no-any-return]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/yury/dev/edge/edgedb-python/gel/base_client.py", line 305, in batch_query
    rv = await self._protocol.batch_execute(ctxs)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "gel/protocol/protocol.pyx", line 886, in batch_execute
  File "gel/protocol/protocol.pyx", line 782, in _execute_batch
gel.errors.InternalServerError: more than one row returned by a subquery used as an expression

on this query

                with __query := (
                    with __all_data := <array<tuple<array<std::uuid>,std::uuid,std::uuid>>>$0
                    for __data in std::array_unpack(__all_data) union (
                        (                update <default::TestSingleLinks>__data.2
                set { opt_wprop_friend := <default::User><std::uuid>(  select std::array_unpack(__data.0) limit 1), req_wprop_friend := <default::User><std::uuid>__data.1 }
            )
                    )
                ) select __query{*}

with these args

             [([UUID('b4e784f8-7286-11f0-8040-df194aa8f2b4')], UUID('b4e784f8-7286-11f0-8040-df194aa8f2b4'), UUID('53bca92e-7321-11f0-bfef-cf0403df7d1b'))]

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions