Skip to content

Commit

Permalink
Set correct error. Refs midgardprojectgh-199
Browse files Browse the repository at this point in the history
  • Loading branch information
piotras committed Apr 2, 2013
1 parent 1933cc7 commit 7b3198b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/midgard_core_query.c
Original file line number Diff line number Diff line change
Expand Up @@ -2521,7 +2521,7 @@ midgard_core_query_get_object (MidgardConnection *mgd, const gchar *classname, M
/* No error, but data model doesn't hold any row */
GdaDataModel *model = GDA_DATA_MODEL (MIDGARD_QUERY_EXECUTOR (select)->priv->resultset);
if (!model || (model && gda_data_model_get_n_rows (model) == 0)) {
g_set_error (error, MIDGARD_GENERIC_ERROR, MGD_ERR_NOT_EXISTS, "Object doesn't exist");
g_set_error (error, MIDGARD_GENERIC_ERROR, MGD_ERR_NOT_EXISTS, NULL);
goto free_objects_and_return;
}

Expand Down
2 changes: 1 addition & 1 deletion src/midgard_object.c
Original file line number Diff line number Diff line change
Expand Up @@ -2500,7 +2500,7 @@ midgard_object_new (MidgardConnection *mgd, const gchar *name, GValue *value)
GError *err = NULL;
midgard_core_query_get_object (mgd, name, &self, FALSE, &err, field, value, NULL);
if (err) {
MIDGARD_ERRNO_SET_STRING (mgd, MGD_ERR_INTERNAL, "%s",
MIDGARD_ERRNO_SET_STRING (mgd, err->code, "%s",
err && err->message ? err->message : "Unknown reason");
g_clear_error (&err);
return NULL;
Expand Down
12 changes: 12 additions & 0 deletions tests/GIR/test_100_object_crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,18 @@ def testPurge(self):
new_obj = Midgard.Object.factory(self.mgd, "gir_test_book_crud", obj.get_property("guid"))
self.assertIsNone(new_obj)

def testLoadDeleted(self):
# https://github.com/midgardproject/midgard-core/issues/199
obj = self.getNewBook()
obj.set_property("title", "The book to delete and load")

self.assertTrue(obj.create())
deleted_id = obj.get_property("id")
self.assertTrue(obj.delete(False))

new_obj = Midgard.Object.factory(self.mgd, "gir_test_book_crud", obj.get_property("guid"))
self.assertEqual(self.mgd.get_error(), Midgard.GenericError.NOT_EXISTS)
self.assertTrue(obj.purge(False))

def testInheritance(self):
obj = Midgard.Object.factory(self.mgd, "gir_test_book_crud", None)
Expand Down

0 comments on commit 7b3198b

Please sign in to comment.