Contributing to Ecto

I’ll preface this by saying no I didn’t actually have a PR merged, yet I still had a great experience nonetheless. I was working on a many_to_many relationship for work, one where if you had an empty list of items, then you added some, then tried to delete some, it would throw a :raise error. At first I was a bit mystified as to the nature of this error, then after some digging I discovered that many_to_many relationships differ slightly to the one_to_many and the one_to_one kind. The obvious difference is the linking table between the two tables. This causes a few issues, because when you go to delete an item from the list, Ecto expects there to be the same number of items in that list. Furthermore, by default it will just raise an error because it doesn’t know what you want to do. Turns out you have to set the on_replace: flag to to :delete. To come up with this solution I not only googled for awhile, I also asked a coworker. Before I asked a fellow programmer, I found the changeset documentation which was just about the only thing that came up that was useful for my issue. I had a read and discovered the 5 or so flag options you could set. It wasn’t clear what many_to_many could use nor what :delete would do, other than to be really careful with it, which makes sense when your using one_to_one, or one_to_many relationships. However, with many_to_many, there’s a table in between them, in fact the :delete option causes Ecto to delete from the joining table, which is amazing, another thing I love about Ecto. Yet I discovered this from trial and error and some advice from a coworker who said “I think it’s delete, but I’m not sure for many_to_many”. Once I had discovered this I figured that the documentation could use some additions to it. So after the same coworker convinced me to contribute, I forked the project and made some documentation additions. Now doc additions, really aren’t special, you won't win any awards for best programmer from contributing these, yet its the first step to contributing. You can’t expect to jump right into writing important functions for the core Elixir language without first starting with something small, such as documentation. Now I just picked something that had caused me some grief and I thought could be improved for future developers. So I did it, I wrote the documentation, submitted a PR, it got looked at. I won’t lie when Jose Valim himself, commented on it, I was pretty happy, even if it was to say it’s already in the docs. That's my story of the first time attempting to contribute to an open source project. I had a problem, I fixed it, I found a lack of documentation for it, so I decided to contribute. I wrote the explanation, turns out it was in another section of the Ecto documentation, but that’s okay, because the community was nice enough to look at what I submitted, review it and provide feedback. Even though I submitted a PR for something that was already in there, it hasn’t gotten me down. In fact I’m pretty excited to contribute again when I find something worth contributing. So thank you Ecto/Elixir community, for being nice enough to provide feedback for a young dev. Contributing is very scary, even more so when you actually do submit some code I can imagine, all these extremely experienced developers, the creator of the language, all looking at your code. It’s quite nerve racking, yet it’s quite a thrill and you learn to back what you put out there. When I did submit my work, one of the bigger contributors wrote a comment asking why this is necessary, at first I was thinking well why is it? Thinking did I make a mistake in submitting this? But it gave me a chance to defend myself, allowing me to explain my thought process to another developer. Which is an extremely important skill in this field, because if you can’t explain your code, your ideas, your thought process to another person, then how in the world will you work in a team?

Practice this skill of explaining, teaching others and go contribute to open source, even if it’s some docs, I know I need to do it more.

Previous
Previous

Daily exercise

Next
Next

Elixir connecting to databases part: 1