- changed status to duplicate
FBDialect.reflecttable can raise an Assertion error on older firebird databases
Versions of Firebird prior to 2.0 were subject to the following bug http://tracker.firebirdsql.org/browse/CORE-356
The gist of CORE-356 is that values in the RDB$DEFAULT_SOURCE column of the RDB$RELATION_FIELDS table can have leading whitespace.
Trying to use meta.reflect on one of these tables results in errors like this:
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'")
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
assert row['fdefault']('fdefault').upper().lstrip().startswith('DEFAULT '), row
Comments (10)
-
-
- changed component to firebird
-
Account Deleted Thanks for the quick reply. For some reason my initial search did not turn up
#1582. While I'm sure 8aa2886c1a31c9a9950ad00345ac0cadcf78f7e2 will solve the majority of cases, I don't think you can count on the trailing space after 'DEFAULT '. The bug report at http://tracker.firebirdsql.org/browse/CORE-356 seems to indicate that in some cases Firebird will also embed CR+LF into RDB$DEFAULT_SOURCE -
Given that strip() considers CR and LF as whitespace, only the assertion seems wrong it that case, isn't it?
-
Account Deleted yes -- the assertion is wrong if 'DEFAULT' is followed by a newline.
how about something like this:
assert defexpr.startswith('DEFAULT') and defexpr[9](9) in string.whitespace, "Unrecognized default value: %s" % defexpr
(note that this requires importing string, but at least it avoids re
-
Account Deleted - removed status
- changed status to open
there is a typo in my previous comment. To avoid index errors the whitespace needs to be found at
defexpr[7](7)
not
defexpr[9](9)
I am going to reopen this since the assert will raise an Exception that client code will not be in a position to correct.
-
I fixed the assertion on both branches (see 6699 and 6700). I even transposed the CORE-356 examples into a test case, even if the issue seems corrected in current firebirds...
If you happen to be using a broken version, I'd be curious to know whether the test/dialect/test_firebird.py spot the problem.
-
repo owner - changed milestone to 0.5.xx
-
repo owner - changed status to wontfix
closing this due to inactivity.
-
repo owner - removed milestone
Removing milestone: 0.6.xx (automated comment)
- Log in to comment
This is a duplicate of
#1582: I'm going to commit a backport of 6257 into the 0.5 branch shortly.