<p dir="auto"><strong>Migrated issue, originally created by Anonymous</strong></p>
<p dir="auto">If you define a default ordering in a relation and do a query on that relation using a different ordering the result is not what you would expect. In my code I define a mapper like this:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="orm.mapper(Desktop, desktop_table, properties=dict(
    status_history = orm.relation(DesktopStatus,
                                  backref=&quot;desktop&quot;,
                                  order_by=DesktopStatus.updated,
                                  lazy=&quot;dynamic&quot;),
    ))"><pre class="notranslate"><code class="notranslate">orm.mapper(Desktop, desktop_table, properties=dict(
    status_history = orm.relation(DesktopStatus,
                                  backref="desktop",
                                  order_by=DesktopStatus.updated,
                                  lazy="dynamic"),
    ))
</code></pre></div>
<p dir="auto">In one method of the Desktop class I need use the last entry in that list. A slice results in all entries being fixed, so I did this:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="    status=self.status_history.order_by(DesktopStatus.updated.desc()).limit(1).first().updated"><pre class="notranslate"><code class="notranslate">    status=self.status_history.order_by(DesktopStatus.updated.desc()).limit(1).first().updated
</code></pre></div>
<p dir="auto">which resulted in this SQL query:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="10:55:38,427 INFO  [sqlalchemy.engine.base.Engine.0x..ec](sqlalchemy.engine.base.Engine.0x..ec) SELECT desktop_status.id AS desktop_status_id, desktop_status.desktop_id AS desktop_status_desktop_id, desktop_status.old_status AS desktop_status_old_status, desktop_status.new_status AS desktop_status_new_status, desktop_status.updated AS desktop_status_updated 
FROM desktop_status 
WHERE %(param_1)s = desktop_status.desktop_id ORDER BY desktop_status.updated, desktop_status.updated DESC 
 LIMIT 1 OFFSET 0"><pre class="notranslate"><code class="notranslate">10:55:38,427 INFO  [sqlalchemy.engine.base.Engine.0x..ec](sqlalchemy.engine.base.Engine.0x..ec) SELECT desktop_status.id AS desktop_status_id, desktop_status.desktop_id AS desktop_status_desktop_id, desktop_status.old_status AS desktop_status_old_status, desktop_status.new_status AS desktop_status_new_status, desktop_status.updated AS desktop_status_updated 
FROM desktop_status 
WHERE %(param_1)s = desktop_status.desktop_id ORDER BY desktop_status.updated, desktop_status.updated DESC 
 LIMIT 1 OFFSET 0
</code></pre></div>
<p dir="auto">notice how desktop_status.updated appears twice in the ORDER BY clause. The first one takes precedence, so the explicit ordering from my query is ignored.</p>
<p dir="auto">This is somewhat related to <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="384614659" data-permission-text="Title is private" data-url="https://github.com/sqlalchemy/sqlalchemy/issues/1079" data-hovercard-type="issue" data-hovercard-url="/sqlalchemy/sqlalchemy/issues/1079/hovercard" href="https://github.com/sqlalchemy/sqlalchemy/issues/1079">#1079</a>. I felt that this specific issue is different enough to warrant a separate bugreport.</p>
<p dir="auto"><strong>Migrated issue, originally created by Anonymous</strong></p>
<p dir="auto">When trying to reflect a table with a column with the unsigned keyword this exception is thrown:</p>
<p dir="auto">Using SQLAlchemy 0.2.6 installed via easy_install and mysql 4.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="$ python bug.py 
Traceback (most recent call last):
  File &quot;bug.py&quot;, line 5, in ?
    bug_table = Table(&quot;bug&quot;, meta, autoload=True)
  File &quot;build/bdist.darwin-8.7.1-i386/egg/sqlalchemy/schema.py&quot;, line 97, in __call__
  File &quot;build/bdist.darwin-8.7.1-i386/egg/sqlalchemy/engine/base.py&quot;, line 488, in reflecttable
  File &quot;build/bdist.darwin-8.7.1-i386/egg/sqlalchemy/databases/mysql.py&quot;, line 337, in reflecttable
TypeError: __init__() got an unexpected keyword argument 'unsigned'"><pre class="notranslate"><code class="notranslate">$ python bug.py 
Traceback (most recent call last):
  File "bug.py", line 5, in ?
    bug_table = Table("bug", meta, autoload=True)
  File "build/bdist.darwin-8.7.1-i386/egg/sqlalchemy/schema.py", line 97, in __call__
  File "build/bdist.darwin-8.7.1-i386/egg/sqlalchemy/engine/base.py", line 488, in reflecttable
  File "build/bdist.darwin-8.7.1-i386/egg/sqlalchemy/databases/mysql.py", line 337, in reflecttable
TypeError: __init__() got an unexpected keyword argument 'unsigned'
</code></pre></div>
<p dir="auto">The SQL used to create this:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="CREATE TABLE `bug` (
    `bug_id` mediumint(8) unsigned NOT NULL default '0'
) ENGINE=MyISAM DEFAULT CHARSET=latin1;"><pre class="notranslate"><code class="notranslate">CREATE TABLE `bug` (
    `bug_id` mediumint(8) unsigned NOT NULL default '0'
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
</code></pre></div>
<p dir="auto">And my bug.py:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="from sqlalchemy import *
meta = meta = BoundMetaData(&quot;mysql://localhost/bug&quot;)
bug_table = Table(&quot;bug&quot;, meta, autoload=True)"><pre class="notranslate"><code class="notranslate">from sqlalchemy import *
meta = meta = BoundMetaData("mysql://localhost/bug")
bug_table = Table("bug", meta, autoload=True)
</code></pre></div>
<p dir="auto">(I was trying to reflect a phpBB table in case you were curious)</p>