Skip to content

Correct query return types #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Oct 29, 2021
Merged

Conversation

andrew-chang-dewitt
Copy link
Contributor

Changes:

  • Fix client query_and_return return type.

    Client has no knowledge of what the return type is or should be. Fixed
    to return RealDictRow & removed the T TypeVar from sync_client.

  • Fix CRUD method return types.

    Previously, the built-in methods on the CRUD objects were returning the
    raw data from the Client's execute_and_return() method, of type
    RealDictRow from psycopg2.extras. Now each CRUD object also requires
    a return type object of type Type[T] to be passed as a second argument
    on initialization, which is then used to initialize a return type object
    from the db query results (i.e. an instance of ModelData) to be
    returned.

  • Also generalizes model.base.ensure_exactly_one() to accept any list
    object.

Previously, the built-in methods on the CRUD objects were returning the
raw data from the Client's `execute_and_return()` method, of type
`RealDictRow` from `psycopg2.extras`. Now each CRUD object also requires
a return type object of type `Type[T]` to be passed as a second argument
on initialization, which is then used to initialize a return type object
from the db query results (i.e. an instance of `ModelData`) to be
returned.

Also generalizes `model.base.ensure_exactly_one()` to accept any list
object.

Also removes unnecessary type imports.
Client has no knowledge of what the return type is or should be. Fixed
to return `RealDictRow` &  removed the T TypeVar from sync_client.
@andrew-chang-dewitt andrew-chang-dewitt merged commit a09016c into main Oct 29, 2021
@andrew-chang-dewitt andrew-chang-dewitt deleted the correct_query_return_types branch October 29, 2021 21:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant