Git Product home page Git Product logo

dbal-adapter's Issues

Error loading policy during instantiation

I get this error when trying to instantiate the Enforcer class using this adapter:

TypeError:
Argument 1 passed to CasbinAdapter\DBAL\Adapter::fetch() must be an instance of Doctrine\DBAL\Result, instance of Doctrine\DBAL\Driver\PDOStatement given, called in /<redacted>/vendor/casbin/dbal-adapter/src/Adapter.php on line 153

  at /<redacted>/vendor/casbin/dbal-adapter/src/Adapter.php:495
  at CasbinAdapter\DBAL\Adapter->fetch(object(PDOStatement))
     (/<redacted>/vendor/casbin/dbal-adapter/src/Adapter.php:153)
  at CasbinAdapter\DBAL\Adapter->loadPolicy(object(Model))
     (/<redacted>/vendor/casbin/casbin/src/CoreEnforcer.php:363)
  at Casbin\CoreEnforcer->loadPolicy()
     (/<redacted>/vendor/casbin/casbin/src/CoreEnforcer.php:223)
  at Casbin\CoreEnforcer->initWithModelAndAdapter(object(Model), object(Adapter))
     (/<redacted>/vendor/casbin/casbin/src/CoreEnforcer.php:198)
  at Casbin\CoreEnforcer->initWithAdapter('/<redacted>/permission_model.conf', object(Adapter))
     (/<redacted>/vendor/casbin/casbin/src/CoreEnforcer.php:150)
  at Casbin\CoreEnforcer->__construct('/<redacted>/resources/permission_model.conf', object(Adapter))
     (/<redacted>/src/Utilities/Permission.php:52)

From the composer.json file in this library, Doctrine 2.9 and 3.0 are supported. I am using Doctrine 2.9.3.

Digging through the source code, it looks like the execute method from DBAL Query Builder (called on line 151 in Adapter.php) returns a ResultStatement rather than the expected Result object.

Passing an array of parameters instead of a Connection object in the constructor produces the same result. Am I doing something wrong?

Doesn't work in Doctrine 4.0 and broken automated checks

Calls to removed methods

#7 claimed to add support for Doctrine 4.0, but there are still multiple calls to removed QueryBuilder::execute() method (along with some calls to other removed methods) across the codebase.

Broken automated checks

Cloning the repository and running the test suite results in 11/11 errors which means that the automated checks for the PR incorrectly passed. I took a glance at the workflow file and I suspect this might be due to Composer package caching, which skipped the Install dependencies step and probably used an old version of Doctrine.

Proposed solution

Fixing the source code itself isn't complicated and I might take a shot at it if I have time at some point attempted a fix (see #13), but I think fixing the tests should be the first priority, since that would've immediately detected the broken code. I also find it a bit odd that apparently no tests were run locally at any point.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.