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 light object to SQL mapping support to generate queries based on attributes #3717

Closed

Conversation

remysaissy
Copy link
Contributor

@remysaissy remysaissy commented Jan 30, 2025

Fixes #3718

@remysaissy remysaissy force-pushed the add_light_orm_support branch from fbdf8d6 to 85d6931 Compare January 30, 2025 15:21
@abonander
Copy link
Collaborator

I don't really see why this needs to be in SQLx specifically. It seems like it could easily be developed and incubated as a separate crate, like the half-dozen or so other ORMs already built on SQLx.

Look at it this way: if you were planning on maintaining it long-term, you wouldn't be beholden to our release cycle and you could evolve independently. If you weren't, then you'd otherwise be dumping a nontrivial additional API surface on us that we'd likely have to maintain in perpetuity--an API design that I personally would probably not use.

Understand that we developed SQLx largely out of a frustration with ORMs. We make it clear in the README that SQLx is not an ORM for a reason. They hide the actual SQL being executed from you, making it much harder to debug issues or understand the performance implications of your code. They often do a lot of unnecessary extra work, like for example, selecting whole rows even when you only need one field (which the database could otherwise serve with an index-only scan). You end up having to jump through a lot of hoops to make any tweaks you might need. And knowledge of one ORM isn't really portable to any other language or framework.

The designed intent of SQLx is to empower people to just write SQL. We have a long ways to go in terms of developer experience, but any convenience layers we add should be in-line with that core ethos, like #875 (which I'd love to get back to when I get the chance).

I'm also concerned that the existence of this would end up confusing a lot of users. Many will likely expect it to integrate into the compile-time checks somehow; this is already an issue with #[derive(FromRow)]. However, you don't mention any plans to implement this kind of functionality.

That also strongly suggests that this doesn't really need to be in SQLx itself, as it doesn't seem to rely on any internal APIs--though if you do end up needing some, we could discuss exposing them.

@remysaissy
Copy link
Contributor Author

Hi,
I was merely proposing it out of frustration to find a lot of non maintained crates built to do this light mapping work but being no longer maintained. I find it pollutes a bit the crates.io actually.
So the most logical to me would have been to have it in sqlx directly for those looking for this feature.
But I understand perfectly your point, especially given the history of SQLx I didn’t have - thanks for the explaination - and it makes total sense.

I will close the draft, this can live as a different crate.

thanks!

@remysaissy remysaissy closed this Jan 31, 2025
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.

Light ORM support based on macros
2 participants