Skip to content

scalars for async scope session #7103

Closed
@Bechma

Description

@Bechma

Describe the use case

I think it's related with #6991 , when I use the scalars method with the async scoped session it gives me an attribute error.
I see the implementations in the AsyncEngine and AsyncSession, but it looks that there is no implementation for the async_scoped_session

AttributeError: 'async_scoped_session' object has no attribute 'scalars'

Databases / Backends / Drivers targeted

PostgreSQL with asyncpg driver

Example Use

...
engine = create_async_engine(db_connstring)
session = async_scoped_session(
    sessionmaker(bind=engine, expire_on_commit=False, class_=AsyncSession),
    scopefunc=current_task)
rows = await session.scalars(select(TableOne))
...

Additional context

No response

Activity

added
requires triageNew issue that requires categorization
use casenot really a feature or a bug; can be support for new DB features or user use cases not anticipated
on Sep 28, 2021
CaselIT

CaselIT commented on Sep 28, 2021

@CaselIT
Member

Hi,

Thanks for reporting. I guess the same is true for scoped_session.

@zzzeek do you think we could automate testing for this, so that we catch similar issues in the future?

added
bugSomething isn't working
and removed
requires triageNew issue that requires categorization
on Sep 28, 2021
zzzeek

zzzeek commented on Sep 28, 2021

@zzzeek
Member

im not really sure because the scoped objects don't track every attribute

CaselIT

CaselIT commented on Sep 28, 2021

@CaselIT
Member

maybe we could have a test with a ignore_list when check that all other attributes are mapped. so what if something is added there is a conscious choice if it should also be in the scoped object or not

added this to the 1.4.x milestone on Sep 28, 2021
removed
use casenot really a feature or a bug; can be support for new DB features or user use cases not anticipated
on Sep 28, 2021
zzzeek

zzzeek commented on Sep 28, 2021

@zzzeek
Member

OK, we can flip our existing tests to use ignore list instead if you want to try that.

self-assigned this
on Sep 28, 2021
sqla-tester

sqla-tester commented on Sep 28, 2021

@sqla-tester
Collaborator

Federico Caselli has proposed a fix for this issue in the master branch:

Add missing methods added in 🎫6991 https://gerrit.sqlalchemy.org/c/sqlalchemy/sqlalchemy/+/3112

sqla-tester

sqla-tester commented on Feb 27, 2023

@sqla-tester
Collaborator

Grey Li referenced this issue:

Add separate version notes for scalars https://gerrit.sqlalchemy.org/c/sqlalchemy/sqlalchemy/+/4470

3 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingorm

Type

No type

Projects

No projects

Relationships

None yet

    Development

    No branches or pull requests

      Participants

      @zzzeek@sqla-tester@CaselIT@Bechma

      Issue actions

        scalars for async scope session · Issue #7103 · sqlalchemy/sqlalchemy