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

Add: Support for Postgres #288

Open
swhyte-rt opened this issue Aug 28, 2020 · 10 comments
Open

Add: Support for Postgres #288

swhyte-rt opened this issue Aug 28, 2020 · 10 comments
Labels
enhancement New feature or request not planned This will not be worked on
Milestone

Comments

@swhyte-rt
Copy link

Watchman Version: current version and forward

What were you trying to do?

Run watchman with Postgres as Database

I am just finishing off the implementation of this and can create a pull request.

@swhyte-rt swhyte-rt changed the title Add support for Postgres ADD: Support for Postgres Aug 28, 2020
@swhyte-rt swhyte-rt changed the title ADD: Support for Postgres Add: Support for Postgres Aug 28, 2020
@adamdecaf adamdecaf added the enhancement New feature or request label Aug 28, 2020
@adamdecaf
Copy link
Member

Yes please @swhyte-rt! Was it just adding the config options? We tried to keep the SQL compatible across the major databases.

@swhyte-rt
Copy link
Author

It was adding config options, but also supporting differences in queries. For example Postgres did not like

insert into customer_status (customer_id, user_id, note, status, created_at) values (?, ?, ?, ?, ?);

so I had to change to

insert into customer_status (customer_id, user_id, note, status, created_at) values ($1, $2, $3, $4, $5);

I will test this one more time, but it was throwing error when preparing the statement.

@swhyte-rt
Copy link
Author

Here is the documentation explaining that most DB will support ? syntax but Postgres supports $1 and Oracle supports :var1

http://go-database-sql.org/prepared.html

@adamdecaf
Copy link
Member

Ah that's too bad. Did you have to branch at each query off a config or flag?

@swhyte-rt
Copy link
Author

swhyte-rt commented Aug 28, 2020

I have repository interfaces, and have implemented a genericSQL<name of repo>Repository (SQLite, MySQL) and a postgres<name of repo>Repository. It is in these implementation repos that is where syntax difference is.

@swhyte-rt
Copy link
Author

@adamdecaf I can let you look at the fork of the work if you want to look at it before doing a pull request.

@adamdecaf
Copy link
Member

Sure! I think it's this branch?

master...swhyte-rt:master

@swhyte-rt
Copy link
Author

Yep that is it

@swhyte-rt
Copy link
Author

swhyte-rt commented Aug 31, 2020

@adamdecaf I may have been over thinking this by breaking out separate repositories for generic db and Postgres. I was thinking if you were to ever support nosql databases. I can change this to a single repository with constants for the various queries and check the db type when initializing the query. That would be cleaner.

@adamdecaf
Copy link
Member

We have no plans to support NoSQL for storage in Watchman. One repository for all three databases sounds fine so long as we find/replace and always prepare the query.

I was checking with other projects and they've written an implementation for MySQL and Postgres.

@adamdecaf adamdecaf added this to the v0.16.0 milestone Oct 20, 2020
@adamdecaf adamdecaf added the not planned This will not be worked on label Sep 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request not planned This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants