Skip to content

Commit

Permalink
Some adjustments with the change to SQLAlchemy 2
Browse files Browse the repository at this point in the history
Signed-off-by: Aurélien Bompard <[email protected]>
  • Loading branch information
abompard committed Mar 29, 2024
1 parent 6ef11a5 commit 17d4ab0
Show file tree
Hide file tree
Showing 2 changed files with 134 additions and 131 deletions.
4 changes: 2 additions & 2 deletions datanommer.models/datanommer/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ def grep(
return total, page, query
else:
# Execute!
messages = list(session.scalars(query))
messages = session.scalars(query).all()
return total, pages, messages


Expand All @@ -501,7 +501,7 @@ def get_or_create(cls, name):
# If we cache the instance, SQLAlchemy will run this query anyway because the instance
# will be from a different transaction. So just cache the id.
return session.get(cls, cls._cache[name])
obj = session.execute(select(cls).where(cls.name == name)).one_or_none()
obj = session.execute(select(cls).where(cls.name == name)).scalar_one_or_none()
if obj is None:
obj = cls(name=name)
session.add(obj)
Expand Down
Loading

0 comments on commit 17d4ab0

Please sign in to comment.