lpil/yesql

Feature request

tschnibo opened this issue · 5 comments

Hey, as already "commited" and messed around in the other issue. I wanted to ask if you would support customizable drivers.

Usecase:
I use your library with a patched Mssqlex for SAP-Hana and would like to use it again with Mssqlex for a Mssql db.

So maybe I could just rename the two Mssqlex Modules and add them as custom drivers.

As soon as my principle is tested with Mssqlex I'll create a separate PR again.

Thank you! And again, sorry for the mess!

lpil commented

Hello!

Support for other databases sounds great to me.

Would it be support for specific drivers (like today it supports postgrex and ecto)? Or something more flexible?

Adding specific drivers could be pretty straightforward, this is the conditional compilation of driver support used at the moment:

https://github.com/lpil/yesql/blob/master/lib/yesql.ex#L106-L116

Hey, thank you for your interest! As indicated, I am currently just using mssqlex with yesql. But I use mssqlex in a patched and in a non patched version I don't know what other drivers would be interesting... and what requirements they would have. So my task is quite simple, I could also just have done the minimal patch.

I am not yet sure how much patching is "normal" and what should be pushed to the corresponding packages.

For yesql I made some progress on a more customizable conditional compilation:
Without proper documentation and no tests. But if you would be willing to have a look:

Loading the driver options from config (or fallback):
https://github.com/tschnibo/yesql/blob/15abc86b3afa7487ee026300c4d55123fbc76e77/lib/yesql/custom_drivers.ex
Adapted conditional compilation:
https://github.com/tschnibo/yesql/blob/15abc86b3afa7487ee026300c4d55123fbc76e77/lib/yesql.ex#L107
Config
https://github.com/tschnibo/yesql/blob/15abc86b3afa7487ee026300c4d55123fbc76e77/config/config.exs

So code formating, tests, documentation... really not quite there yet... but its a start maybe and I would be willing to put some more effort in.
What do you think?

lpil commented

I like the idea and driver but I think I would prefer to keep to the pattern that is in the codebase at the moment. It is a lot simpler, and give us a clear point to perform any value conversions that are required if the drivers have different return formats.

There are not many drivers out there so it would not be much work to support them this way vs having a dynamic driver system like this one.

Ok, thank you! I sort of entered "dependency hell" with these SQL Drivers... ;)
The patched Yesql is the least worrying problem for me...

Best regards, tschnibo

lpil commented

Cheers!