<p dir="auto"><strong>Migrated issue, originally created by Anonymous</strong></p>
<p dir="auto">Versions of Firebird prior to 2.0 were subject to the following bug <a href="http://tracker.firebirdsql.org/browse/CORE-356" rel="nofollow">http://tracker.firebirdsql.org/browse/CORE-356</a></p>
<p dir="auto">The gist of CORE-356 is that values in the RDB$DEFAULT_SOURCE column of the RDB$RELATION_FIELDS table can have leading whitespace.</p>
<p dir="auto">Trying to use meta.reflect on one of these tables results in errors like this:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="File &quot;.../site-packages/sqlalchemy/databases/firebird.py&quot;, line 501, in reflecttable
    assert row['fdefault']('fdefault').upper().startswith('DEFAULT '), row
AssertionError: (u'ARCHIVED           ', None, u'TEXT', 0, 1, None, 0, &quot; DEFAULT 'N'&quot;)"><pre class="notranslate"><code class="notranslate">File ".../site-packages/sqlalchemy/databases/firebird.py", line 501, in reflecttable
    assert row['fdefault']('fdefault').upper().startswith('DEFAULT '), row
AssertionError: (u'ARCHIVED           ', None, u'TEXT', 0, 1, None, 0, " DEFAULT 'N'")
</code></pre></div>
<p dir="auto">A simple fix for this is to add a TRIM to the tblqry around the COALESCE or since the fdefault value is being modified with .upper anyway line 501 might be a better spot to "fix" this</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"><pre class="notranslate"><code class="notranslate">assert row['fdefault']('fdefault').upper().lstrip().startswith('DEFAULT '), row
</code></pre></div>
<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>