8/11/2023 0 Comments Elixir ecto long textFor one of those systems, some code was actually making web requests from those same functions/procedures! I worked on several systems for which core business logic was in SQL functions/procedures. I have a lot of SQL experience – at some times, most of my programming was in SQL. The schema API is pretty small with the only real complexity in the relationship stuff, but even that is pretty standard as far as any SQL wrapper goes or you can throw those out and just stick a field :post_id, :id in the schema instead and handle it all yourself. I'm not sure if "In the majority of cases, mapping an abstraction down to a table requires looking at the mapping syntax time and again" is directed at Ecto specifically or not. You wont get the "type safe functions" that sqlc produces with that because, well, that's what changeset/query/schema are doing (without getting too deep into type discussions re: ex vs go).īut really Ecto is pretty thin but flexible, I think throwing it out for the n number of complex queries (where n is almost definitely a small fraction of the total number of queries you run unless you're in some specialised problem space) you need is maybe short sighted. Then you still have Ecto and your queries are most definitely "pure SQL" at that point. ![]() Hell, you could just forgo any Ecto.Query "helpers" and just use your SQL adapters query function. Yeah I am curious if the OP has actually hit the limit (?) of Ecto or just expecting to from experience.Īs you say, Ecto matches SQL pretty closely and you can pretty easily drop fragments down wherever you want for any "weird" stuff. I mean, Ecto schemas are just structs on steroids, which are maps on steroids, so… That’s one of the things o love about Elixir. On that note, I did a quick prototype mixing Ecto schemas with the ayesql library and it works awesome. What I’m targeting at, is replacing its query builder part with auto-generated functions out of raw SQL queries. I still believe it’s a great persistence and retrieval mechanism and it offers possibilities for validation and sanitatizing, etc. Update: I have to add a few clarification notes. Ideally, something that makes use of Ecto's changesets (for validation, etc). My quick research showed me these two options: ![]() In my Go projects, I am using sqlc, but I am yet to find a suitable alternative for Elixir. I've realized that for me, the option to simply laying out my thoughts in SQL and using a generator to turn those into functions is the better way to go. There are also cases when the query syntax would be insufficient for what I am trying to achieve, and then I'd have to drop to using raw SQL. In the majority of cases, mapping an abstraction down to a table requires looking at the mapping syntax time and again. Not because Ecto is bad, but because I've gotten used to reaching the limitations of ORMs and query DSLs in every tech stack I've worked with. I love Elixir and Phoenix, but I have long had difficulty getting up to speed with Ecto.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |