<p dir="auto"><strong>Migrated issue, originally created by Nagaraj Tantri</strong></p>
<p dir="auto">Hi,</p>
<p dir="auto">I had a scenario where I would treat a custom column as unix date time and convert it to the required output via:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="literal_column(&quot;date_format(from_unixtime(ts), '%Y-%m-%d'&quot;))"><pre class="notranslate"><code class="notranslate">literal_column("date_format(from_unixtime(ts), '%Y-%m-%d'"))
</code></pre></div>
<p dir="auto">But that is getting converted to:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="WHERE date_format(from_unixtime(ts), '%%Y-%%m-%%d') 
&gt;= '1916-07-04 15:10:18.000000'"><pre class="notranslate"><code class="notranslate">WHERE date_format(from_unixtime(ts), '%%Y-%%m-%%d') 
&gt;= '1916-07-04 15:10:18.000000'
</code></pre></div>
<p dir="auto">I tried looking into other examples to escape the same and also tried to use bindparam but was in no success.</p>
<p dir="auto">Could anyone point me the actual solution to get it as:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="WHERE date_format(from_unixtime(ts), '%Y-%m-%d') 
&gt;= '1916-07-04 15:10:18.000000'"><pre class="notranslate"><code class="notranslate">WHERE date_format(from_unixtime(ts), '%Y-%m-%d') 
&gt;= '1916-07-04 15:10:18.000000'
</code></pre></div>
<p dir="auto"><strong>Migrated issue, originally created by Michael Bayer (<a href="https://github.com/zzzeek">@zzzeek</a>)</strong></p>
<p dir="auto">Currently, literal_column() doubles up percent signs as the base compiler.py level, which is inconsistent with the behavior of text() and column(), which both do it at the per-dialect level.  But also, at the per-dialect level, the mysqldb and psycopg2 compilers hardcode this behavior in two separate places for text(), column(), and the modulus operator.</p>
<p dir="auto">doubling of percents should be done based on paramstyle alone and can be done by default in the base compiler.   literal_column() should not unconditionaly double percents as this is legacy behavior.</p>