[Developers] implicit connect directives in mqlwrite operations

Augusto Callejas acallejas at appliedminds.com
Tue Jul 1 23:25:02 UTC 2008


hi-

in the sandbox, i ran a write operation twice.  the first time it created
the "/people/marriage" value.  the second time it reported it was already
created.  i performed a query and determined that the insert connected the
new "/people/marriage" value with the "/people/person" located at
"spouse_s.spouse":

=====
{
  "create" : "unless_exists",
  "date_of_birth" : "1932-02-27",
  "name" : "Elizabeth Taylor",
  "spouse_s" : {
    "create" : "unless_connected",
    "spouse" : {
      "name":"Augusto Callejas",
      "type" : "/people/person"
    },
    "type" : "/people/marriage"
  },
  "type" : "/people/person"
}
-----
{
  "create" : "existed",
  "date_of_birth" : "1932-02-27",
  "name" : "Elizabeth Taylor",
  "spouse_s" : {
    "create" : "created",
    "spouse" : {
      "name" : "Augusto Callejas",
      "type" : "/people/person"
    },
    "type" : "/people/marriage"
  },
  "type" : "/people/person"
}
-----
{
  "create" : "existed",
  "date_of_birth" : "1932-02-27",
  "name" : "Elizabeth Taylor",
  "spouse_s" : {
    "create" : "existed",
    "spouse" : {
      "name" : "Augusto Callejas",
      "type" : "/people/person"
    },
    "type" : "/people/marriage"
  },
  "type" : "/people/person"
}
=====

however, when i explicitly add the connect clause to my query, i get a
different response than the latter one:

=====
{
  "create" : "unless_exists",
  "date_of_birth" : "1932-02-27",
  "name" : "Elizabeth Taylor",
  "spouse_s" : {
    "create" : "unless_connected",
    "spouse" : {
      "connect" : "insert",
      "name" : "Augusto Callejas",
      "type" : "/people/person"
    },
    "type" : "/people/marriage"
  },
  "type" : "/people/person"
}
-----
{
  "code" : "/api/status/ok",
  "q1" : {
    "code" : "/api/status/error",
    "messages" : [
      {
        "code" : "/api/status/error/mql/result",
        "info" : {
          "count" : 2,
          "guids" : [
            "#9202a8c04000641f8000000006d52534",
            "#9202a8c04000641f8000000006d52720"
          ]
        },
        "message" : "Unique query may have at most one result. Got 2",
        "path" : "",
        "query" : {
          "create" : "unless_exists",
          "date_of_birth" : "1932-02-27",
          "error_inside" : ".",
          "name" : "Elizabeth Taylor",
          "spouse_s" : {
            "create" : "unless_connected",
            "spouse" : {
              "connect" : "insert",
              "name" : "Augusto Callejas",
              "type" : "/people/person"
            },
            "type" : "/people/marriage"
          },
          "type" : "/people/person"
        }
      }
    ]
  },
  "status" : "200 OK"
}
=====

my question is what implicit connect directive is occurring in the first
write operation above?  if it is a "connect":"insert", then why does the
second write operation above fail?

thanks,
augusto. 




More information about the Developers mailing list