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

Postgresql driver? #4

Open
bobbypriam opened this issue Oct 4, 2017 · 2 comments
Open

Postgresql driver? #4

bobbypriam opened this issue Oct 4, 2017 · 2 comments

Comments

@bobbypriam
Copy link

Hi, thank you for building this amazing library!

Is a Postgresql driver in the roadmap of this project? If so, what would be necessary to realize it? Would love to try using this with Postgres if possible.

@andrenth
Copy link
Owner

andrenth commented Oct 4, 2017

Hi

It's not on the roadmap currently, mainly because I don't use Postgres, so I don't have enough knowledge about it. I would of course accept a patch with a Postgres driver :)

If you want to try that, the easiest way would be looking at the MySQL driver. There I define a time type and extend Field.t and Field.Null.t to include it. There's some amount of boilerplate but the code is simple and you can see what you need to do to add Postgres' types. Then there's similar code to support time literals and parameters.

Then Expr.t is extended to support MySQL-specific functions. There's a lot of code because there are many functions, so it's a big variant and there are lots of smart constructors.

I believe you should be able to can figure it out, as searching for "time" or "Time" would point you to all types and modules you'll need to modify.

The seal functions are more complex because of the need to recursively call the base library Expr builder and provide a way for it to call the driver back. However, this code can be just copied over (you'll see it's exactly the same on the Sqlite driver).

Cheers!

@bobbypriam
Copy link
Author

Neat! Really appreciate the general pointers. I might visit it in the future but if anyone wanted to take this on I'll be very happy :)

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

No branches or pull requests

2 participants