Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: add test for enum reflection #450

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from

test: rework enum tests

a041be4
Select commit
Loading
Failed to load commit list.
Sign in for the full log view
Draft

test: add test for enum reflection #450

test: rework enum tests
a041be4
Select commit
Loading
Failed to load commit list.
GitHub Actions / Test Results - 3.10 failed Apr 9, 2024 in 0s

2 fail, 40 skipped, 48 pass in 14s

90 tests  ±0   48 ✅ ±0   14s ⏱️ ±0s
 1 suites ±0   40 💤  - 1 
 1 files   ±0    2 ❌ +1 

Results for commit a041be4. ± Comparison against earlier commit 0c97ebb.

Annotations

Check warning on line 0 in duckdb_engine.tests.test_basic

See this annotation in the file changed.

@github-actions github-actions / Test Results - 3.10

test_enum_type_format (duckdb_engine.tests.test_basic) failed

results.xml [took 0s]
Raw output
TypeError: tuple indices must be integers or slices, not str
engine = Engine(duckdb:///:memory:)

    #x1B[0m#x1B[37m@mark#x1B[39;49;00m.xfail(raises=#x1B[96mAssertionError#x1B[39;49;00m, reason=#x1B[33m"#x1B[39;49;00m#x1B[33mnot yet supported by duckdb#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m)#x1B[90m#x1B[39;49;00m
    #x1B[94mdef#x1B[39;49;00m #x1B[92mtest_enum_type_format#x1B[39;49;00m(engine: Engine) -> #x1B[94mNone#x1B[39;49;00m:#x1B[90m#x1B[39;49;00m
        importorskip(#x1B[33m"#x1B[39;49;00m#x1B[33mduckdb#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m, #x1B[33m"#x1B[39;49;00m#x1B[33m0.6.1#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m)#x1B[90m#x1B[39;49;00m
    #x1B[90m#x1B[39;49;00m
        sql = [#x1B[90m#x1B[39;49;00m
            #x1B[33m"#x1B[39;49;00m#x1B[33mCREATE TYPE enum_t AS ENUM(#x1B[39;49;00m#x1B[33m'#x1B[39;49;00m#x1B[33ma#x1B[39;49;00m#x1B[33m'#x1B[39;49;00m#x1B[33m, #x1B[39;49;00m#x1B[33m'#x1B[39;49;00m#x1B[33mb#x1B[39;49;00m#x1B[33m'#x1B[39;49;00m#x1B[33m);#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m,#x1B[90m#x1B[39;49;00m
            #x1B[33m"#x1B[39;49;00m#x1B[33mCREATE TABLE tmp (enum_col enum_t);#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m,#x1B[90m#x1B[39;49;00m
        ]#x1B[90m#x1B[39;49;00m
        #x1B[94mwith#x1B[39;49;00m engine.connect() #x1B[94mas#x1B[39;49;00m conn:#x1B[90m#x1B[39;49;00m
            #x1B[94mfor#x1B[39;49;00m s #x1B[95min#x1B[39;49;00m sql:#x1B[90m#x1B[39;49;00m
                conn.execute(text(s))#x1B[90m#x1B[39;49;00m
    #x1B[90m#x1B[39;49;00m
            (column,) = conn.execute(#x1B[90m#x1B[39;49;00m
                text(#x1B[33m"#x1B[39;49;00m#x1B[33mselect * from duckdb_columns() where column_name = #x1B[39;49;00m#x1B[33m'#x1B[39;49;00m#x1B[33menum_col#x1B[39;49;00m#x1B[33m'#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m)#x1B[90m#x1B[39;49;00m
            )#x1B[90m#x1B[39;49;00m
            (type_actual,) = conn.execute(#x1B[90m#x1B[39;49;00m
                text(#x1B[33m"#x1B[39;49;00m#x1B[33mselect * from duckdb_types() where type_name = #x1B[39;49;00m#x1B[33m'#x1B[39;49;00m#x1B[33menum_t#x1B[39;49;00m#x1B[33m'#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m),#x1B[90m#x1B[39;49;00m
            )#x1B[90m#x1B[39;49;00m
    #x1B[90m#x1B[39;49;00m
>           type_oid = type_actual[#x1B[33m"#x1B[39;49;00m#x1B[33mtype_oid#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m]#x1B[90m#x1B[39;49;00m

#x1B[1m#x1B[31mduckdb_engine/tests/test_basic.py#x1B[0m:394: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

>   #x1B[0m#x1B[04m#x1B[91m?#x1B[39;49;00m#x1B[04m#x1B[91m?#x1B[39;49;00m#x1B[04m#x1B[91m?#x1B[39;49;00m#x1B[90m#x1B[39;49;00m
#x1B[1m#x1B[31mE   TypeError: tuple indices must be integers or slices, not str#x1B[0m

#x1B[1m#x1B[31mlib/sqlalchemy/cyextension/resultproxy.pyx#x1B[0m:54: TypeError

Check warning on line 0 in duckdb_engine.tests.test_basic

See this annotation in the file changed.

@github-actions github-actions / Test Results - 3.10

test_enum_reflection (duckdb_engine.tests.test_basic) failed

results.xml [took 0s]
Raw output
sqlalchemy.exc.NoSuchTableError: tmp
session = <sqlalchemy.orm.session.Session object at 0x7f88b8998e50>
engine = Engine(duckdb:///:memory:)

    #x1B[0m#x1B[94mdef#x1B[39;49;00m #x1B[92mtest_enum_reflection#x1B[39;49;00m(session: Session, engine: Engine) -> #x1B[94mNone#x1B[39;49;00m:#x1B[90m#x1B[39;49;00m
        importorskip(#x1B[33m"#x1B[39;49;00m#x1B[33mduckdb#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m, #x1B[33m"#x1B[39;49;00m#x1B[33m0.6.1#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m)#x1B[90m#x1B[39;49;00m
    #x1B[90m#x1B[39;49;00m
        sql = [#x1B[90m#x1B[39;49;00m
            #x1B[33m"#x1B[39;49;00m#x1B[33mCREATE TYPE enum_t AS ENUM(#x1B[39;49;00m#x1B[33m'#x1B[39;49;00m#x1B[33ma#x1B[39;49;00m#x1B[33m'#x1B[39;49;00m#x1B[33m, #x1B[39;49;00m#x1B[33m'#x1B[39;49;00m#x1B[33mb#x1B[39;49;00m#x1B[33m'#x1B[39;49;00m#x1B[33m);#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m,#x1B[90m#x1B[39;49;00m
            #x1B[33m"#x1B[39;49;00m#x1B[33mCREATE TABLE tmp (enum_col enum_t);#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m,#x1B[90m#x1B[39;49;00m
            #x1B[33m"#x1B[39;49;00m#x1B[33mINSERT INTO tmp VALUES (#x1B[39;49;00m#x1B[33m'#x1B[39;49;00m#x1B[33mb#x1B[39;49;00m#x1B[33m'#x1B[39;49;00m#x1B[33m);#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m,#x1B[90m#x1B[39;49;00m
            #x1B[33m"#x1B[39;49;00m#x1B[33mINSERT INTO tmp VALUES (#x1B[39;49;00m#x1B[33m'#x1B[39;49;00m#x1B[33ma#x1B[39;49;00m#x1B[33m'#x1B[39;49;00m#x1B[33m);#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m,#x1B[90m#x1B[39;49;00m
        ]#x1B[90m#x1B[39;49;00m
    #x1B[90m#x1B[39;49;00m
        #x1B[94mwith#x1B[39;49;00m engine.connect() #x1B[94mas#x1B[39;49;00m conn:#x1B[90m#x1B[39;49;00m
            #x1B[94mfor#x1B[39;49;00m s #x1B[95min#x1B[39;49;00m sql:#x1B[90m#x1B[39;49;00m
                conn.execute(text(s))#x1B[90m#x1B[39;49;00m
    #x1B[90m#x1B[39;49;00m
        tmp = Table(#x1B[33m"#x1B[39;49;00m#x1B[33mtmp#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m, MetaData())#x1B[90m#x1B[39;49;00m
>       reflect_table(inspect(engine), tmp, include_columns=[])#x1B[90m#x1B[39;49;00m

#x1B[1m#x1B[31mduckdb_engine/tests/test_basic.py#x1B[0m:421: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
#x1B[1m#x1B[31mduckdb_engine/tests/test_basic.py#x1B[0m:372: in reflect_table
    #x1B[0m#x1B[94mreturn#x1B[39;49;00m reflect_table(*args, **kwargs)#x1B[90m#x1B[39;49;00m
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <duckdb_engine.DuckDBInspector object at 0x7f88b8998eb0>
table = Table('tmp', MetaData(), schema=None), include_columns = []
exclude_columns = (), resolve_fks = True, _extend_on = None
_reflect_info = _ReflectionInfo(columns={}, pk_constraint={}, foreign_keys={}, indexes={}, unique_constraints={}, table_comment={}, check_constraints={}, table_options={}, unreflectable={})

    #x1B[0m#x1B[94mdef#x1B[39;49;00m #x1B[92mreflect_table#x1B[39;49;00m(#x1B[90m#x1B[39;49;00m
        #x1B[96mself#x1B[39;49;00m,#x1B[90m#x1B[39;49;00m
        table: sa_schema.Table,#x1B[90m#x1B[39;49;00m
        include_columns: Optional[Collection[#x1B[96mstr#x1B[39;49;00m]],#x1B[90m#x1B[39;49;00m
        exclude_columns: Collection[#x1B[96mstr#x1B[39;49;00m] = (),#x1B[90m#x1B[39;49;00m
        resolve_fks: #x1B[96mbool#x1B[39;49;00m = #x1B[94mTrue#x1B[39;49;00m,#x1B[90m#x1B[39;49;00m
        _extend_on: Optional[Set[sa_schema.Table]] = #x1B[94mNone#x1B[39;49;00m,#x1B[90m#x1B[39;49;00m
        _reflect_info: Optional[_ReflectionInfo] = #x1B[94mNone#x1B[39;49;00m,#x1B[90m#x1B[39;49;00m
    ) -> #x1B[94mNone#x1B[39;49;00m:#x1B[90m#x1B[39;49;00m
    #x1B[90m    #x1B[39;49;00m#x1B[33m"""Given a :class:`_schema.Table` object, load its internal#x1B[39;49;00m
    #x1B[33m    constructs based on introspection.#x1B[39;49;00m
    #x1B[33m#x1B[39;49;00m
    #x1B[33m    This is the underlying method used by most dialects to produce#x1B[39;49;00m
    #x1B[33m    table reflection.  Direct usage is like::#x1B[39;49;00m
    #x1B[33m#x1B[39;49;00m
    #x1B[33m        from sqlalchemy import create_engine, MetaData, Table#x1B[39;49;00m
    #x1B[33m        from sqlalchemy import inspect#x1B[39;49;00m
    #x1B[33m#x1B[39;49;00m
    #x1B[33m        engine = create_engine('...')#x1B[39;49;00m
    #x1B[33m        meta = MetaData()#x1B[39;49;00m
    #x1B[33m        user_table = Table('user', meta)#x1B[39;49;00m
    #x1B[33m        insp = inspect(engine)#x1B[39;49;00m
    #x1B[33m        insp.reflect_table(user_table, None)#x1B[39;49;00m
    #x1B[33m#x1B[39;49;00m
    #x1B[33m    .. versionchanged:: 1.4 Renamed from ``reflecttable`` to#x1B[39;49;00m
    #x1B[33m       ``reflect_table``#x1B[39;49;00m
    #x1B[33m#x1B[39;49;00m
    #x1B[33m    :param table: a :class:`~sqlalchemy.schema.Table` instance.#x1B[39;49;00m
    #x1B[33m    :param include_columns: a list of string column names to include#x1B[39;49;00m
    #x1B[33m      in the reflection process.  If ``None``, all columns are reflected.#x1B[39;49;00m
    #x1B[33m#x1B[39;49;00m
    #x1B[33m    """#x1B[39;49;00m#x1B[90m#x1B[39;49;00m
    #x1B[90m#x1B[39;49;00m
        #x1B[94mif#x1B[39;49;00m _extend_on #x1B[95mis#x1B[39;49;00m #x1B[95mnot#x1B[39;49;00m #x1B[94mNone#x1B[39;49;00m:#x1B[90m#x1B[39;49;00m
            #x1B[94mif#x1B[39;49;00m table #x1B[95min#x1B[39;49;00m _extend_on:#x1B[90m#x1B[39;49;00m
                #x1B[94mreturn#x1B[39;49;00m#x1B[90m#x1B[39;49;00m
            #x1B[94melse#x1B[39;49;00m:#x1B[90m#x1B[39;49;00m
                _extend_on.add(table)#x1B[90m#x1B[39;49;00m
    #x1B[90m#x1B[39;49;00m
        dialect = #x1B[96mself#x1B[39;49;00m.bind.dialect#x1B[90m#x1B[39;49;00m
    #x1B[90m#x1B[39;49;00m
        #x1B[94mwith#x1B[39;49;00m #x1B[96mself#x1B[39;49;00m._operation_context() #x1B[94mas#x1B[39;49;00m conn:#x1B[90m#x1B[39;49;00m
            schema = conn.schema_for_object(table)#x1B[90m#x1B[39;49;00m
    #x1B[90m#x1B[39;49;00m
        table_name = table.name#x1B[90m#x1B[39;49;00m
    #x1B[90m#x1B[39;49;00m
        #x1B[90m# get table-level arguments that are specifically#x1B[39;49;00m#x1B[90m#x1B[39;49;00m
        #x1B[90m# intended for reflection, e.g. oracle_resolve_synonyms.#x1B[39;49;00m#x1B[90m#x1B[39;49;00m
        #x1B[90m# these are unconditionally passed to related Table#x1B[39;49;00m#x1B[90m#x1B[39;49;00m
        #x1B[90m# objects#x1B[39;49;00m#x1B[90m#x1B[39;49;00m
        reflection_options = {#x1B[90m#x1B[39;49;00m
            k: table.dialect_kwargs.get(k)#x1B[90m#x1B[39;49;00m
            #x1B[94mfor#x1B[39;49;00m k #x1B[95min#x1B[39;49;00m dialect.reflection_options#x1B[90m#x1B[39;49;00m
            #x1B[94mif#x1B[39;49;00m k #x1B[95min#x1B[39;49;00m table.dialect_kwargs#x1B[90m#x1B[39;49;00m
        }#x1B[90m#x1B[39;49;00m
    #x1B[90m#x1B[39;49;00m
        table_key = (schema, table_name)#x1B[90m#x1B[39;49;00m
        #x1B[94mif#x1B[39;49;00m _reflect_info #x1B[95mis#x1B[39;49;00m #x1B[94mNone#x1B[39;49;00m #x1B[95mor#x1B[39;49;00m table_key #x1B[95mnot#x1B[39;49;00m #x1B[95min#x1B[39;49;00m _reflect_info.columns:#x1B[90m#x1B[39;49;00m
            _reflect_info = #x1B[96mself#x1B[39;49;00m._get_reflection_info(#x1B[90m#x1B[39;49;00m
                schema,#x1B[90m#x1B[39;49;00m
                filter_names=[table_name],#x1B[90m#x1B[39;49;00m
                kind=ObjectKind.ANY,#x1B[90m#x1B[39;49;00m
                scope=ObjectScope.ANY,#x1B[90m#x1B[39;49;00m
                _reflect_info=_reflect_info,#x1B[90m#x1B[39;49;00m
                **table.dialect_kwargs,#x1B[90m#x1B[39;49;00m
            )#x1B[90m#x1B[39;49;00m
        #x1B[94mif#x1B[39;49;00m table_key #x1B[95min#x1B[39;49;00m _reflect_info.unreflectable:#x1B[90m#x1B[39;49;00m
            #x1B[94mraise#x1B[39;49;00m _reflect_info.unreflectable[table_key]#x1B[90m#x1B[39;49;00m
    #x1B[90m#x1B[39;49;00m
        #x1B[94mif#x1B[39;49;00m table_key #x1B[95mnot#x1B[39;49;00m #x1B[95min#x1B[39;49;00m _reflect_info.columns:#x1B[90m#x1B[39;49;00m
>           #x1B[94mraise#x1B[39;49;00m exc.NoSuchTableError(table_name)#x1B[90m#x1B[39;49;00m
#x1B[1m#x1B[31mE           sqlalchemy.exc.NoSuchTableError: tmp#x1B[0m

#x1B[1m#x1B[31m.nox/tests-3-10-sqlalchemy-2-0-duckdb-0-10-1/lib/python3.10/site-packages/sqlalchemy/engine/reflection.py#x1B[0m:1538: NoSuchTableError