<p dir="auto"><strong>Migrated issue, originally created by Anonymous</strong></p>
<p dir="auto">During schema reflection SQLAlchemy fails with AssertionError</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Traceback (most recent call last):
  File &quot;/tmp/sqla2.py&quot;, line 190, in &lt;module&gt;
    concentrate=False # Don't try to join the relation lines together
  File &quot;/tmp/sqla2.py&quot;, line 132, in create_schema_graph
    metadata.reflect()
  File &quot;/home/filip/tefnet/teferp/workspace/tefobjects/lib/python2.5/site-packages/SQLAlchemy-0.5.5-py2.5.egg/sqlalchemy/schema.py&quot;, line 1733, in reflect
    Table(name, self, **reflect_opts)
  File &quot;/home/filip/tefnet/teferp/workspace/tefobjects/lib/python2.5/site-packages/SQLAlchemy-0.5.5-py2.5.egg/sqlalchemy/schema.py&quot;, line 108, in __call__
    return type.__call__(self, name, metadata, *args, **kwargs)
  File &quot;/home/filip/tefnet/teferp/workspace/tefobjects/lib/python2.5/site-packages/SQLAlchemy-0.5.5-py2.5.egg/sqlalchemy/schema.py&quot;, line 236, in __init__
    _bind_or_error(metadata).reflecttable(self, include_columns=include_columns)
  File &quot;/home/filip/tefnet/teferp/workspace/tefobjects/lib/python2.5/site-packages/SQLAlchemy-0.5.5-py2.5.egg/sqlalchemy/engine/base.py&quot;, line 1265, in reflecttable
    self.dialect.reflecttable(conn, table, include_columns)
  File &quot;/mnt/tmp/tefnet/teferp/workspace/tefobjects/lib/python2.5/site-packages/SQLAlchemy-0.5.5-py2.5.egg/sqlalchemy/databases/firebird.py&quot;, line 502, in reflecttable
    assert row['fdefault']('fdefault').upper().startswith('DEFAULT '), row
AssertionError: (u'DATAREJ                        ', 1, u'DATE                           ', None, 4, None, 0, ' DEFAULT CURRENT_DATE')"><pre class="notranslate"><code class="notranslate">Traceback (most recent call last):
  File "/tmp/sqla2.py", line 190, in &lt;module&gt;
    concentrate=False # Don't try to join the relation lines together
  File "/tmp/sqla2.py", line 132, in create_schema_graph
    metadata.reflect()
  File "/home/filip/tefnet/teferp/workspace/tefobjects/lib/python2.5/site-packages/SQLAlchemy-0.5.5-py2.5.egg/sqlalchemy/schema.py", line 1733, in reflect
    Table(name, self, **reflect_opts)
  File "/home/filip/tefnet/teferp/workspace/tefobjects/lib/python2.5/site-packages/SQLAlchemy-0.5.5-py2.5.egg/sqlalchemy/schema.py", line 108, in __call__
    return type.__call__(self, name, metadata, *args, **kwargs)
  File "/home/filip/tefnet/teferp/workspace/tefobjects/lib/python2.5/site-packages/SQLAlchemy-0.5.5-py2.5.egg/sqlalchemy/schema.py", line 236, in __init__
    _bind_or_error(metadata).reflecttable(self, include_columns=include_columns)
  File "/home/filip/tefnet/teferp/workspace/tefobjects/lib/python2.5/site-packages/SQLAlchemy-0.5.5-py2.5.egg/sqlalchemy/engine/base.py", line 1265, in reflecttable
    self.dialect.reflecttable(conn, table, include_columns)
  File "/mnt/tmp/tefnet/teferp/workspace/tefobjects/lib/python2.5/site-packages/SQLAlchemy-0.5.5-py2.5.egg/sqlalchemy/databases/firebird.py", line 502, in reflecttable
    assert row['fdefault']('fdefault').upper().startswith('DEFAULT '), row
AssertionError: (u'DATAREJ                        ', 1, u'DATE                           ', None, 4, None, 0, ' DEFAULT CURRENT_DATE')
</code></pre></div>
<p dir="auto">The problem is because 'DEFAULT' sometimes has whitespaces at the begining</p>
<hr>
<p dir="auto">Attachments: <a href="../wiki/imported_issue_attachments/1582/tef_firebird_default_reflection.patch">tef_firebird_default_reflection.patch</a></p>
<p dir="auto"><strong>Migrated issue, originally created by Anonymous</strong></p>
<p dir="auto">Reflecting columns with default values fails assertion test.  This may not happen on all tables, but did on at least one of mine.  The problem is in lines 502 and 503 of firebird.py.  They were:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="assert row['fdefault']('fdefault').upper().startswith('DEFAULT '), row
defvalue = row['fdefault']('fdefault')![8:](8:)"><pre class="notranslate"><code class="notranslate">assert row['fdefault']('fdefault').upper().startswith('DEFAULT '), row
defvalue = row['fdefault']('fdefault')![8:](8:)
</code></pre></div>
<p dir="auto">The problem was, at least in my case, that there was a space before the word DEFAULT in row<a target="_blank" rel="noopener noreferrer" href="'fdefault'"><img src="'fdefault'" alt="'fdefault'" style="max-width: 100%;"></a>.  This caused the assertion to fail.  I fixed it with the following code:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="assert row['fdefault']('fdefault').upper().lstrip().startswith('DEFAULT '), row
defvalue = row['fdefault']('fdefault').lstrip()![8:](8:)"><pre class="notranslate"><code class="notranslate">assert row['fdefault']('fdefault').upper().lstrip().startswith('DEFAULT '), row
defvalue = row['fdefault']('fdefault').lstrip()![8:](8:)
</code></pre></div>
<p dir="auto">Everything worked fine after that.</p>