<turbo-stream action="append" target="posts_list"><template>    <div class="postbit" id="318483" data-post-id="318483">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="sasajuric" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/sasajuric/120/991_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  sasajuric
                  </h3>
		          </div>
						
			          <div class="user-title">
									<span>Author of Elixir In Action</span>
			          </div>
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="tfwright" data-post="10" data-topic="61733">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/tfwright/48/20299_2.png" class="avatar"> tfwright:</div>
<blockquote>
<p>I’m not sure this is the strongest argument for <code>transact</code> since a fair comparison with <code>Multi.run</code> seems like it should be against <code>with</code> plus one or more error clauses which imo is some of the most confusing Elixir logic to follow.</p>
</blockquote>
</aside>
<p>Sorry, I don’t follow what you’re saying here.</p>
<aside class="quote no-group" data-username="tfwright" data-post="10" data-topic="61733">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/tfwright/48/20299_2.png" class="avatar"> tfwright:</div>
<blockquote>
<p>This seems to be precisely where you want Multi–complex flow control with multiple distinct user error cases.</p>
</blockquote>
</aside>
<p>The stock Elixir tool for chaining multiple operations and return on first error is <code>with</code>. I prefer to use that instead of some custom library mechanism.</p>
<aside class="quote no-group" data-username="tfwright" data-post="10" data-topic="61733">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/tfwright/48/20299_2.png" class="avatar"> tfwright:</div>
<blockquote>
<p>I would note there is no need to return a failed log</p>
</blockquote>
</aside>
<p>Yes, and I’m not returning it from vanilla Elixir. Multi OTOH requires you to return something in each step. It could be <code>nil</code>, I guess, but IME that’s confusing, because we end up with named things which are always <code>nil</code>.</p>
<aside class="quote no-group" data-username="tfwright" data-post="10" data-topic="61733">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/tfwright/48/20299_2.png" class="avatar"> tfwright:</div>
<blockquote>
<p>request it be changed more like</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">Repo.transaction(fn -&gt;
  user_changeset
  |&gt; Repo.insert()
  |&gt; case do
    {:ok, user}  -&gt; 
      {:ok, user}
       Repo.insert!(%LogData{user_id: user.id, ...})
    error -&gt; 
      error
end)
</code></pre>
</blockquote>
</aside>
<p>If there’s an error inserting the user, this code will commit and return <code>{:ok, {:error, changeset}}</code>. This is how <code>transaction</code> + fun work, and it’s specifically what <code>transact</code> changes (by wrapping <code>transaction</code>).</p>
<p>Furthermore, the <code>case</code> version is noisy even in such a simple example, and it becomes progressively worse when you want to chain multiple operations, exiting early on some (but not all) of them. IIRC, this is precisely why <code>with</code> was introduced to the language.</p>
<aside class="quote no-group" data-username="tfwright" data-post="10" data-topic="61733">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/tfwright/48/20299_2.png" class="avatar"> tfwright:</div>
<blockquote>
<p>I would still include it in every project because I would prefer that to rewriting my own transactional error handling with <code>with</code>.</p>
</blockquote>
</aside>
<p>Sorry, no idea what this means. What is being rewritten?</p>
<aside class="quote no-group" data-username="LostKobrakai" data-post="11" data-topic="61733">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/lostkobrakai/48/3072_2.png" class="avatar"> LostKobrakai:</div>
<blockquote>
<p>People see multiple steps – insert user then log – and reach for <code>Ecto.Multi</code>.</p>
</blockquote>
</aside>
<p>I agree. Given its API, multi pushes folks to uncritically return non-actionable errors, in the places where they should raise. I’ve seen way too much of such code.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="318483" data-batch-url="/posts/batch_likers">
                        3
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/seeking-thoughts-on-advantages-of-the-repo-transact-pattern-vs-disadvantages-i-ve-read-about-ecto-multi/61733/12">Post #11</a>
	                </div>
	            </div>
              <div id="likers-container-318483" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="318483"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #11"></div>
  </section>
</div>
    <div class="postbit" id="318485" data-post-id="318485">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="wojtekmach" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/wojtekmach/120/999_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  wojtekmach
                  </h3>
		          </div>
						
			          <div class="user-title">
									<span>Hex Core Team</span>
			          </div>
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Another thing is, as was mentioned previously, sometimes it is nice that steps are named but what tends to happen is the call and the error handling is separated:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">multi
|&gt; Ecto.Multi.insert(:step1, ...)
|&gt; Ecto.Multi.run(:step2, ...)
|&gt; Ecto.Repo.transaction(...)
|&gt; case do
  {:ok, ..., ..., ...} -&gt;
    {:ok, ...}

  {:error, :step1, changeset, ...} -&gt;
    {:error, ...}

  {:error, :step2, changeset, ...} -&gt;
    {:error, ...}
end
</code></pre>
<p>or worse yet, it is the <em>caller</em> that has to do such <code>case</code>.</p>
<p>This is akin to the usage of with/1 that I’m definitely not a fan of either:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">with {:step1, ...} &lt;- {:step1, ...},
     {:step2, ...} &lt;- ... do
else
  {:step1, {:error, _}} -&gt;
    {:error, ...}

  {:step1, {:error, _}} -&gt;
    {:error, ...}
end
</code></pre>
<p>In my experience it’s much better to have a simpler <code>with</code> even if the logic of each steps is<br>
somewhat tricky we can safely tuck it away in a private function:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">with {:ok, ...} &lt;- private_function_1(),
     {:ok, ...} &lt;- private_function_2() do
  {:ok, ...}
end
</code></pre>
<p>and it fits very well with Repo.transact.</p>
<p>Btw, a friendly reminder that from the Ecto README (emphasis mine)</p>
<blockquote>
<p>Ecto is a <em>toolkit</em> for data mapping and language integrated query for Elixir.</p>
</blockquote>
<p>So it’s totally OK to build custom things on top. <img src="https://forum.elixirforum.com/images/emoji/apple/slight_smile.png?v=15" title=":slight_smile:" class="emoji" alt=":slight_smile:" loading="lazy" width="20" height="20"></p>
<p>I might be totally off here but I believe multi and with/2 came out around the same time actually and multi at the time really did feel like a breath of fresh air and only later people realized that there might be better ways to solve these types of problems and that’s totally OK. Personally speaking, in hindsight multi should perhaps be less prominent in favour of exactly Repo.transact-like semantics but that ship has mostly sailed in the sense removing multi feels too big of a change. I think the Ecto team would consider adding another function with transact semantics hence my search of a good name for it.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="318485" data-batch-url="/posts/batch_likers">
                        12
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/seeking-thoughts-on-advantages-of-the-repo-transact-pattern-vs-disadvantages-i-ve-read-about-ecto-multi/61733/13">Post #12</a>
	                </div>
	            </div>
              <div id="likers-container-318485" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="318485"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #12"></div>
  </section>
</div>
    <div class="postbit" id="318487" data-post-id="318487">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="sasajuric" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/sasajuric/120/991_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  sasajuric
                  </h3>
		          </div>
						
			          <div class="user-title">
									<span>Author of Elixir In Action</span>
			          </div>
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote group-Hex-Core-Team" data-username="wojtekmach" data-post="13" data-topic="61733">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/wojtekmach/48/999_2.png" class="avatar"> wojtekmach:</div>
<blockquote>
<p>but what tends to happen is the call and the error handling is separated</p>
</blockquote>
</aside>
<p>Great point! And those post-transaction <code>case</code>s are IMO just terrible.</p>
<aside class="quote group-Hex-Core-Team" data-username="wojtekmach" data-post="13" data-topic="61733">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/wojtekmach/48/999_2.png" class="avatar"> wojtekmach:</div>
<blockquote>
<p>This is akin to the usage of with/1 that I’m definitely not a fan of either</p>
</blockquote>
</aside>
<p>Also big +1! Each step should be responsible for returning its own success/failure. That way <code>else</code> can most often be avoided.</p>
<aside class="quote group-Hex-Core-Team" data-username="wojtekmach" data-post="13" data-topic="61733">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/wojtekmach/48/999_2.png" class="avatar"> wojtekmach:</div>
<blockquote>
<p>removing multi feels too big of a change</p>
</blockquote>
</aside>
<p>It wouldn’t be unprecedented. Both Ecto and Phoenix have a history of moving some things to other libraries. But I’m not pushing for this. However, it would be great if we had stock <code>transact</code> semantics, and if the official docs emphasized that approach.</p>
<aside class="quote group-Hex-Core-Team" data-username="wojtekmach" data-post="13" data-topic="61733">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/wojtekmach/48/999_2.png" class="avatar"> wojtekmach:</div>
<blockquote>
<p>I think the Ecto team would consider adding another function with transact semantics hence my search of a good name for it.</p>
</blockquote>
</aside>
<p><code>Repo.atomic</code>?</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="318487" data-batch-url="/posts/batch_likers">
                        5
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/seeking-thoughts-on-advantages-of-the-repo-transact-pattern-vs-disadvantages-i-ve-read-about-ecto-multi/61733/14">Post #13</a>
	                </div>
	            </div>
              <div id="likers-container-318487" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="318487"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #13"></div>
  </section>
</div>
    <div class="postbit" id="318488" data-post-id="318488">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="tfwright" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/tfwright/120/20299_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  tfwright
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group quote-modified" data-username="sasajuric" data-post="12" data-topic="61733">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/sasajuric/48/991_2.png" class="avatar"> sasajuric:</div>
<blockquote>
<aside class="quote no-group" data-username="tfwright" data-post="10" data-topic="61733">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/tfwright/48/20299_2.png" class="avatar"> tfwright:</div>
<blockquote>
<p>I’m not sure this is the strongest argument for <code>transact</code> since a fair comparison with <code>Multi.run</code> seems like it should be against <code>with</code> plus one or more error clauses which imo is some of the most confusing Elixir logic to follow.</p>
</blockquote>
</aside>
<p>Sorry, I don’t follow what you’re saying here.</p>
</blockquote>
</aside>
<p>It’s quite late here so possibly I am sleep deprived, but I am only reformulating a point that others have made, including you I believe, that the use of Multi is not always “needless noise.”</p>
<aside class="quote no-group" data-username="tfwright" data-post="10" data-topic="61733">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/tfwright/48/20299_2.png" class="avatar"> tfwright:</div>
<blockquote>
<p>I would still include it in every project because I would prefer that to rewriting my own transactional error handling with <code>with</code>.</p>
</blockquote>
</aside>
<blockquote>
<p>Sorry, no idea what this means. What is being rewritten?</p>
</blockquote>
<p>Multi. <code>transact</code> is an alternate solution to the same problem, there could be others, but my point is that personally I am not dissatisfied with the semantics of Multi.</p>
<aside class="quote no-group" data-username="sasajuric" data-post="12" data-topic="61733">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/sasajuric/48/991_2.png" class="avatar"> sasajuric:</div>
<blockquote>
<p>I agree. Given its API, multi pushes folks to uncritically return non-actionable errors, in the places where they should raise. I’ve seen way too much of such code.</p>
</blockquote>
</aside>
<p>I am happy to cede this point, in fact I have also had the experience of needing to correct juniors’ use of Multi in various cases. I am not sure I yet see how an alternate solution like <code>transact</code> would prevent or discourage useless return values, but that would certainly be a mark in its favor.</p>
<blockquote>
<p>I think the Ecto team would consider adding another function with transact semantics hence my search of a good name for it.</p>
</blockquote>
<p>I would happily sign any petition to separate Multi out into its own library. I would consider the addition of a new competing utility unfortunate.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="318488" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/seeking-thoughts-on-advantages-of-the-repo-transact-pattern-vs-disadvantages-i-ve-read-about-ecto-multi/61733/15">Post #14</a>
	                </div>
	            </div>
              <div id="likers-container-318488" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="318488"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #14"></div>
  </section>
</div>
    <div class="postbit" id="318489" data-post-id="318489">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="belaustegui" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/belaustegui/120/36580_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  belaustegui
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="sasajuric" data-post="14" data-topic="61733">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/sasajuric/48/991_2.png" class="avatar"> sasajuric:</div>
<blockquote>
<p>However, it would be great if we had stock <code>transact</code> semantics, and if the official docs emphasized that approach.</p>
</blockquote>
</aside>
<p>I totally agree with this. In my dayjob we have almost completely switched to <code>transact</code> instead of <code>Ecto.Multi</code> for new code. <code>Repo.transaction</code> is never used due to the weird semantics that have been already mentioned upthread.</p>
<p>Is there any place in which we can make an official discussion to potentially include <code>Repo.transact</code> directly in <code>Ecto</code>? Opening a PR in the Ecto repository would be easy but I believe it would’t be a good idea without a previous discussion with the maintainers.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="318489" data-batch-url="/posts/batch_likers">
                        3
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/seeking-thoughts-on-advantages-of-the-repo-transact-pattern-vs-disadvantages-i-ve-read-about-ecto-multi/61733/16">Post #15</a>
	                </div>
	            </div>
              <div id="likers-container-318489" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="318489"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #15"></div>
  </section>
</div>
    <div class="postbit" id="318490" data-post-id="318490">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="sasajuric" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/sasajuric/120/991_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  sasajuric
                  </h3>
		          </div>
						
			          <div class="user-title">
									<span>Author of Elixir In Action</span>
			          </div>
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="belaustegui" data-post="16" data-topic="61733">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/belaustegui/48/36580_2.png" class="avatar"> belaustegui:</div>
<blockquote>
<p>Is there any place in which we can make an official discussion to potentially include <code>Repo.transact</code> directly in <code>Ecto</code>?</p>
</blockquote>
</aside>
<p>I think that new features are discussed on the mailing list <a href="https://groups.google.com/g/elixir-ecto" rel="noopener nofollow ugc">https://groups.google.com/g/elixir-ecto</a>.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="318490" data-batch-url="/posts/batch_likers">
                        2
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/seeking-thoughts-on-advantages-of-the-repo-transact-pattern-vs-disadvantages-i-ve-read-about-ecto-multi/61733/17">Post #16</a>
	                </div>
	            </div>
              <div id="likers-container-318490" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="318490"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #16"></div>
  </section>
</div>
    <div class="postbit" id="318492" data-post-id="318492">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="sasajuric" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/sasajuric/120/991_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  sasajuric
                  </h3>
		          </div>
						
			          <div class="user-title">
									<span>Author of Elixir In Action</span>
			          </div>
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="tfwright" data-post="15" data-topic="61733">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/tfwright/48/20299_2.png" class="avatar"> tfwright:</div>
<blockquote>
<p>a point that others have made, including you I believe, that the use of Multi is not always “needless noise.”</p>
</blockquote>
</aside>
<p>Yes, I agree. But “not always” doesn’t exclude “very often” <img src="https://forum.elixirforum.com/images/emoji/apple/slight_smile.png?v=15" title=":slight_smile:" class="emoji" alt=":slight_smile:" loading="lazy" width="20" height="20"> And from the code I’ve seen in practice, folks tend to use multi way too much.</p>
<aside class="quote no-group" data-username="tfwright" data-post="15" data-topic="61733">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/tfwright/48/20299_2.png" class="avatar"> tfwright:</div>
<blockquote>
<p><code>transact</code> is an alternate solution to the same problem</p>
</blockquote>
</aside>
<p>This discussion focuses a lot on multi, but <code>transact</code> is arguably an alternate solution to <code>transaction</code>. As it just so happens, once you have it in place, it becomes much more compelling than multi in many situations.</p>
<aside class="quote no-group" data-username="tfwright" data-post="15" data-topic="61733">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/tfwright/48/20299_2.png" class="avatar"> tfwright:</div>
<blockquote>
<p>I am not sure I yet see how an alternate solution like <code>transact</code> would prevent or discourage useless return values</p>
</blockquote>
</aside>
<p>Admittedly not much. But I think it stands less in the way, because you’re using plain <code>Repo</code>, so it’s equally convenient to use <code>insert</code> or <code>insert!</code>. In contrast, with multi, it’s <code>Multi.insert</code> vs <code>Multi.run</code> + <code>Repo.insert!</code>, and from there I think most folks would choose the former <img src="https://forum.elixirforum.com/images/emoji/apple/slight_smile.png?v=15" title=":slight_smile:" class="emoji" alt=":slight_smile:" loading="lazy" width="20" height="20"></p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="318492" data-batch-url="/posts/batch_likers">
                        1
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/seeking-thoughts-on-advantages-of-the-repo-transact-pattern-vs-disadvantages-i-ve-read-about-ecto-multi/61733/18">Post #17</a>
	                </div>
	            </div>
              <div id="likers-container-318492" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="318492"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #17"></div>
  </section>
</div>
    <div class="postbit" id="318493" data-post-id="318493">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="tfwright" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/tfwright/120/20299_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  tfwright
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="sasajuric" data-post="18" data-topic="61733">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/sasajuric/48/991_2.png" class="avatar"> sasajuric:</div>
<blockquote>
<p>This discussion focuses a lot on multi, but <code>transact</code> is arguably an alternate solution to <code>transaction</code>.</p>
</blockquote>
</aside>
<p>I was just considering adding this in an edit! I think it cuts to the heart of the issue perfectly and I can 100% agree that it improves a lot on the semantics there.</p>
<p>Unfortunately I suspect modifying the semantics of <code>transaction</code> is an even tougher prospect then divorcing Multi from Ecto?</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="318493" data-batch-url="/posts/batch_likers">
                        3
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/seeking-thoughts-on-advantages-of-the-repo-transact-pattern-vs-disadvantages-i-ve-read-about-ecto-multi/61733/19">Post #18</a>
	                </div>
	            </div>
              <div id="likers-container-318493" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="318493"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #18"></div>
  </section>
</div>
    <div class="postbit" id="318495" data-post-id="318495">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="wojtekmach" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/wojtekmach/120/999_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  wojtekmach
                  </h3>
		          </div>
						
			          <div class="user-title">
									<span>Hex Core Team</span>
			          </div>
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Yes exactly, we cannot make Repo.transaction(fun) work in a different way without breaking existing code hence we need a new function name.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="318495" data-batch-url="/posts/batch_likers">
                        2
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/seeking-thoughts-on-advantages-of-the-repo-transact-pattern-vs-disadvantages-i-ve-read-about-ecto-multi/61733/20">Post #19</a>
	                </div>
	            </div>
              <div id="likers-container-318495" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="318495"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #19"></div>
  </section>
</div>
    <div class="postbit" id="318556" data-post-id="318556">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="wojtekmach" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/wojtekmach/120/999_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  wojtekmach
                  </h3>
		          </div>
						
			          <div class="user-title">
									<span>Hex Core Team</span>
			          </div>
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="sasajuric" data-post="14" data-topic="61733">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/sasajuric/48/991_2.png" class="avatar"> sasajuric:</div>
<blockquote>
<p><code>Repo.atomic</code>?</p>
</blockquote>
</aside>
<p>I think it needs to be something with transaction given that’s what people will most likely look for.</p>
<p>To me the contenders are:</p>
<ol>
<li>transact</li>
<li>transaction_with</li>
<li>with_transaction</li>
</ol> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="318556" data-batch-url="/posts/batch_likers">
                        2
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/seeking-thoughts-on-advantages-of-the-repo-transact-pattern-vs-disadvantages-i-ve-read-about-ecto-multi/61733/21">Post #20</a>
	                </div>
	            </div>
              <div id="likers-container-318556" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="318556"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #20"></div>
  </section>
</div>
</template></turbo-stream><turbo-stream action="replace" target="load-more-container"><template><div id="load-more-container" class="load-more-container">
    <a class="load-more-button" data-turbo-stream="true" href="/topics/61733/load_more?page=3">Load more posts (36 remaining)</a>
</div></template></turbo-stream>