<p dir="auto"><strong>Migrated issue, originally created by tosh</strong></p>
<p dir="auto">Hi there,</p>
<p dir="auto">I use SQLAlchemy 0.8.3 (so maybe it's fixed in newer releases) with MySQL 5.1.73.<br>
When I do the query</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Session.query(distinct(Model))"><pre class="notranslate"><code class="notranslate">Session.query(distinct(Model))
</code></pre></div>
<p dir="auto">it generates something like</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="SELECT DISTINCT :param_1 AS anon_1;"><pre class="notranslate"><code class="notranslate">SELECT DISTINCT :param_1 AS anon_1;
</code></pre></div>
<p dir="auto">Where :param_1 is replaced with Model.__repr__() which is a simple string.</p>
<p dir="auto">Maybe it would be more obvious if such SQLAlchemy-queries generated the following code?</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="SELECT DISTINCT id AS anon_1 FROM model_table;"><pre class="notranslate"><code class="notranslate">SELECT DISTINCT id AS anon_1 FROM model_table;
</code></pre></div>
<p dir="auto">Optionally, SQLAlchemy could raise an exception if a model was passed as an argument.</p>
<p dir="auto"><strong>Migrated issue, originally created by Michael Bayer (<a href="https://github.com/zzzeek">@zzzeek</a>)</strong></p>