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 SQLDelight support #1524

Open
JGulbronson opened this issue Jun 6, 2020 · 9 comments
Open

Add SQLDelight support #1524

JGulbronson opened this issue Jun 6, 2020 · 9 comments

Comments

@JGulbronson
Copy link
Collaborator

@AlecStrong and I have been adding MySQL support to SQLDelight over the past week, and I think it's just about at the point there's enough functionality to look at getting it in to Misk.

The way I'm picturing this would be to pull the JDBC stuff out in to it's own module, (misk-jdbc?). This would make support config like misk-hibernate does today, and provide a DataSourceService which SQLDelight could use for connections.

Wanted to open this issue to see if
a) there's interest in getting this merged. @swankjesse feels like you're the person to ask
b) if there is interest, talk next steps for implementing, so there's no surprises in a future PR

@AlecKazakova
Copy link
Collaborator

High level it'd be good to know if there's more blockers to getting this in misk. We've worked on compatibility with faire's setup and it looks good to go. Schemas can be built from flyway-compatible migration files instead of needing to redeclare anything which I think was the biggest blocker.

The only dependency we need from misk is a DataSource, which we can get from hikari and the existing jdbc setup. It's tied to hibernate but I don't really know if thats an issue.

@JGulbronson
Copy link
Collaborator Author

Actually there is one potential issue, I think Misk currently doesn't support non .SQL extensions for migrations. And I think it might have some issues but having them in resources, but I could be wrong on that.

@AlecKazakova
Copy link
Collaborator

that should still be fine, the sqldelight task can output .sql files for misk

@jjestrel
Copy link
Contributor

jjestrel commented Jul 9, 2020

We've talked about decoupling the jdbc and hibernate stuff internally before to support sqlc and sqldelight. I think people are interested but no one has done the work yet. +1 on separating misk-jdbc and misk-hibernate and I think that's a good first step

@zcross
Copy link
Contributor

zcross commented Aug 6, 2020

The way I'm picturing this would be to pull the JDBC stuff out in to it's own module, (misk-jdbc?). This would make support config like misk-hibernate does today, and provide a DataSourceService which SQLDelight could use for connections.

+1 to extracting JDBC related things

One other point: the Transacter is a really nice abstraction. Unfortunately, if we're talking about code organization, the interface itself includes Hibernate types like Session. Whether we can actually implement that interface or need to write a second one inspired by it, it would be great to preserve some of its ideas, most importantly: demarcating DB transactions with blocks and hiding transaction begin/commit/rollback.

@AlecKazakova
Copy link
Collaborator

I think the JDBC module should be an implementation detail of actual consumer modules. Really people should only be using something higher level like misk-hibernate which would still have Transacter, or if it's SQLDelight there's a similar Transaction interface for blocking together code in a transaction/providing commit & rollback APIs.

@tirsen
Copy link
Collaborator

tirsen commented Aug 6, 2020

I started working on extracting the pure JDBC parts from Hibernate to separate it into a DataSourceModule (which sets up the Hikari pool and exposes a DataSource) and HibernateModule (which requires a DataSource and exposes a Transacter and a SessionFactory). It's pretty hard because things are quite entangled but I got about half way through. It's been on our agenda for a little while but I don't have time to work on this now. I'd imagine that's the first part of adding non-Hibernate persistence frameworks to misk.

@tirsen
Copy link
Collaborator

tirsen commented Aug 6, 2020

@JGulbronson I'd be happy to review and merge any such PRs though. But start off splitting up the HibernateModule since I know almost nothing about SQLDelight except that it's obviously super awesome. :-)

@AlecKazakova
Copy link
Collaborator

DataSourceModule which exposes a DataSource would be peeeerfect for SQLDelight, DataSource is the only JDBC dependency needed to initialize everything

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

6 participants