Search code examples
wakanda

Wakanda 2.x cannot set certain tables' scope to publicOnServer


I am not able to set certain tables' scope to publicOnServer. In my model.js, I set the scope for the table. The change in scope can be seen when I view my remote model (4D Database) in Wakanda- the table's scope is updated after my change.

With some tables, when I set the scope and then do any kind of query from the clientside - to any table - the console on my browser fills with errors and the query fails. Effectively, setting certain tables' scope in model.js breaks query for even an unrelated table.

One difference I notice between the tables for which scope changes work and those where it doesn't are tables that have relational attributes. Setting the scope for these tables consistently breaks query functionality and setting scope for tables without relational attributes consistently works fine. Is this a bug?

Chrome console output: ERROR Error: Uncaught (in promise): Error: Needed Contractor dataClass is not present on catalog

Line in model.js: model.Contractor.properties.scope="publicOnServer";

Contractor is a table in the remote model and it has relational attributes.


Solution

  • I ran the solution and based on the model of your project. This is a standard behavior and the error is expected. Any data class that is set to "PublicOnServer" is considered "removed" or "hidden" from client-side. Relation attribute in other class referencing this class is considered error just like it is referencing a non-exist class. The error will not appear if the Books class is set to "PublicOnServer" since it is not related to any other class.

    If you click the first line in the error stack: wakanda-client.no-promise.js line: 1880. You will find the following code:

    //Check if we have all needed dataClasses on the catalog
    for (var _e = 0, _f = _this.seenDataClasses; _e < _f.length; _e++) {
        var dcName = _f[_e];
        if (!catalog[dcName]) {
           throw new Error('Needed ' + dcName + ' dataClass is not present on catalog');
        }
    }
    

    at line 1775 you will find a function neededDataClass() comparing array called seenDataClasses with data classes need.

    Wakada client framework in fact promptly checks all public data classes and examine whether they have relational attributes that are referencing a non-public data class. This will avoid future problems in subsequent queries.

    The error "Errors in the console disappear if solution is launched without restricting access to the Company table." is added by Wakanda client in the promise to stop you from querying Client table containing an invalid relation attribute. I recommend adding a catch() in your code to handle it:

    wakanda.getCatalog()
        .then((ds) => {
            this.ds = ds;
        }).catch(error=>{
            //handle the error
    }); 
    

    Previous Answer:

    In my understanding, when the related table of the table you are querying is set as "publicOnServer", the query will work as long as the related table is not referenced in the query string or in query results subsequently.

    Can you provide a reproducible example of your model and code containing query string?