Closed greatlaki closed 6 months ago
I've tried to reproduce, but you didn't provide full code to reproducer error. I've tried using
# user model
class TestUserModel(Base):
__tablename__ = "TestUserModelTable"
id = Column(Integer(), primary_key=True)
email = Column(Unicode(200))
password = Column(Unicode(200))
hashed_password = Column(Unicode(200))
# factory model
class TestUserModelFactory(AsyncSQLAlchemyFactory):
class Meta:
model = models.TestUserModel
sqlalchemy_session = sc_session
id = factory.Sequence(lambda n: n)
email = factory.Sequence(lambda n: "text%s" % n)
password = factory.Sequence(lambda n: "password%s" % n)
@classmethod
def _create(cls, model_class, *args, **kwargs):
kwargs['hashed_password'] = kwargs.pop("password")
return super()._create(model_class, *args, **kwargs)
# user creation test
async def test_user_creation(db_session):
test_user = await TestUserModelFactory(password="password")
found_user = (await db_session.execute(sqlalchemy.select(TestUserModel).filter_by(id=test_user.id))).scalars().one()
assert found_user.id == test_user.id
assert found_user.hashed_password == test_user.hashed_password
It did work.
@kuzxnia, I think that you didn't use two libs to reproduce my bug. What else should I provide?
fastapi = "^0.103.2"
fastapi-users = {extras = ["sqlalchemy"], version = "^12.1.2"}
You're correct, I overlooked that. While I'm unable to debug and provide support for every SQLAlchemy wrapper library individually, I recommend reaching out to the maintainers of fastapi-users or the SQLAlchemy community for assistance. Feel free to ask if you have any other questions. Apologies and thank you!
Okay, thank you for the information
On Fri, Feb 9, 2024 at 1:23 AM Kacper Kuźniarski @.***> wrote:
You're correct, I overlooked that. While I'm unable to debug and provide support for every SQLAlchemy wrapper library individually, I recommend reaching out to the maintainers of fastapi-users or the SQLAlchemy community for assistance. Feel free to ask if you have any other questions. Apologies and thank you!
— Reply to this email directly, view it on GitHub https://github.com/kuzxnia/async_factory_boy/issues/7#issuecomment-1935028061, or unsubscribe https://github.com/notifications/unsubscribe-auth/AU2W2ZX47H43DSZ3G3274YLYSVF6XAVCNFSM6AAAAABCOBP3ECVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMZVGAZDQMBWGE . You are receiving this because you authored the thread.Message ID: @.***>
pytohn =3.11.4 fastapi = "^0.103.2" async-factory-boy = "^1.0.1" fastapi-users = {extras = ["sqlalchemy"], version = "^12.1.2"}
Here is my settings for testing FastApi app
I tried to test user login
As a result is endless execution creating an instance
the part of library code (async_factory_boy.factory.sqlalchemy.AsyncSQLAlchemyFactory.create)