informatics-isi-edu / ermrestjs

ERMrest client library in JavaScript
Apache License 2.0
4 stars 3 forks source link

use scalar projection for all-outbounds if we can #931

Closed RFSH closed 2 years ago

RFSH commented 2 years ago

When an all-outbound path's value is needed for a page (either by being visible, or being used in the wait_for list of another column) we're modifying the main entity request to include the data for this path.

The current implementation doesn't differentiate between scalar and entity modes and will ask for the whole row instead of just the column that is being projected. For example, let's assume we're looking at table main where it has a foreign key relationship to table o1 through the following column mapping:

{
  "names": [["schema", "main_fk1"]],
  "foreign_key_columns": [{
    "column_name": "fk",
    "table_name": "main",
    "schema_name": "schema"
  }],
  "referenced_columns": [{
    "column_name": "RID",
    "table_name": "o1",
    "schema_name": "schema"
  }]
}

If we have a visible-column like the following

{ "source": [{"outbound": ["schema", "main_fk1"]}, "RID"], "entity": true}

It will result in the following request:

M:=s:main/F1:=left(fk)=(o1:RID)/RID;M:=array_d(M:*),F1:=array(F1:*)@sort(RID)

And with this when we're populating data for that visible-column we have the whole row data which allows us to,

But in case of scalar all-outbound, we might not need to fetch all the row values and we could potentially just fetch the column's value. To ensure that is the case, I added a canUseScalarProjection API to PseudoColumn which returns true if,

With this we can ensure that just fetching the scalar column is enough.

RFSH commented 2 years ago

The build in Github Actions started failing for reasons that are not directly related to this PR. The issue was related to jsdoc dependency. It seems like the latest 3.6.9 was causing these issues and fixing the version to 3.6.7 solved the issue.