jacquayj / GoRODS

Golang binding for iRODS C API: An iRODS client library written in Golang + C
https://godoc.org/github.com/jjacquay712/GoRODS
BSD 3-Clause "New" or "Revised" License
17 stars 5 forks source link

Supporting >1 metadata object with the same Attribute #17

Closed simont closed 8 years ago

simont commented 8 years ago

iRODS doesn't care if you have more than one AVU with the same attribute. GoRods, however, appears to make the assumption that there can be only one Metadata AVU with a given Attribute associated with a particular collection or data object.

e.g. the Add() function checks to see if an AVU with this attribute already exists and if so, it prevents a new one being added: https://github.com/jjacquay712/GoRods/blob/master/meta.go#L310

Supporting iRODS' functionality would seem to be the route to take though this will require some refactoring, etc. to support handling potentially 0..many returned metadata objects as opposed to the current assumption of just ne.

jjacquay712 commented 8 years ago

Looks like you're correct, iRods doesn't mind duplicate AVU attribute names as long as the value or unit differs:

[john@localhost tester]$ imeta -C add gorods testattr test test # Success
[john@localhost tester]$ imeta -C add gorods testattr test test # Fail
ERROR: rcModAVUMetadata failed with error -809000 CATALOG_ALREADY_HAS_ITEM_BY_THAT_NAME
[john@localhost tester]$ imeta -C add gorods testattr test test2 # Success

I'll add more specific checks for matching value & unit, rather than just checking the attribute name. Will also look into returning a slice of meta structs. Thanks for the report!

jjacquay712 commented 8 years ago

MetaCollection.Get now returns a slice, MetaCollection.One returns first match on attribute name. DataObj and Collection .Attribute returns a slice. MetaCollection.Add now checks only for a match in attribute name and value.

These changes should resolve this issue. Be careful when pulling this commit, it will probably break existing code. Still need to test these changes a little more to ensure they're bug free and work as expected.