mirror of
https://github.com/mealie-recipes/mealie.git
synced 2026-02-27 02:03:13 -05:00
prs-fleshgolem-2070: feat: sqlalchemy 2.0 (#2096)
* upgrade sqlalchemy to 2.0 * rewrite all db models to sqla 2.0 mapping api * fix some importing and typing weirdness * fix types of a lot of nullable columns * remove get_ref methods * fix issues found by tests * rewrite all queries in repository_recipe to 2.0 style * rewrite all repository queries to 2.0 api * rewrite all remaining queries to 2.0 api * remove now-unneeded __allow_unmapped__ flag * remove and fix some unneeded cases of "# type: ignore" * fix formatting * bump black version * run black * can this please be the last one. okay. just. okay. * fix repository errors * remove return * drop open API validator --------- Co-authored-by: Sören Busch <fleshgolem@gmx.net>
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
from collections.abc import Sequence
|
||||
from functools import cached_property
|
||||
|
||||
from sqlalchemy import select
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from mealie.db.models.group import Group, GroupMealPlan, ReportEntryModel, ReportModel
|
||||
@@ -70,13 +72,16 @@ PK_GROUP_ID = "group_id"
|
||||
|
||||
|
||||
class RepositoryCategories(RepositoryGeneric[CategoryOut, Category]):
|
||||
def get_empty(self):
|
||||
return self.session.query(Category).filter(~Category.recipes.any()).all()
|
||||
def get_empty(self) -> Sequence[Category]:
|
||||
stmt = select(Category).filter(~Category.recipes.any())
|
||||
|
||||
return self.session.execute(stmt).scalars().all()
|
||||
|
||||
|
||||
class RepositoryTags(RepositoryGeneric[TagOut, Tag]):
|
||||
def get_empty(self):
|
||||
return self.session.query(Tag).filter(~Tag.recipes.any()).all()
|
||||
def get_empty(self) -> Sequence[Tag]:
|
||||
stmt = select(Tag).filter(~Tag.recipes.any())
|
||||
return self.session.execute(stmt).scalars().all()
|
||||
|
||||
|
||||
class AllRepositories:
|
||||
|
||||
Reference in New Issue
Block a user