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

feat: extract databases in Kotlin schema #762

Merged
merged 2 commits into from
Jan 12, 2024

Conversation

worstell
Copy link
Contributor

@worstell worstell commented Jan 12, 2024

Screenshot 2024-01-11 at 8 56 38 PM

@worstell worstell force-pushed the worstell/20240108-dbconn branch 3 times, most recently from 3f65e47 to 400e2db Compare January 12, 2024 05:10
Copy link
Collaborator

@alecthomas alecthomas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is awesome work Lizzy, thanks! Just a couple of minor comments.

backend/schema/database.go Outdated Show resolved Hide resolved
backend/schema/metadatadatabases.go Outdated Show resolved Hide resolved
backend/schema/metadatadatabases.go Outdated Show resolved Hide resolved
@@ -221,6 +230,71 @@ func call[Resp any](module, verb string, req obj, onResponse func(t testing.TB,
}
}

func setUpKotlinModuleDb(dir string) assertion {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should just be setupModuleDb as it's not Kotlin specific.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated - right now this scaffolds the kotlin DbTest.kt file, but we can always follow up with a change to write language-appropriate content once Go is ready

integration/integration_test.go Outdated Show resolved Hide resolved
data class DbRequest(val data: String?)
data class DbResponse(val message: String? = "ok")

val db = Database("testdb")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is awesome Lizzy.

}

fun persistRequest(req: DbRequest) {
db.conn {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, nice!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it turns out java.sql.Connection extends AutoCloseable, which handles resource management with the caveat that the close() logic is only properly utilized if you use this .use function

so now calling db.conn { ... } creates a new connection and executes the provided block in a .use function to make sure the resource is properly managed. also, not sure if this fixed the integration test but with a few other fixes it's working now!

comments = module.comments()
)
modules[currentModuleName]?.decls?.addAll(moduleData.decls) ?: run {
modules[currentModuleName] = moduleData
}
}

private fun extractDatabases(): Set<Decl> {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is so good!

@alecthomas
Copy link
Collaborator

I forgot to add: please add support to Go for this. We want to keep the two runtimes at feature parity.

@worstell
Copy link
Contributor Author

worstell commented Jan 12, 2024

I forgot to add: please add support to Go for this. We want to keep the two runtimes at feature parity.

will do - was thinking i should prioritize the remaining work here first though, unless you think otherwise

for now i can make tickets to add Go support for all the new Kotlin features (this + secrets/KMS APIs)?

@alecthomas
Copy link
Collaborator

alecthomas commented Jan 12, 2024

I'd prefer to keep both at parity in main at all times. We've let them get out of sync before and it ends up being a massive PITA bringing them up to date.

If you want to prioritise the other work though, defer merging this PR until it supports Go. I'm happy to pair with you on this in the morning if you like.

@alecthomas
Copy link
Collaborator

Actually disregard that, let's get this in. I'll get the Go side working while you work on the other Kotlin stuff.

@worstell worstell force-pushed the worstell/20240111-parse-database-schema branch from b033e8e to 36b57c7 Compare January 12, 2024 17:43
@worstell worstell changed the base branch from worstell/20240108-dbconn to main January 12, 2024 17:48
@worstell worstell force-pushed the worstell/20240111-parse-database-schema branch from 36b57c7 to 9a345a7 Compare January 12, 2024 17:52
@worstell worstell force-pushed the worstell/20240111-parse-database-schema branch from 9a345a7 to 241f0fe Compare January 12, 2024 17:53
@worstell worstell merged commit ed61da7 into main Jan 12, 2024
11 checks passed
@worstell worstell deleted the worstell/20240111-parse-database-schema branch January 12, 2024 18:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants