node-casbin / prisma-adapter

Prisma adapter for Casbin
Apache License 2.0
29 stars 16 forks source link

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

Open azmi-plavaga opened 7 months ago

azmi-plavaga commented 7 months ago

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());
casbin-bot commented 7 months ago

@nodece @Shivansh-yadav13