How to retrieve from calc field


#1

Hi all,

I have:

    type_A {
    my_field: [type_B] calc "unique(...)" schema suffix 'ASSLST'
    }

And I want to retrieve all type_A in which my_field contains type_B.id == my_id

I tried:

type_A .fetch({filter: Filter.intersects('my_field.id',['my_id ']),include : 'my_field'})

but return me this error:

    "Unable to execute sql SELECT T.ID, T.VERSION, T.TYPE_IDENT
    FROM C3_2_ASSET T
    WHERE T.TENANT_TAG_ID=:v1 AND ((T.TYPE_IDENT LIKE '...') AND 
       EXISTS(SELECT 1 FROM C3_2_ASSET_ASSLST M
       WHERE M.TENANT_TAG_ID=:v1 AND M.RID=T.ID AND ((M.VALUE IN (:v2)))))
    ORDER BY T.ID
    LIMIT 2002
    ERROR: relation "c3_2_my_field_asslst" does not exist
      Position: 155"

How I can solve this?

Thanks


#2

You shouldn’t need a schema suffix since the values aren’t being stored. Can you try removing it?


#3

You cannot filter on a calc field.
The reason is that there is no column in the table for that field, it is only populated ”at runtime”, so you cannot build a SQL statement mentioning that field.
If you really need to do that this way, make it a stored calc field (with a schema suffix).


#4

I take it back, Camille is more correct in this case.