- GINO version: 1.0.0 and 1.0.1
- GINO-Starlette: 0.1.1
- Python version: 3.8.2
- asyncpg version: 0.20.1
- aiocontextvars version: 0.2.2
- PostgreSQL version: PostgreSQL 11.8 (Ubuntu 11.8-1.pgdg20.04+1) on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 9.3.0-10ubuntu2) 9.3.0, 64-bit
Description
The bake attribute/ the bakery is missing from the gino.ext.starlette.Gino object. This raises an error if an query should be baked with `db.bake (db = Gino(app, dsn=Config.DATABASE_URL) and db is connected). Schema declaration and normal queries/ updates/ create are fully functional.
What I Did
This block is executed after the init of app and db on startup.
async def connect():
from app import app, db
from app.models import (Game, PlayerGames, Player, Role,
PlayerRoles, State, GameStates)
app.engine = await db.set_bind(Config.DATABASE_URL)
app.baked = Ctx()
await db.gino.create_all()
app.logger.info("Database created and connected")
# At this point 'bake' is also not in dir(db)
async def QueryBake():
from app import app, db
from app.models import Player, PlayerGames, Role, PlayerRoles, Game
# User.get_roles() query
query = Role.outerjoin(PlayerRoles).outerjoin(Player)
query = query.select().where(
PlayerRoles.player_id == db.bindparam("uid")
)
loader = Role.distinct(Role.id).load(
add_parent=Player.distinct(Player.id)
)
app.baked.role_query = db.bake(
query.execution_options(loader=loader)
)
Traceback:
´bash ERROR: Traceback (most recent call last): File "/home/username/P/boardgame-backend/venv/lib/python3.8/site-packages/starlette/routing.py", line 517, in lifespan await self.startup() File "/home/username/P/boardgame-backend/venv/lib/python3.8/site-packages/starlette/routing.py", line 494, in startup await handler() File "/home/username/P/boardgame-backend/app/config.py", line 73, in QueryBake app.baked.role_query = db.bake( AttributeError: 'Gino' object has no attribute 'bake' ´
Description
The bake attribute/ the bakery is missing from the
gino.ext.starlette.Ginoobject. This raises an error if an query should be baked with `db.bake (db = Gino(app, dsn=Config.DATABASE_URL) and db is connected). Schema declaration and normal queries/ updates/ create are fully functional.What I Did
This block is executed after the init of app and db on startup.
Traceback:
´bash ERROR: Traceback (most recent call last): File "/home/username/P/boardgame-backend/venv/lib/python3.8/site-packages/starlette/routing.py", line 517, in lifespan await self.startup() File "/home/username/P/boardgame-backend/venv/lib/python3.8/site-packages/starlette/routing.py", line 494, in startup await handler() File "/home/username/P/boardgame-backend/app/config.py", line 73, in QueryBake app.baked.role_query = db.bake( AttributeError: 'Gino' object has no attribute 'bake'´