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

Implement zio-jdbc backend #57

Merged
merged 149 commits into from
Nov 7, 2023
Merged

Conversation

@guizmaii guizmaii marked this pull request as ready for review October 23, 2023 12:13
@guizmaii guizmaii marked this pull request as draft October 23, 2023 12:29
@oyvindberg
Copy link
Owner

Thanks @guizmaii - you're fast!

I noticed you found my link to DbLib on twitter. The task is basically to implement that. Here are some pointers:

  • You can likely start by implementing all the methods with ??? and then port methods one by one.

  • Start with customizing the signatures to the new library before you implement the methods

  • You'll notice that there is some duplicate logic in these files - I haven't invested into fully extracting the logic from the templating yet, so to say.

  • inlineImplicits is optional and can be done later

  • mock repositories could also be done later, but is likely easy

  • you can skip SelectByFieldValues and UpdateFieldValues if they cause problems. That functionality is provided by the DSL now.

  • the contents of missingInstances will be obvious while compiling the example adventureworks database, so just make it an empty list when starting out.

  • Once you have that you can setup the GenAdventureWorks script to also generate zio code to a typo-tester-zio project.

  • When that compiles you can port the tests from typo-tester-{doobie|anorm}/src/scala/adventureworks

@oyvindberg
Copy link
Owner

If you're bothered by the files in .bleep/generated-sources they are created as part of the compilation process by the sourcegen script (scripts.GenHardcodedFiles) in the bleep build. You can comment them out there if needed during development.

I track all generated files in git as a kind of snapshot tests. I also continuously commit them to git as I work and use git diff to preview the effect my changes have. It's a very, very powerful technique for working on code generation code.

GenHardcodedFiles is the fast one, so it runs automatically, and GeneratedAdventureWorks is the slow one which needs a database connection.

@oyvindberg oyvindberg marked this pull request as ready for review October 23, 2023 20:14
@guizmaii
Copy link
Contributor Author

guizmaii commented Oct 24, 2023

I track all generated files in git as a kind of snapshot tests. I also continuously commit them to git as I work and use git diff to preview the effect my changes have. It's a very, very powerful technique for working on code generation code.

Yup, we completely agree on this. I do the same thing 🙂

I'm not committing them for now to avoid having a huuuuuuuge PR

@guizmaii
Copy link
Contributor Author

There's a bug in zio-jdbc that makes the tests fail in Scala 2.12. See zio-archive/zio-jdbc#185

@guizmaii
Copy link
Contributor Author

guizmaii commented Oct 31, 2023

Test are now passing on all Scala versions 🎉

@oyvindberg
Copy link
Owner

Test are now passing on all Scala versions 🎉

We're quite close then! 🚀

I hope to be able to dig up some time tonight after Halloween celebrations :)

@oyvindberg
Copy link
Owner

now it compiles almost as fast as the other combinations

Screenshot 2023-11-01 at 07 44 39

@oyvindberg
Copy link
Owner

discovered zio-archive/zio-jdbc#188 while verifying. will push tests to this branch shortly

@oyvindberg
Copy link
Owner

we can move forward with that one test commented out by the way, it's strictly not our problem and it may be hard to solve well in zio-jdbc.

@oyvindberg
Copy link
Owner

oyvindberg commented Nov 2, 2023

todo:

  • update docs
  • move ParameterMetadata from DSL to generated code. The DSL is meant to be optional, so it can't stay there. will need a slight refactor so DbLib can produce extra sc.Files in this case.
  • published version of zio-jdbc

- lose explicit `ClassTag` in `arrayJdbcDecoder`. will add it everywhere if we determine that it makes a big difference
- try a somewhat new code style in DbLibZioJdbc. a bit less nesting and a bit more naming. try to line up `|` in code fragments at least.
- compress `arrayJdbcDecoder` for custom types
- add `ParameterMetadata.instance` to avoid generating some bytecode and slightly nicer looking generated code
@oyvindberg
Copy link
Owner

I'm ready to merge this now, just need a new release of zio-jdbc.

🚀

@guizmaii
Copy link
Contributor Author

guizmaii commented Nov 5, 2023

I'm ready to merge this now, just need a new release of zio-jdbc.

I asked for a release

@sideeffffect
Copy link

new version has been released https://github.com/zio/zio-jdbc/releases/tag/v0.1.1 🎉

@oyvindberg oyvindberg merged commit c3cee5b into oyvindberg:main Nov 7, 2023
6 checks passed
@guizmaii guizmaii deleted the zio-jdbc-backen branch November 8, 2023 14:13
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

Successfully merging this pull request may close these issues.

3 participants