Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

SQLA queries fail due to `AbstractConcreteBase and has a mapping pending until all subclasses are defined`

Open
#262 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
python, sqlalchemy
Domain
databases

Research direction

Reproduce the failure with the shown imports, tunnel_pipelines profile, session, and Gaia_DR3 query. Start by examining sdssdb.sqlalchemy.sdss5db.catalogdb.Gaia_DR3 and the surrounding model definitions, then investigate when mapper configuration occurs; verify the fix by confirming the query succeeds without the UnmappedClassError.

Written by the indexing model from the issue text.

Description

When I try a query using the SQLAlchemy model they all fail with error AbstractConcreteBase and has a mapping pending until all subclasses are defined.

For example

>>> from sdssdb.sqlalchemy.sdss5db import database, catalogdb

>>> database.set_profile('tunnel_pipelines')
True

>>> session = database.Session()

>>> session.query(catalogdb.Gaia_DR3).first()
[ERROR]: Traceback (most recent call last):
  File "/Users/gallegoj/.pyenv/versions/3.10.14/envs/valis/lib/python3.10/site-packages/IPython/core/interactiveshell.py", line 3577, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-5-3e43bb8cd684>", line 1, in <module>
    x = session.query(catalogdb.Gaia_DR3).first()
  File "/Users/gallegoj/.pyenv/versions/3.10.14/envs/valis/lib/python3.10/site-packages/sqlalchemy/orm/session.py", line 2166, in query
    return self._query_cls(entities, self, **kwargs)
  File "/Users/gallegoj/.pyenv/versions/3.10.14/envs/valis/lib/python3.10/site-packages/sqlalchemy/orm/query.py", line 180, in __init__
    self._set_entities(entities)
  File "/Users/gallegoj/.pyenv/versions/3.10.14/envs/valis/lib/python3.10/site-packages/sqlalchemy/orm/query.py", line 187, in _set_entities
    self._raw_columns = [
  File "/Users/gallegoj/.pyenv/versions/3.10.14/envs/valis/lib/python3.10/site-packages/sqlalchemy/orm/query.py", line 188, in <listcomp>
    coercions.expect(
  File "/Users/gallegoj/.pyenv/versions/3.10.14/envs/valis/lib/python3.10/site-packages/sqlalchemy/sql/coercions.py", line 183, in expect
    insp = inspection.inspect(element, raiseerr=False)
  File "/Users/gallegoj/.pyenv/versions/3.10.14/envs/valis/lib/python3.10/site-packages/sqlalchemy/inspection.py", line 64, in inspect
    ret = reg(subject)
  File "/Users/gallegoj/.pyenv/versions/3.10.14/envs/valis/lib/python3.10/site-packages/sqlalchemy/orm/decl_api.py", line 1056, in _inspect_decl_meta
    _DeferredMapperConfig.raise_unmapped_for_cls(cls)
  File "/Users/gallegoj/.pyenv/versions/3.10.14/envs/valis/lib/python3.10/site-packages/sqlalchemy/orm/decl_base.py", line 1091, in raise_unmapped_for_cls
    class_._sa_raise_deferred_config()
  File "/Users/gallegoj/.pyenv/versions/3.10.14/envs/valis/lib/python3.10/site-packages/sqlalchemy/ext/declarative/extensions.py", line 307, in _sa_raise_deferred_config
    raise orm_exc.UnmappedClassError(
sqlalchemy.orm.exc.UnmappedClassError: Class sdssdb.sqlalchemy.sdss5db.catalogdb.Gaia_DR3 is a subclass of AbstractConcreteBase and has a mapping pending until all subclasses are defined. Call the sqlalchemy.orm.configure_mappers() function after all subclasses have been defined to complete the mapping of this class.

Running configure_mappers() doesn't seem to help.

Dominant language
Python
Stars
8
Forks
2
Avg merge
10d 31m
Merged PRs (30d)
1

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from sdss/sdssdb

All issues in sdss/sdssdb

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.