diff --git a/edgedb/datatypes/object.c b/edgedb/datatypes/object.c index 3e0050e2..a2b1b03a 100644 --- a/edgedb/datatypes/object.c +++ b/edgedb/datatypes/object.c @@ -51,13 +51,6 @@ EdgeObject_New(PyObject *desc) return NULL; } - if (EdgeRecordDesc_IDPos(desc) < 0) { - PyErr_SetString( - PyExc_ValueError, - "Cannot create Object without 'id' field"); - return NULL; - } - Py_ssize_t size = EdgeRecordDesc_GetSize(desc); if (size > EDGE_MAX_TUPLE_SIZE) { @@ -137,7 +130,10 @@ EdgeObject_GetID(PyObject *ob) assert(EdgeObject_Check(ob)); EdgeObject *o = (EdgeObject *)ob; Py_ssize_t i = EdgeRecordDesc_IDPos(o->desc); - if (i < 0 || i >= Py_SIZE(o)) { + if (i < 0) { + Py_RETURN_NONE; + } + if (i >= Py_SIZE(o)) { PyErr_BadInternalCall(); return NULL; } diff --git a/tests/datatypes/test_datatypes.py b/tests/datatypes/test_datatypes.py index 741489d4..93bbcd17 100644 --- a/tests/datatypes/test_datatypes.py +++ b/tests/datatypes/test_datatypes.py @@ -561,8 +561,8 @@ def test_object_5(self): lb='link-property', c='property' ) - with self.assertRaisesRegex(ValueError, "without 'id' field"): - f(1, 2, 3) + x = f(1, 2, 3) + self.assertFalse(hasattr(x, 'id')) def test_object_6(self): User = private.create_object_factory(