You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi again, I'm using rulesToAST to convert an Ability to an AST condition and then I translate the condition in a typeorm query with ucast/sql.
I found that the Interpreter builds a wrong query when the ability has a rule with no conditions (e.g. can("read", "User")), indeed the ability is translated into r { operator: 'and', value: [] } AST condition that the interpreter translates into .where('()', []).
asyncfunctionmain(){constconn=awaitcreateConnection();constability=defineAbility((can)=>{can('read','User');});constastCondition=rulesToAST(ability,'read','User');console.log(astCondition)// r { operator: 'and', value: [] }letquery=interpret(astCondition,User.createQueryBuilder());awaitquery.getMany()// SELECT "User"."id" AS "User_id", "User"."firstName" AS "User_firstName", "User"."lastName" AS "User_lastName", "User"."age" AS "User_age" FROM "users" "User" WHERE ()conn.close()}
Is this the correct usage of rulesToAST and ucast/sql?
The text was updated successfully, but these errors were encountered:
thanks for the issue. I think that I need to add more validation to mongodb parser. { and: [] } is probably a mistake in another place and should not be just ignored
Hi again, I'm using
rulesToAST
to convert an Ability to an AST condition and then I translate the condition in a typeorm query with ucast/sql.I found that the Interpreter builds a wrong query when the ability has a rule with no conditions (e.g.
can("read", "User")
), indeed the ability is translated intor { operator: 'and', value: [] }
AST condition that the interpreter translates into.where('()', [])
.Is this the correct usage of rulesToAST and ucast/sql?
The text was updated successfully, but these errors were encountered: