Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose ability to override PDO drivers from user code #1057

Closed
Alikont opened this issue Jun 10, 2022 · 1 comment
Closed

Expose ability to override PDO drivers from user code #1057

Alikont opened this issue Jun 10, 2022 · 1 comment
Assignees

Comments

@Alikont
Copy link

Alikont commented Jun 10, 2022

PDOEngine has private and internal mechanism to resolve drivers based on loaded assemblies, but assemblies and classes are hardcoded to predefined list of drivers.

I'd like to have an ability to add custom drivers to this list, or override existing drivers there to provide my own implementation.

Currently as a workaround we use this code on app startup:

var s_lazydrivers = typeof(PDOEngine).GetField("s_lazydrivers", BindingFlags.NonPublic | BindingFlags.Static);
var driver = new CustomPDOSqlServerDriver();
var drivers = new Dictionary<string, PDODriver>()
{
    [driver.Name] = driver,
};
s_lazydrivers.SetValue(null, drivers);

Ideally I'd like to have something like void PDOEngine.RegisterDriver(PDODriver driver)

@jakubmisek
Copy link
Member

thanks for the issue; you're right, it used to register the drivers dynamically, but for some reason, we hardcoded the list of drivers (probably because nobody was implementing their custom driver before).

We should implement the driver registration again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants