[PATCH] firebird tests fail when using has_table or has_sequence

Issue #1521 resolved
Former user created an issue

(original reporter: randall) At svn 6292, most of these tests fail.

nosetests test.engine.test_reflection:ComponentReflectionTest --dburi=firebird://test:test@dbhost1/var/lib/firebird/2.0/data/test.gdb

I traced it back to calls to has_table and has_sequence. I'm using Firebird classic 2.0. Apparently for my setup, the SELECT 1 without a column alias was returning an empty string, which caused denormalize_name to barf. I've attached a patch which uses aliases and all tests pass now for me.

Comments (11)

  1. Lele Gaifax

    Uhm, even if I agree that the proposed patch is innoquous, I fail to see the relation between how the field is labelled and the denormalize_name barf.

    The function is applied only to the "incoming" argument (that is, either to the table name or the sequence name), and the affected methods just check whether the query returns a row or not:

    tblqry = """
    SELECT 1 FROM rdb$database
    WHERE EXISTS (SELECT rdb$relation_name
                  FROM rdb$relations
                  WHERE rdb$relation_name=?)
    """
    c = connection.execute(tblqry, [self.denormalize_name(table_name)](self.denormalize_name(table_name)))
    return c.first() is not None
    

    There must be something else going wrong here, as the test suite you mention does work ok for me:

    svn-0.6 $ ./rt test.engine.test_reflection:ComponentReflectionTest
    .'test_get_columns_with_schema' unsupported on DB implementation 'firebird+kinterbasdb': no schema support
    ..'test_get_foreign_keys_with_schema' unsupported on DB implementation 'firebird+kinterbasdb': no schema support
    ..'test_get_indexes_with_schema' unsupported on DB implementation 'firebird+kinterbasdb': no schema support
    ...'test_get_schema_names' unsupported on DB implementation 'firebird+kinterbasdb': no schema support
    ..'test_get_table_names_with_schema' unsupported on DB implementation 'firebird+kinterbasdb': no schema support
    ..'test_get_table_oid_with_schema' unsupported on DB implementation 'firebird+kinterbasdb': no schema support
    ..'test_get_view_columns_with_schema' unsupported on DB implementation 'firebird+kinterbasdb': no schema support
    ..'test_get_view_definition_with_schema' unsupported on DB implementation 'firebird+kinterbasdb': no schema support
    ..'test_get_view_names_with_schema' unsupported on DB implementation 'firebird+kinterbasdb': no schema support
    .
    ----------------------------------------------------------------------
    Ran 19 tests in 0.698s
    
    OK
    
  2. Mike Bayer repo owner

    if you can post what error was raised when the label wasn't present that would shed light on what's happening here.

  3. Former user Account Deleted

    Replying to zzzeek:

    if you can post what error was raised when the label wasn't present that would shed light on what's happening here. Here's the error:

    File "/usr/lib/python2.6/site-packages/SQLAlchemy-0.6beta3-py2.6.egg/sqlalchemy/engine/base.py", line 1972, in _init_metadata
    self._metadata = ResultMetaData(self, metadata)
    File "/usr/lib/python2.6/site-packages/SQLAlchemy-0.6beta3-py2.6.egg/sqlalchemy/engine/base.py", line 1866, in __init__
    colname = dialect.normalize_name(colname)
    File "/usr/lib/python2.6/site-packages/SQLAlchemy-0.6beta3-py2.6.egg/sqlalchemy/dialects/firebird/base.py", line 343, in normalize_name
    not self.identifier_preparer._requires_quotes(name.lower()):
    File "/usr/lib/python2.6/site-packages/SQLAlchemy-0.6beta3-py2.6.egg/sqlalchemy/sql/compiler.py", line 1507, in _requires_quotes
    or value[0](0) in self.illegal_initial_characters
    IndexError: string index out of range
    

    Here's the isql results: for firebird 2.0.5 (column doesn't have a name):

    SQL> select 1 from rdb$database;
    
    
    ============
               1
    

    for firebird 2.1 (name appeared):

    SQL> select 1 from rdb$database;
    
        CONSTANT
    ============
               1
    

    cursor.description returns empty string ('') and indexing fails.

  4. Log in to comment