<p dir="auto"><strong>Migrated issue, originally created by Anonymous</strong></p>
<p dir="auto">We're dealing with tables with user-defined schemas. Sometimes they provide columns with duplicate names, except for case, e.g.:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="  CREATE TABLE foo (&quot;bar&quot; integer, &quot;BAR&quot; integer);
  INSERT INTO foo (&quot;bar&quot;, &quot;BAR&quot;) VALUES (1, 2);"><pre class="notranslate"><code class="notranslate">  CREATE TABLE foo ("bar" integer, "BAR" integer);
  INSERT INTO foo ("bar", "BAR") VALUES (1, 2);
</code></pre></div>
<p dir="auto">While that's clearly crazy, I expect sqlalchemy to handle them. Unfortunately:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="  for row in table.select().execute():
    print row.items()"><pre class="notranslate"><code class="notranslate">  for row in table.select().execute():
    print row.items()
</code></pre></div>
<p dir="auto">Causes:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="  Traceback (most recent call last):
    File &quot;&lt;ipython console&gt;&quot;, line 4, in f
    File &quot;/usr/lib/pymodules/python2.6/sqlalchemy/engine/base.py&quot;, line 1359, in items
      return [getattr(self, key)) for key in self.iterkeys()]((key,)
    File &quot;/usr/lib/pymodules/python2.6/sqlalchemy/engine/base.py&quot;, line 1352, in __getattr__
      return self.__parent._get_col(self.__row, name)
    File &quot;/usr/lib/pymodules/python2.6/sqlalchemy/engine/base.py&quot;, line 1620, in _get_col
      return processor(row[index](index))
    File &quot;/usr/lib/pymodules/python2.6/sqlalchemy/engine/base.py&quot;, line 1513, in process
      &quot;try 'use_labels' option on select statement.&quot; % colname)
  InvalidRequestError: Ambiguous column name 'bar' in result set! try 'use_labels' option on select statement."><pre class="notranslate"><code class="notranslate">  Traceback (most recent call last):
    File "&lt;ipython console&gt;", line 4, in f
    File "/usr/lib/pymodules/python2.6/sqlalchemy/engine/base.py", line 1359, in items
      return [getattr(self, key)) for key in self.iterkeys()]((key,)
    File "/usr/lib/pymodules/python2.6/sqlalchemy/engine/base.py", line 1352, in __getattr__
      return self.__parent._get_col(self.__row, name)
    File "/usr/lib/pymodules/python2.6/sqlalchemy/engine/base.py", line 1620, in _get_col
      return processor(row[index](index))
    File "/usr/lib/pymodules/python2.6/sqlalchemy/engine/base.py", line 1513, in process
      "try 'use_labels' option on select statement." % colname)
  InvalidRequestError: Ambiguous column name 'bar' in result set! try 'use_labels' option on select statement.
</code></pre></div>
<p dir="auto">The problem is apparent from the <code class="notranslate">ResultProxy</code> docstring:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="    Individual columns may be accessed by ... case-insensitive column name ..."><pre class="notranslate"><code class="notranslate">    Individual columns may be accessed by ... case-insensitive column name ...
</code></pre></div>
<p dir="auto">Note that <code class="notranslate">row.keys()</code> and <code class="notranslate">list(row)</code> both work fine, so the exception message is actually misleading, because the fetch from the database works fine (the naming ambiguity is a problem in sqlalchemy, after the rows have been fetched)</p>
<p dir="auto">Discovered on 0.5.8 but that docstring is unchanged in the 0.7.7 source, so I assume it hasn't been fixed.</p>
<p dir="auto"><strong>Migrated issue, originally created by Anonymous</strong></p>
<p dir="auto">Here is a small patch to add support of storing timedelta valuesin SQL databases. If possible it tries to use native DB support of timedelta (just PostgreSQL for now), if there is no such it fallbacks to store timedeltas as sqltypes.DateTime with base of zero timestamp.</p>
<hr>
<p dir="auto">Attachments: <a href="../wiki/imported_issue_attachments/595/interval.5.patch">interval.5.patch</a> | <a href="../wiki/imported_issue_attachments/595/interval.6.patch">interval.6.patch</a> | <a href="../wiki/imported_issue_attachments/595/interval.4.patch">interval.4.patch</a> | <a href="../wiki/imported_issue_attachments/595/Interval.patch">Interval.patch</a> | <a href="../wiki/imported_issue_attachments/595/interval.2.patch">interval.2.patch</a> | <a href="../wiki/imported_issue_attachments/595/interval.3.patch">interval.3.patch</a></p>