Skip to content

Implement SQLResult #9

@ilevkivskyi

Description

@ilevkivskyi

A user should be able to annotate an argument/variable that is expected to take rows of a specific table/join/etc. For example:

class BasicData(SQLResult):
    id: int
    name: str

We can also support a Python 2 compatible syntax like for named tuples. This type should be added to an actual tiny runtime package that will be shipped with stubs/plugins. This should be accompanied by
at least two plugin hooks:

  • One type analyzer hook that will transform an occurrence BasicData into something like SQLResult[TypedDict(x=int, name=str)] (SQLResult should be declared a subclass of RowProxy)
  • Another hook for attribute access, so that SQLResult will provide both NamedTuple- and TypedDict-like APIs (to match runtime magic).

Note that SQLResult, Iterable[SQLResult] can be used as a more precise result for some functions in #4.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions