crs4 / notredam

Automatically exported from code.google.com/p/notredam
http://www.notredam.org
17 stars 4 forks source link

Error adding object for class with optional objectref attribute to same class #89

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

1. Create new workspace
2. Workspace -> Configure Vocabulary
3. Add Class "Asset" with 2 attributes (a "status" choice of "not started, in 
progress, completed" which is required). There is no way to add an attribute 
with object reference to the class I'm creating, so I first save the class, then
4. Edit class, add attribute "related" which is an object reference to the 
Asset class (attribute may be empty)
5. Click save, which completes successfully
6. Open "configure vocabulary" again, right-click on Asset to "Add Object", add 
"not started" for status, leave "related" blank, and click save. 

What is the expected output? What do you see instead?

There is an error saving the object. The error page displays:

ArgumentError at /api/workspace/2/kb/object/
Could not determine relationship direction for primaryjoin condition 
'kb_object_asset_irswddf4.related = kb_object_asset_irswddf4.id', on 
relationship asset.related. Ensure that the referencing Column objects have a 
ForeignKey present, or are otherwise part of a ForeignKeyConstraint on their 
parent Table, or specify the foreign_keys parameter to this relationship.

After this error saving, the app is in an invalid state, and when I open 
"configure vocabulary" again, I no longer see the "Asset" class and can't add 
any classes or objects. If I restart the django server, I do see the "Asset" 
class again, but if I try to add an asset object, I get the following error in 
the "PUT http://<myhostname:9000>/api/workspace/2/kb/object/" call:

"Unknown object id reference:"

This happens when I'm trying to add the 1st asset, which can't link to any 
other assets (but that should be okay since the attribute was created as 
optional).

What version of the product are you using? On what operating system?

current notredam-replacement branch, on ubuntu 12.04

Please provide any additional information below.

If you would like a complete JSON dump of all the database tables from 
immediately after I received the above error, let me know where to upload it to 
(contains email addresses, so I can't post publicly).

Original issue reported on code.google.com by sapient....@gmail.com on 8 May 2013 at 10:20

GoogleCodeExporter commented 9 years ago
I also tried in a fresh database creating an 'Entity' Class with a required 
'name' string, and an Asset sub-class with the same 'status' column and a 
'related' attribute that is optional and is an objectreference to an Entity 
class. I thought it might work if I created the 'Asset' class with all its 
attributes in one step and with the objectreference to a different class than 
'Asset', but it didn't work. The error was:

ArgumentError at /api/workspace/2/kb/object/
Can't determine join between 'kb_object_entity_hl4k2sxw' and 
'kb_object_asset_13iyc9a5'; tables have more than one foreign key constraint 
relationship between them. Please specify the 'onclause' of this join 
explicitly.

I will also do a database dump in the current state in case you want that.

Original comment by sapient....@gmail.com on 8 May 2013 at 10:40

GoogleCodeExporter commented 9 years ago
Thank you for your report, I am working on it.

Original comment by alce...@crs4.it on 14 May 2013 at 3:36

GoogleCodeExporter commented 9 years ago
Your issue should be fixed now.  Please have a look at the latest NotreDAM 
revision, and reopen this bug report in case of problems.  Thank you!

Original comment by alce...@crs4.it on 22 May 2013 at 1:54

GoogleCodeExporter commented 9 years ago
Thanks! That fixed it for us.

Original comment by sapient....@gmail.com on 3 Jun 2013 at 5:44