<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Kazuyoshi Ueno on Medium]]></title>
        <description><![CDATA[Stories by Kazuyoshi Ueno on Medium]]></description>
        <link>https://medium.com/@kazuyoshiueno?source=rss-cfe1dfb7f973------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*XfocHRt5rcYJLEun4jDdOA.jpeg</url>
            <title>Stories by Kazuyoshi Ueno on Medium</title>
            <link>https://medium.com/@kazuyoshiueno?source=rss-cfe1dfb7f973------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 18:45:22 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@kazuyoshiueno/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Enable Japanese to use in the Docker Container of MySQL.]]></title>
            <link>https://medium.com/@kazuyoshiueno/enable-japanese-to-use-in-the-docker-container-of-mysql-b0bc4cc23fa5?source=rss-cfe1dfb7f973------2</link>
            <guid isPermaLink="false">https://medium.com/p/b0bc4cc23fa5</guid>
            <dc:creator><![CDATA[Kazuyoshi Ueno]]></dc:creator>
            <pubDate>Fri, 10 Apr 2020 09:42:51 GMT</pubDate>
            <atom:updated>2020-04-10T09:42:51.086Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*PwStrhjmQURtXiyxNRoNpQ.jpeg" /></figure><p>If you do not need Japanese or some other multi-byte languages, this article will not be readable.I will show you the way so that we can use Japanese language in your Docker Container of MySQL. You will be able to paste and type Japanese characters in the terminal with the mysql client.</p><p>If <strong>Dockerfile</strong> has just like a “From mysql:5.7”, you can not type or past any Japanese.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/52bbcbbc608167b29082d8dd19ff4b62/href">https://medium.com/media/52bbcbbc608167b29082d8dd19ff4b62/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b0bc4cc23fa5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Sometimes Updating some records by Repo.insert_all]]></title>
            <link>https://medium.com/codes-for-elixir-phoenix/sometimes-updating-some-records-by-repo-insert-all-91ef06f17707?source=rss-cfe1dfb7f973------2</link>
            <guid isPermaLink="false">https://medium.com/p/91ef06f17707</guid>
            <dc:creator><![CDATA[Kazuyoshi Ueno]]></dc:creator>
            <pubDate>Mon, 09 Mar 2020 10:38:12 GMT</pubDate>
            <atom:updated>2020-03-09T10:38:12.375Z</atom:updated>
            <content:encoded><![CDATA[<h3>Sometimes Updating some records by Repo.insert_all with on_conflict: :replace_all will not work properly on MySQL5.7 | Elixir /Phoenix</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ige205Rf8Ywz_ALkN7q7hw.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@artmatters?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Artur Matosyan</a> on <a href="https://unsplash.com/?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>When you want to upsert a record, you may want to use Repo.insert with <strong><em>on_conflict::replace_all</em></strong>. Me, too. However, I really <strong>DO NOT RECOMMEND</strong> this, If you are using <strong>MySQL 5.7</strong>.</p><p>The reason is <a href="https://bugs.mysql.com/bug.php?id=79243">here</a>. MySQL5.7 has a bug for “<strong>insert on duplicate key</strong>”. Repo.insert_all with on_conflict::replace_all will use “insert on duplicate key”, so sometimes we will see the command won’t work which means an error comes.</p><p>I did not see any errors for that as long as I work with my local PC, but on my Production with the Aurora Instance.</p><p>So, I rewrite all of my codes for on_conflict::replace_all. Now, I just update records by <strong>Repo.update</strong>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=91ef06f17707" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codes-for-elixir-phoenix/sometimes-updating-some-records-by-repo-insert-all-91ef06f17707">Sometimes Updating some records by Repo.insert_all</a> was originally published in <a href="https://medium.com/codes-for-elixir-phoenix">Codes for Elixir / Phoenix. Investigation of the best practice.</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Bulk update a record with Ecto | Elixir /Phoenix]]></title>
            <link>https://medium.com/codes-for-elixir-phoenix/bulk-update-a-record-with-ecto-elixir-phoenix-799c29ff52f6?source=rss-cfe1dfb7f973------2</link>
            <guid isPermaLink="false">https://medium.com/p/799c29ff52f6</guid>
            <category><![CDATA[elixir]]></category>
            <category><![CDATA[phoenix-framework]]></category>
            <category><![CDATA[ecto]]></category>
            <category><![CDATA[bulk-insert]]></category>
            <dc:creator><![CDATA[Kazuyoshi Ueno]]></dc:creator>
            <pubDate>Wed, 27 Mar 2019 17:36:29 GMT</pubDate>
            <atom:updated>2019-03-27T17:52:22.106Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/829/1*A0EusmMfDKC_JlbjZgY51Q.png" /><figcaption>tag cloud</figcaption></figure><p>Do you update a record <strong>by overriding values</strong>? Yes, you can. However, sometime we just can’t do it, because sometimes we have to <strong>delete</strong> some data at the same time. Can you imagine it? Please imagine that the Blog system like <strong>WordPress</strong>. We can add some <strong>categories or tags</strong> to a post we have written down, can’t you? When we write an article as your blog with two tags which are like “Mazda” and “vehicle”. Oh, BTW, the database schema like the following.</p><pre><strong>Blog Database schema</strong></pre><pre>posts table<br>==========================================<br>| id | title | body |....</pre><pre>post_tags table<br>==========================================<br>| id | post_id | tag_id | ...</pre><pre>tags table ( master )<br>==========================================<br>| id | tag_name |</pre><pre>- post has many posts_tags</pre><p>So, we added “Mazda” and “vehicle” as the tag to our post. <br>The records are like the following.</p><pre><strong>The post has &quot;Mazda&quot; and &quot;vehicle&quot; as the tag.</strong></pre><pre>posts table<br>==========================================<br>| 1 | MyFirstPost | ..... |</pre><pre>post_tags<br>==========================================<br>| 1 | 1 | 1 | <br>| 1 | 1 | 2 |</pre><pre>tags table ( master )<br>==========================================<br>| 1 | Mazda |<br>| 2 | vehicle |<br>| 3 | RED |<br>| 4 | Blue |<br>| 5 | Green |<br>...</pre><p>O.K, a couple of days passed, we want to update tags of the post.<br>And think that we want to make our tags to be “<strong>Blue</strong>” and “<strong>Mazda</strong>”.</p><p>So, we need to <strong>delete</strong> the “vehicle” tag from the post_tag table.</p><p>How will you update the records in the post_tags table? As you’ve already known that we<strong> just cannot update</strong> an old value “Mazda” and insert new tag “Blue”. If we do this, the “vehicle” tag still be in the table. Which means that we have to <strong>think</strong> to delete it in this case.</p><blockquote>Yes, we do have the case we do <strong>not need to think</strong> about <strong>deleting</strong> for updating records. It depends on the system design and UI.</blockquote><p>However, the system design often changes anytime, unfortunately. And besides, I personally do not like to think anything too much. Therefore, I would like to <strong><em>introduce my way of updating</em></strong>.<br>Actually, I learned this way from my colleague, though.</p><p>My way has <strong>3 parts</strong> which are “<strong>Delete</strong> data”, “<strong>Insert</strong> new data” and “<strong>Update</strong> exists data”. Let me write the steps a few details for the above case.</p><blockquote>1) Look for the data ( records ) to delete.<br>2) Look for the data ( records ) to insert.<br>3) Look for the data ( records ) to update.<br>4) Delete data if exists.<br>5) Insert data if exists.<br>6) Update data if exists.</blockquote><p>The final code.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9aa5c1296515352dec2a2ff2a4d8aeba/href">https://medium.com/media/9aa5c1296515352dec2a2ff2a4d8aeba/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=799c29ff52f6" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codes-for-elixir-phoenix/bulk-update-a-record-with-ecto-elixir-phoenix-799c29ff52f6">Bulk update a record with Ecto | Elixir /Phoenix</a> was originally published in <a href="https://medium.com/codes-for-elixir-phoenix">Codes for Elixir / Phoenix. Investigation of the best practice.</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Ecto. Select data by computed column | Elixir / Phoenix]]></title>
            <link>https://medium.com/codes-for-elixir-phoenix/ecto-select-data-by-computed-column-elixir-phoenix-cd71150f1653?source=rss-cfe1dfb7f973------2</link>
            <guid isPermaLink="false">https://medium.com/p/cd71150f1653</guid>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[pagination]]></category>
            <category><![CDATA[phoenix-framework]]></category>
            <category><![CDATA[elixir]]></category>
            <category><![CDATA[ecto]]></category>
            <dc:creator><![CDATA[Kazuyoshi Ueno]]></dc:creator>
            <pubDate>Tue, 26 Mar 2019 12:46:09 GMT</pubDate>
            <atom:updated>2019-03-27T08:35:16.941Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OplBdgcHATAFTLLHGbOzyQ.jpeg" /></figure><p>This post is about <strong>a basic technique for SQL</strong>. The reason I want to write this article is that I am not a good friend with SQL and I hope a person who is not familiar with will be able to have the technique.</p><p>Let’s see… We select data from our database tables with some conditions many times, it may be to display the data and create a list for UI.<br>Especially for UI, we often use “<strong>paginate</strong>” function.</p><p>As you know, the “paginate” has some properties which are “entities”, “page_number”, “page_size”, “total_pages” and “total_entries”.</p><p>Basically, those numbers are computed automatically so we do not need to care for it. However, when we use “paginate” ( maybe ), we have to know the knowledge that will be <strong>the technique.</strong></p><p>Let me take a sample database for this post. We have a “<strong>countries</strong>” table, a “<strong>islands</strong>” table and “<strong>islands_peoples</strong>” table. And the schema is the following.</p><pre><strong>Sample DB Schema</strong></pre><pre>countries table<br>-------------------------------------------------------<br>id | name(string) | islands_id(int) | population(int) |<br></pre><pre>islands table<br>----------------------------------------------------<br>id | name(string) | area(string) | population(int) |<br></pre><pre>islands_peoples table<br>------------------------------------------------<br>id | islands_id(int) | male(int) | female(int) |</pre><pre><br>languages table<br>------------------------------------------------<br>id | islands_peoples_id(int) | language(string) | </pre><pre>- countries <strong>has many</strong> islands.<br>- islands_peoples <strong>has one</strong> islands.<br>- islands_peoples <strong>has many</strong> languages.</pre><h3><strong>Select with Non-Computed Columns</strong></h3><p>Just in case, I will show you a sample code for comparison with this purpose. Here is a sample code which selects countries records by islands&#39; population is less than 100.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3ceb2d6c9fc7a0099df1a094f7cd220d/href">https://medium.com/media/3ceb2d6c9fc7a0099df1a094f7cd220d/href</a></iframe><p>It is quite a simple code. The point of this code and design is that we can select data by a ( or some ) condition which is “<strong>Column</strong>” <strong>itsself</strong>. It is the “population” of islands table in this above example.</p><blockquote>P.S. We need to join the islands table, not preload that otherwise Repo.paginate will deliver the wrong properties. ( eg. total_entries )</blockquote><h3>|&gt; Select with computed columns</h3><p>Let’s consider the theme of this post. Imagine that we want to select the countries name and related islands info. with people whose language is English. For the countries info. and islands info., we just can get it by joining both tables.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ad20ca53338bb66a3486ac3f1711b23b/href">https://medium.com/media/ad20ca53338bb66a3486ac3f1711b23b/href</a></iframe><p>However, country and island <strong>Do Not know</strong> the language info. Just islands_peoples know it.</p><p>So, the first thing we have to do is to know which islands_people use “English”. And besides, this job will be worked as the filter for <strong><em>select_computed_data/2</em></strong> function so I will add this as function and apply to <strong><em>select_computed_data/2</em></strong>. Let’s take a look at the final code.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2656db358430cc847dcab80f1d6a8317/href">https://medium.com/media/2656db358430cc847dcab80f1d6a8317/href</a></iframe><p>The <strong>point</strong> is that we want to <strong>use columns in Countries or Islands table</strong> because we select data ( information ) of those tables have. However, let me tell you once again, These two tables do not know which language people use. So, we have done in <strong><em>_filtered_by_language/2</em></strong> is to collect islands_id <strong>which is related to a column in Islands table</strong> ( Islands.id ).</p><p>Finally, we can apply the “<strong>where</strong>” condition to the SQL so that we can get what we want! I personally think this technique(?) is very useful or will be your good knowledge!</p><p>Thank you.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cd71150f1653" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codes-for-elixir-phoenix/ecto-select-data-by-computed-column-elixir-phoenix-cd71150f1653">Ecto. Select data by computed column | Elixir / Phoenix</a> was originally published in <a href="https://medium.com/codes-for-elixir-phoenix">Codes for Elixir / Phoenix. Investigation of the best practice.</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[When I use “cond” | Elixir / Phoenix]]></title>
            <link>https://medium.com/codes-for-elixir-phoenix/when-i-use-cond-elixir-phoenix-fd424b35d1aa?source=rss-cfe1dfb7f973------2</link>
            <guid isPermaLink="false">https://medium.com/p/fd424b35d1aa</guid>
            <category><![CDATA[api]]></category>
            <category><![CDATA[with]]></category>
            <category><![CDATA[cond]]></category>
            <category><![CDATA[elixir]]></category>
            <category><![CDATA[phoenix-framework]]></category>
            <dc:creator><![CDATA[Kazuyoshi Ueno]]></dc:creator>
            <pubDate>Mon, 18 Mar 2019 16:09:14 GMT</pubDate>
            <atom:updated>2019-03-26T12:51:07.923Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XHR82ZdEDv_XCxGilnGK8g.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/photos/R1ql7fk3I1Y?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Miti</a> on <a href="https://unsplash.com/search/photos/some-cases?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>I’ve told that I like the “with” statement in <a href="https://medium.com/codes-for-elixir-phoenix/i-like-the-with-statement-elixir-phoenix-5ff27e0a01c3">my first post</a> because the “with” statement can check all conditions which are requirements to do what we want to at once. For instance, the API which needs 3 request parameters, so we have to validate them if each of them is nil or not.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/73ca7bd94de331d2b16bea222b673ccb/href">https://medium.com/media/73ca7bd94de331d2b16bea222b673ccb/href</a></iframe><p>However, what if I have to response a specific error code with the specific message for each lack of request parameters?</p><p>I will use the “cond” statement for this.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b99c504f1cc9b051c32ec08afb0ce3db/href">https://medium.com/media/b99c504f1cc9b051c32ec08afb0ce3db/href</a></iframe><p>But what if there were 100 request parameters for an API? Will you write 100 conditions? And besides, we can say that this way can response <strong>just one error response</strong>.</p><p>So I will tell you <strong>another way </strong>in the <strong>next post</strong>, even though we have to check all each parameter.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fd424b35d1aa" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codes-for-elixir-phoenix/when-i-use-cond-elixir-phoenix-fd424b35d1aa">When I use “cond” | Elixir / Phoenix</a> was originally published in <a href="https://medium.com/codes-for-elixir-phoenix">Codes for Elixir / Phoenix. Investigation of the best practice.</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Naming Rule of public and private function | Elixir / Phoenix]]></title>
            <link>https://medium.com/codes-for-elixir-phoenix/naming-rule-of-public-and-private-function-elixir-phoenix-494abee4d354?source=rss-cfe1dfb7f973------2</link>
            <guid isPermaLink="false">https://medium.com/p/494abee4d354</guid>
            <category><![CDATA[naming]]></category>
            <category><![CDATA[elixir]]></category>
            <category><![CDATA[phoenix-framework]]></category>
            <dc:creator><![CDATA[Kazuyoshi Ueno]]></dc:creator>
            <pubDate>Tue, 12 Mar 2019 15:56:00 GMT</pubDate>
            <atom:updated>2019-03-26T12:53:51.143Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QKvpZyeokgtQwygAuDv35Q.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/photos/71CjSSB83Wo?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Pavan Trikutam</a> on <a href="https://unsplash.com/search/photos/public-and-private?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>I think the function name is based on snake case, many programmers seem to use it but just the snake case? I have another naming rule to distinguish the public function from the private.</p><p>For the public function, I just use low case alphabet and the snake case. And on the other side, I start with “_” for the private function.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4964f077b31e1654050489e05d0f808a/href">https://medium.com/media/4964f077b31e1654050489e05d0f808a/href</a></iframe><p>Let’s imagine that If you ( I ) wanted to use the private function from other modules named ModuleB.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e55e0fcc3bc2b6d467622cdd096d7891/href">https://medium.com/media/e55e0fcc3bc2b6d467622cdd096d7891/href</a></iframe><blockquote>ModuleA._private_function()</blockquote><p>The “_” we can see is just after “ModuleA”. I really feel creepy. <br>Let’s change that name along with my naming rule.</p><p>The “<strong>_private_function</strong>” actually must be changed to “<strong>private_function</strong>” by removing <strong>the first “_”,</strong> the function name itself is still strange one, though.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e4359f5624667903f329fe3a384b5238/href">https://medium.com/media/e4359f5624667903f329fe3a384b5238/href</a></iframe><p>Hey, This really makes me a happy feeling! Not only the appearance in codes in terms of readable but also you won’t <strong>forget</strong> to change “<strong>defp</strong>” into “<strong>def</strong>”.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=494abee4d354" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codes-for-elixir-phoenix/naming-rule-of-public-and-private-function-elixir-phoenix-494abee4d354">Naming Rule of public and private function | Elixir / Phoenix</a> was originally published in <a href="https://medium.com/codes-for-elixir-phoenix">Codes for Elixir / Phoenix. Investigation of the best practice.</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What is “where(query, false)”? | Elixir / Phoenix]]></title>
            <link>https://medium.com/codes-for-elixir-phoenix/what-is-where-query-false-elixir-phoenix-a7b4540d4a45?source=rss-cfe1dfb7f973------2</link>
            <guid isPermaLink="false">https://medium.com/p/a7b4540d4a45</guid>
            <category><![CDATA[phoenix-framework]]></category>
            <category><![CDATA[where]]></category>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[ecto]]></category>
            <category><![CDATA[elixir]]></category>
            <dc:creator><![CDATA[Kazuyoshi Ueno]]></dc:creator>
            <pubDate>Sat, 09 Mar 2019 17:59:09 GMT</pubDate>
            <atom:updated>2019-03-26T12:53:33.596Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HDIqq5EKGAvqqRXjsDi9Qg.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/photos/HnUHOBuJ7s4?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Ambitious Creative Co. — Rick Barrett</a> on <a href="https://unsplash.com/search/photos/empty?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>Are you a good friend for <strong>SQL</strong>? Please say YES! I will tell you something about <strong>Ecto</strong>, but the essence of this post is SQL. I guess you love the “<strong>where</strong>” statement to select data with some conditions. On another word, when using “where” means you want to get data by filtered all results.</p><p>However, I also do not know why it does exist, the “where” can take “<strong>false</strong>” as an argument. When it comes, you <strong>can</strong> <strong>not</strong> <strong>get</strong> any results from the database.</p><p>Hey!, I want to select some data from the database, <strong>That’s why </strong>I will do ask the Ecto to fetch data with some conditions I will give! As a result, if there is nothing, I have no choice and I agree.</p><p>However, Mr. “<strong>Where</strong>: <strong>false</strong>” just give me <strong>nothing</strong> whatever other conditions exist.</p><blockquote>When do we need it or use false as an argument of where?</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_gDa6u_1yCZpx-z6wLvw7w.jpeg" /></figure><p>Yes, I’ve finally happened to meet up.<br>Let’s (please) imagine that we can see 100 checkboxes, radio buttons and some textboxes as a search UI. Each UI will make <strong>one</strong> “where” condition for a query to select data like the following.</p><pre>query<br>|&gt; where([a, b, c, d, e, f, g, h],e.name == ^criteria)<br>|&gt; where([a, b, c, d, e, f, g, h],a.flag == true)<br>|&gt; where([a, b, c, d, e, f, g, h],b.flag == ^criteria)<br>|&gt; where .....<br>|&gt; where .....<br>|&gt; where .....<br>|&gt; where .....</pre><p>No problem. That query will work properly for me.<br>However, each parameter for each “where” is an option so that we do not need to check all buttons and input for all textboxes. This is the design of the system.<br>So, I usually make a function for each “where” statement like the following.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d1cb5f15bef2c26bbb9891b51b651f55/href">https://medium.com/media/d1cb5f15bef2c26bbb9891b51b651f55/href</a></iframe><p>“where(query, <strong>true</strong>)” just returns query which is passed to the function _filtered_by_name.</p><p>So far, so good?</p><p>Then I have finally met one condition that could make all other conditions dead if that specific condition won’t exist <strong>just in my case.</strong> This is like “<strong>Balus</strong>” from “Laputa: Castle in the Sky”.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7c191ea26049afed481ac07be114bd36/href">https://medium.com/media/7c191ea26049afed481ac07be114bd36/href</a></iframe><p>In this above my design case, if param (could be one of the request parameters) does not have the parameter named “flag_b”, the results <strong>will be</strong> <strong>empty</strong>. This is my system design.</p><p>If that is caused by “flag_b” request parameter, which may be from one UI, We can check if it exists or not like <strong>the guard section</strong> using “<strong>with</strong>” statement or something like that.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a7b4540d4a45" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codes-for-elixir-phoenix/what-is-where-query-false-elixir-phoenix-a7b4540d4a45">What is “where(query, false)”? | Elixir / Phoenix</a> was originally published in <a href="https://medium.com/codes-for-elixir-phoenix">Codes for Elixir / Phoenix. Investigation of the best practice.</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Do you want to see “SQL” you created by Ecto?]]></title>
            <link>https://medium.com/codes-for-elixir-phoenix/do-you-want-to-see-sql-you-created-by-ecto-b785019b2098?source=rss-cfe1dfb7f973------2</link>
            <guid isPermaLink="false">https://medium.com/p/b785019b2098</guid>
            <category><![CDATA[elixir]]></category>
            <category><![CDATA[ecto]]></category>
            <category><![CDATA[phoenix-framework]]></category>
            <dc:creator><![CDATA[Kazuyoshi Ueno]]></dc:creator>
            <pubDate>Sat, 09 Mar 2019 14:10:33 GMT</pubDate>
            <atom:updated>2019-03-26T12:53:18.591Z</atom:updated>
            <content:encoded><![CDATA[<h3>Do you want to see “SQL” you created by Ecto? | Elixir / Phoenix</h3><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*7_2PjFM9Xp9POuSkVVLznQ.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/photos/9r-_2gzP37k?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Mike Arney</a> on <a href="https://unsplash.com/search/photos/want?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>For me, I think Ecto is really kind to use among O/R Mappers I have ever used so far. However, I have felt like.., especially when the query does not work I expected, I want to see the SQL itself which has made by Ecto.</p><p>Here is the function to print the query.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/93965b3cd2693cd218378f5ff5073a84/href">https://medium.com/media/93965b3cd2693cd218378f5ff5073a84/href</a></iframe><p>I think everyone likes this!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b785019b2098" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codes-for-elixir-phoenix/do-you-want-to-see-sql-you-created-by-ecto-b785019b2098">Do you want to see “SQL” you created by Ecto?</a> was originally published in <a href="https://medium.com/codes-for-elixir-phoenix">Codes for Elixir / Phoenix. Investigation of the best practice.</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[“if” statement can return value | Elixir | Phoenix]]></title>
            <link>https://medium.com/codes-for-elixir-phoenix/if-statement-can-return-value-elixir-phoenix-e93c9df1c50b?source=rss-cfe1dfb7f973------2</link>
            <guid isPermaLink="false">https://medium.com/p/e93c9df1c50b</guid>
            <category><![CDATA[phoenix-framework]]></category>
            <category><![CDATA[elixir]]></category>
            <dc:creator><![CDATA[Kazuyoshi Ueno]]></dc:creator>
            <pubDate>Fri, 08 Mar 2019 06:54:17 GMT</pubDate>
            <atom:updated>2019-03-26T12:52:04.914Z</atom:updated>
            <content:encoded><![CDATA[<h3>“if” statement can return value | Elixir / Phoenix</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*z1ifbG5SRh7dtCIRV3AC1Q.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/photos/3FFxit3yCCc?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Nick Karvounis</a> on <a href="https://unsplash.com/collections/582659/expressive-faces?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>I’m not trying to use “if” statement in Elixir as I’ve already mentioned it in the first <a href="https://medium.com/codes-for-elixir-phoenix/i-like-the-with-statement-elixir-phoenix-5ff27e0a01c3">post</a>. But ….the reality is different. We can avoid “if” completely from codes we will write. I think it is so great, but, on the other hand, this will sometime make our codes not be readable. So, I unwillingly use “if” statement like the following.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/09162539f072673386c5e62a6b52adaa/href">https://medium.com/media/09162539f072673386c5e62a6b52adaa/href</a></iframe><p>It’s so weird <strong>for me</strong>. Even I have no choice but to use “if”, I want to find another way of writing. Yes, I can write it by <strong>one line</strong>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b28c803cc511bddc083d2bfed3b24108/href">https://medium.com/media/b28c803cc511bddc083d2bfed3b24108/href</a></iframe><p>O.K…. I have been writing by this way for the first 2 months with some patience…</p><p>You know what? Elixir is not the OOP language! Because of my OOP experience of more than 10 years, I could not imagine talking more about it with Elixir.</p><p>Actually, the condition syntax in Elixir <strong>can returns value</strong>!<br>So, now I’m writing above code like this!</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f2c8e60f82f325a0aee67a1957ed627b/href">https://medium.com/media/f2c8e60f82f325a0aee67a1957ed627b/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e93c9df1c50b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codes-for-elixir-phoenix/if-statement-can-return-value-elixir-phoenix-e93c9df1c50b">“if” statement can return value | Elixir | Phoenix</a> was originally published in <a href="https://medium.com/codes-for-elixir-phoenix">Codes for Elixir / Phoenix. Investigation of the best practice.</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[I like the “with” statement. | Elixir / Phoenix]]></title>
            <link>https://medium.com/codes-for-elixir-phoenix/i-like-the-with-statement-elixir-phoenix-5ff27e0a01c3?source=rss-cfe1dfb7f973------2</link>
            <guid isPermaLink="false">https://medium.com/p/5ff27e0a01c3</guid>
            <category><![CDATA[elixir]]></category>
            <category><![CDATA[phoenix-framework]]></category>
            <dc:creator><![CDATA[Kazuyoshi Ueno]]></dc:creator>
            <pubDate>Thu, 07 Mar 2019 17:06:31 GMT</pubDate>
            <atom:updated>2019-03-26T12:53:01.566Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6Am2UYRK8S2o4mzs7cP27Q.png" /></figure><p>It’s been 3 months since I’ve started to write codes with <strong>Elixir</strong>.<br>Elixir isn’t a famous language in <strong>Japan</strong>, so it’s hard to find a guy who knows how to write the best code in Elixir.</p><p>Actually, just because it’s a “<strong>job</strong>” makes me being conscious to finish it speedily and we can not make some time for refactoring our codes.</p><p>However, I personally want to write it down about my knowledge that I currently think it is a better or best way.</p><p>If you were also an Elixir Programmer or something, please comment me!</p><p>The first story about Elixir is “<strong>with</strong>” statement. My colleague started to study Elixir before I join a project, and she often uses “<strong>if</strong>” statement a lot, and that makes some <strong>nests</strong> because she also has to finish a job rather than taking time for refactoring or studying.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0760a1a84814b055fb9ddc58b518a527/href">https://medium.com/media/0760a1a84814b055fb9ddc58b518a527/href</a></iframe><p>Yes, I know someone like this way….<br>But we use Elixir, so I personally do not like to use “Control or Condition Syntax” as possible.</p><p>Elixir has the “with” statement. ( I did not understand what for it at first. )<br>So I always use “with” statement when doing something which needs some conditions passed.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/97d7ea21d8fa961a575a2dd1445037ae/href">https://medium.com/media/97d7ea21d8fa961a575a2dd1445037ae/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5ff27e0a01c3" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codes-for-elixir-phoenix/i-like-the-with-statement-elixir-phoenix-5ff27e0a01c3">I like the “with” statement. | Elixir / Phoenix</a> was originally published in <a href="https://medium.com/codes-for-elixir-phoenix">Codes for Elixir / Phoenix. Investigation of the best practice.</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>