prisma-adapter icon indicating copy to clipboard operation
prisma-adapter copied to clipboard

Order of policies stored in DB after a.savePolicy is not same as source

Open azmi-plavaga opened this issue 2 years ago • 1 comments

Order of policies in DB after savePolicy is not same as in source file: examples/rbac_policy.csv

Sample test: https://github.com/node-casbin/prisma-adapter/blob/master/test/adapter.test.ts Code snippet: line 40-50

 try {
      // Because the DB is empty at first,
      // so we need to load the policy from the file adapter (.CSV) first.
      let e = await newEnforcer(
        'examples/rbac_model.conf',
        'examples/rbac_policy.csv'
      );

      // This is a trick to save the current policy to the DB.
      // We can't call e.savePolicy() because the adapter in the enforcer is still the file adapter.
      // The current policy means the policy in the Node-Casbin enforcer (aka in memory).
      await a.savePolicy(e.getModel());

azmi-plavaga avatar Jan 18 '24 17:01 azmi-plavaga

@nodece @Shivansh-yadav13

casbin-bot avatar Jan 18 '24 17:01 casbin-bot