Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Event loop crashes when creating a record on a table with defined field #140

Open
2 tasks done
huntipl opened this issue Jan 14, 2025 · 0 comments
Open
2 tasks done
Labels
bug Something isn't working

Comments

@huntipl
Copy link
Contributor

huntipl commented Jan 14, 2025

Describe the bug

Using async client on SDK 0.4.1 and surrealdb 2.1.4, when I create records on schemaless table everything works fine. The moment I defined a field with a VALUE set, I can no longer create records using the SDK (tried both create and query methods, both result in a RuntimeError: Event loop stopped before Future completed. But the record gets created in the database!

Executing pure surrealQL on surrealist works fine.

Also I noticed that none of the SDK methods manipulating the record actually work when the field is defined

Steps to reproduce

# This works
res = await db.create(RecordID("test", "id1"), {"key": "value"})
print(f"Create1:\n{res}")

# This also works
res = await db.query(
    """DEFINE FIELD OVERWRITE created ON test TYPE option<datetime> VALUE $before OR time::now();"""
)
print(f"Query:\n{res}")

# This crashes the event loop
res = await db.create(RecordID("test", "id2"), {"key": "value"})
print(f"Create2:\n{res}"

Result:

Create1:
{'id': RecordID(table_name=test, record_id=id1), 'key': 'value'}

Query:
[{'result': None, 'status': 'OK', 'time': '98.096µs'}]

('no decoder for tag', 12)
Traceback (most recent call last):
  File "app/dbtest.py", line 20, in <module>
    asyncio.run(main())
  File ".pyenv/versions/3.12.5/lib/python3.12/asyncio/runners.py", line 194, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File ".pyenv/versions/3.12.5/lib/python3.12/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".pyenv/versions/3.12.5/lib/python3.12/asyncio/base_events.py", line 685, in run_until_complete
    raise RuntimeError('Event loop stopped before Future completed.')
RuntimeError: Event loop stopped before Future completed.

Side note:

running

res = await db.query("""UPSERT test:id5 CONTENT {key:"val"} RETURN NONE;""")
print(f"Query:\n{res}")

works fine.

Expected behaviour

I expect to be able to create the record when there is a defined table on the table, without crashing the event loop

SurrealDB version

2.1.4

surrealdb.py version

0.4.1

Contact Details

No response

Is there an existing issue for this?

  • I have searched the existing issues

Code of Conduct

  • I agree to follow this project's Code of Conduct
@huntipl huntipl added the bug Something isn't working label Jan 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant