[Developers] multiple create unless_exists in one query
John Giannandrea
jg at metaweb.com
Thu Dec 20 08:56:26 UTC 2007
Arthur,
Im not sure I understand the query here. Can you post the real example?
You normally only need the "create": "unless_exists" clause at the
toplevel, not in the inner clauses.
You are making foo1. Does bar1 already exist?
MQL write will try and find a matching clause and then link to it.
If bar1 didnt exist the it would have to create two of them, which I
agree is not what you want.
-jg
On Dec 19, 2007, at 11:01 PM, Arthur van Hoff wrote:
> Hi,
>
> I wrote a query that created multiple reference to the same object
> using “create”:”unless_exists”.
> Unfortunately, the object did not yet exist, so to my surprise it
> created multiple objects, not just one.
> Had the object already existed, the right thing would have happened.
> Is that a feature or a bug?
>
> Here is a simple example:
>
> “query”:{
> "foobar": [{
> "name": "bar1",
> "type": "/user/avh/default_domain/bar",
> "create": "unless_exists"
> },{
> "name": "bar1",
> "type": "/user/avh/default_domain/bar",
> "create": "unless_exists"
> }],
> "create": "unless_exists",
> "type": "/user/avh/default_domain/foo",
> "name": "foo1"
> }
>
> The result is:
>
> {
> "status": "200 OK",
> "code": "/api/status/ok",
> "result": {
> "foobar": [
> {
> "create": "created",
> "type": "/user/avh/default_domain/bar",
> "name": "bar1"
> },
> {
> "create": "created",
> "type": "/user/avh/default_domain/bar",
> "name": "bar1"
> }
> ],
> "create": "created",
> "type": "/user/avh/default_domain/foo",
> "name": "foo1"
> }
> }
>
> I expected this to result in one “bar1”, but surprisingly I got two.
> I am not sure how to work around this.
>
> Have fun,
>
> Arthur van Hoff
>
> ___________________________________________
> Arthur van Hoff, Dell-ZING, CTO Software and Services.
> W: 650-267-2413, F: 650-267-2498, M: 650-283-0842
>
> _______________________________________________
> Developers mailing list
> Developers at freebase.com
> http://lists.freebase.com/mailman/listinfo/developers
More information about the Developers
mailing list