From b7117d11a4b182d7e2843846a65dfc31010c4e4f Mon Sep 17 00:00:00 2001 From: Dinar Gaskarov <72319713+x1Katari@users.noreply.github.com> Date: Sat, 26 Aug 2023 20:30:16 +0400 Subject: [PATCH] Fixed creation of a copy of all table entries in the get endpoint. --- project/app/main.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/project/app/main.py b/project/app/main.py index b4d68ae..b6af69c 100644 --- a/project/app/main.py +++ b/project/app/main.py @@ -17,8 +17,7 @@ async def pong(): async def get_songs(session: AsyncSession = Depends(get_session)): result = await session.execute(select(Song)) songs = result.scalars().all() - return [Song(name=song.name, artist=song.artist, year=song.year, id=song.id) for song in songs] - + return songs @app.post("/songs") async def add_song(song: SongCreate, session: AsyncSession = Depends(get_session)): @@ -26,4 +25,4 @@ async def add_song(song: SongCreate, session: AsyncSession = Depends(get_session session.add(song) await session.commit() await session.refresh(song) - return song \ No newline at end of file + return song