Skip to content
This repository was archived by the owner on Jun 18, 2022. It is now read-only.

query executor in constructor#60

Open
Paul-Ilyin wants to merge 2 commits intopotykion:masterfrom
Paul-Ilyin:query_executor
Open

query executor in constructor#60
Paul-Ilyin wants to merge 2 commits intopotykion:masterfrom
Paul-Ilyin:query_executor

Conversation

@Paul-Ilyin
Copy link
Copy Markdown
Contributor

PR merge checklist:

  • add tests for new functionality if any

  • run poetry install && pre-commit run -a

  • describe changes in CHANGELOG.md with PR/issue reference like so

    ## Unreleased
    
    ### Changed
    
    - `repka.repositories.base.AsyncQueryExecutor.fetch_all` - now returns AsyncIterator (#54 by @Paul-Ilyin)
    - `repka.repositories.base.AsyncQueryExecutor.insert_many` - now returns AsyncIterator (#54 by @Paul-Ilyin)
    
  • ensure build passed

Надо подумать над названием, пока ниче кроме Repository не придумал

from repka.repositories.base import GenericIdModel, AsyncBaseRepo, AsyncQueryExecutor


class Repository(AsyncBaseRepo[GenericIdModel], ABC):
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А че этот класс дает? Как мокать AiopgRepository? Там же по-прежнему коннекшн на вход

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

всм коннекшен? Там не коннекшен, там query_executor:

    def __init__(self, query_executor: AsyncQueryExecutor):
        self._query_executor = query_executor

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Я имел в виду AiopgRepository

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ну, AiopgRepository для обратной совместимости вообще функционально не изменился
А вот в Repository можно уже подставлять произвольный экзекутор, в том числе и мок
То есть, предлагаю юзать Repository в проекте, подставляя нужный экзекутор

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тогда почему бы не перенести конструктор в AsyncBaseRepo и избавится от класса Repository?

    def __init__(self, query_executor: AsyncQueryExecutor):
        self._query_executor = query_executor

Copy link
Copy Markdown
Owner

@potykion potykion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Бля гх чет не отправил коммент

from repka.repositories.base import GenericIdModel, AsyncBaseRepo, AsyncQueryExecutor


class Repository(AsyncBaseRepo[GenericIdModel], ABC):
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тогда почему бы не перенести конструктор в AsyncBaseRepo и избавится от класса Repository?

    def __init__(self, query_executor: AsyncQueryExecutor):
        self._query_executor = query_executor

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants