From 8f2704146df7b436127390cf28561ca4961ce8ad Mon Sep 17 00:00:00 2001 From: collerek Date: Wed, 10 Mar 2021 09:12:31 +0100 Subject: [PATCH] remove switch to _row for pg backend --- Makefile | 4 ++-- ormar/models/model_row.py | 5 +---- tests/settings.py | 2 +- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 0995692..721821b 100644 --- a/Makefile +++ b/Makefile @@ -7,13 +7,13 @@ test_pg: export DATABASE_URL=postgresql://username:password@localhost:5432/tests test_pg: docker-compose -f scripts/docker-compose.yml up -d postgres bash scripts/test.sh -svv - docker-compose stop postgres + docker-compose -f scripts/docker-compose.yml stop postgres test_mysql: export DATABASE_URL=mysql://username:password@127.0.0.1:3306/testsuite test_mysql: docker-compose -f "scripts/docker-compose.yml" up -d mysql bash scripts/test.sh -svv - docker-compose stop mysql + docker-compose -f scripts/docker-compose.yml stop mysql test_sqlite: bash scripts/test.sh -svv \ No newline at end of file diff --git a/ormar/models/model_row.py b/ormar/models/model_row.py index 2cd488a..d06d0d9 100644 --- a/ormar/models/model_row.py +++ b/ormar/models/model_row.py @@ -369,9 +369,6 @@ class ModelRow(NewBaseModel): and values are database values :rtype: Dict """ - # databases does not keep aliases in Record for postgres, change to raw row - source = row._row if cls.db_backend_name() == "postgresql" else row - selected_columns = cls.own_table_columns( model=cls, excludable=excludable, alias=table_prefix, use_alias=False, ) @@ -381,6 +378,6 @@ class ModelRow(NewBaseModel): alias = cls.get_column_name_from_alias(column.name) if alias not in item and alias in selected_columns: prefixed_name = f"{column_prefix}{column.name}" - item[alias] = source[prefixed_name] + item[alias] = row[prefixed_name] return item diff --git a/tests/settings.py b/tests/settings.py index fededf3..be1bed2 100644 --- a/tests/settings.py +++ b/tests/settings.py @@ -6,4 +6,4 @@ DATABASE_URL = os.getenv("DATABASE_URL", "sqlite:///test.db") database_url = databases.DatabaseURL(DATABASE_URL) if database_url.scheme == "postgresql+aiopg": # pragma no cover DATABASE_URL = str(database_url.replace(driver=None)) -print('USED DB:', DATABASE_URL) +print("USED DB:", DATABASE_URL)