wiringbits / scala-webapp-template

A pragmatic skeleton to build web applications in Scala/Scala.js, including user registration, login, admin portal, and, deployments
https://template-demo.wiringbits.net/
MIT License
172 stars 40 forks source link

SQL DSL using Typo #424

Closed KapStorm closed 11 months ago

KapStorm commented 1 year ago

PoC using the SQL DSL generator github.com/oyvindberg/typo/

github-actions[bot] commented 1 year ago

Preview ready at https://sql-typo-poc.sssppa.wiringbits.dev

Powered by https://codepreview.io community edition.

github-actions[bot] commented 1 year ago

Preview ready at https://sql-typo-poc.sssppa.wiringbits.dev

Powered by https://codepreview.io community edition.

oyvindberg commented 12 months ago

Hey I just came across this - very cool :)

I see two things I'm wondering how we should progress with:

custom types

I see you added CustomUUID and CustomInstant in here, probably to work around for the TypoUUID classes. is there something in particular wrong with those classes which means you cant use them?

scala.js

I see you're duplicating anorm types into js. what's the goal here? any thoughts re: my thoughts in https://oyvindberg.github.io/typo/docs/other-features/scala-js-ready/ ?

AlexITC commented 12 months ago

I see you added CustomUUID and CustomInstant in here, probably to work around for the TypoUUID classes. is there something in particular wrong with those classes which means you cant use them?

It is very likely that our changes were pushed before Typo release covering these custom types.

I see you're duplicating anorm types into js. what's the goal here?

From what I remember, we have a few wrapper objects cross-compiled to sjs, we need to define the implicit ToStatement[_] value for those, otherwise, Typo code won't compile with our wrappers.

@oyvindberg Given that you are around, are we expected to commit the generated by Typo? i was thinking to leave it at the target/ directory like scalapb does but that would mean that we'd require another step before compiling the app.

github-actions[bot] commented 12 months ago

Preview ready at https://sql-typo-poc.sssppa.wiringbits.dev

Powered by https://codepreview.io community edition.

github-actions[bot] commented 12 months ago

Preview ready at https://sql-typo-poc.sssppa.wiringbits.dev

Powered by https://codepreview.io community edition.

github-actions[bot] commented 12 months ago

Preview ready at https://sql-typo-poc.sssppa.wiringbits.dev

Powered by https://codepreview.io community edition.

github-actions[bot] commented 12 months ago

Preview ready at https://sql-typo-poc.sssppa.wiringbits.dev

Powered by https://codepreview.io community edition.

oyvindberg commented 12 months ago

I see you added CustomUUID and CustomInstant in here, probably to work around for the TypoUUID classes. is there something in particular wrong with those classes which means you cant use them?

It is very likely that our changes were pushed before Typo release covering these custom types.

Ok. Let me know if this causes friction. if so we can discuss a path forward

@oyvindberg Given that you are around, are we expected to commit the generated by Typo? i was thinking to leave it at the target/ directory like scalapb does but that would mean that we'd require another step before compiling the app.

That is left completely open for you to decide. For me personally it makes most sense to check them in so you can track them over time, and speedup the build at the same time.

github-actions[bot] commented 12 months ago

Preview ready at https://sql-typo-poc.sssppa.wiringbits.dev

Powered by https://codepreview.io community edition.

github-actions[bot] commented 12 months ago

Preview ready at https://sql-typo-poc.sssppa.wiringbits.dev

Powered by https://codepreview.io community edition.

github-actions[bot] commented 12 months ago

Preview ready at https://sql-typo-poc.sssppa.wiringbits.dev

Powered by https://codepreview.io community edition.

github-actions[bot] commented 12 months ago

Preview ready at https://sql-typo-poc.sssppa.wiringbits.dev

Powered by https://codepreview.io community edition.

github-actions[bot] commented 11 months ago

Preview ready at https://sql-typo-poc.sssppa.wiringbits.dev

Powered by https://codepreview.io community edition.

AlexITC commented 11 months ago

I see you added CustomUUID and CustomInstant in here, probably to work around for the TypoUUID classes. is there something in particular wrong with those classes which means you cant use them?

@oyvindberg I got more accurate comments now for this, we are avoiding built-in types because the custom instant/uuid types are exposed to our frontend and we'd prefer to not expose typo values there.

AlexITC commented 11 months ago

@oyvindberg we ended up deciding not to integrate Typo right now, the main reason being is, given our project structure, Typo doesn't play so smoothly with our scalajs integration, we have typed-models that are cross-compiled to scalajs which we also use from anorm.

I'm still very interested to try again in a few months.

Thanks!

oyvindberg commented 11 months ago

Oh ok, @AlexITC - no worries.

The solution is likely to not expose the database layer to frontend. Create domain types, which often bears some similarity to db objects but are not the same, and enjoy a compiler-checked map from Row objects to domain objects 👍

AlexITC commented 11 months ago

The solution is likely to not expose the database layer to frontend

Its the other way around, we have some core models which are exposed to the db layer, Typo generates some of these but we would like to use the ones we already have, for example: https://github.com/wiringbits/scala-webapp-template/blob/master/lib/common/shared/src/main/scala/net/wiringbits/common/models/Email.scala