- this.method = query.object;
-
- // xxx beware that this.key needs to contain a key that all records will have
- // in general query_all will return well populated records, but query
- // returns records with only the fields displayed on startup.
- this.key = (this.options.id_key);
- if (! this.key) {
- // if not specified by caller, decide from metadata
- var keys = manifold.metadata.get_key(this.method);
- this.key = (keys && keys.length == 1) ? keys[0] : null;
- }
- if (! this.key) messages.warning("querytable.init could not kind valid key");
-
- messages.debug("querytable: key="+this.key);
+ this.object = query.object;
+
+ //// we need 2 different keys
+ // * canonical_key is the primary key as derived from metadata (typically: urn)
+ // and is used to communicate about a given record with the other plugins
+ // * init_key is a key that both kinds of records
+ // (i.e. records returned by both queries) must have (typically: hrn or hostname)
+ // in general query_all will return well populated records, but query
+ // returns records with only the fields displayed on startup
+ var keys = manifold.metadata.get_key(this.object);
+ this.canonical_key = (keys && keys.length == 1) ? keys[0] : undefined;
+ //
+ this.init_key = this.options.init_key;
+ // have init_key default to canonical_key
+ this.init_key = this.init_key || this.canonical_key;
+ // sanity check
+ if ( ! this.init_key ) messages.warning ("QueryTable : cannot find init_key");
+ if ( ! this.canonical_key ) messages.warning ("QueryTable : cannot find canonical_key");
+ if (debug) messages.debug("querytable: canonical_key="+this.canonical_key+" init_key="+this.init_key);