|     IEEE Xplore Digital Library     |     IEEE Standards     |     IEEE Spectrum     |     More Sites

Verified Commit cd0396a3 authored by Emi Simpson's avatar Emi Simpson
Browse files

[new arch] Minor stylistic changes to the code

parent 4ea9ec54
Pipeline #899 passed with stage
in 53 seconds
......@@ -74,6 +74,7 @@ Backend = NewType('Backend', str)
A `str`-like field exclusively for backends
Url = NewType('Url', str)
A `str`-like field exclusively for URLs
......@@ -67,6 +67,7 @@ class SqlIntegrityError(NamedTuple):
In this way, IntegrityErrors can be used to glean small amounts of information about
the state of the code
error_code: SqlErrorCode
A machine-readable code indicating what type of error this is
......@@ -90,10 +91,12 @@ class QueryResult(NamedTuple):
methods do perform IO under the hood, but for the purposes of the Query, they may as
well just be lazy immutable data.
row_count: int
The number of rows affected by the execution of SQL statement
last_row_id: int
The foreign key of the last row affected by the execution of SQL statement
......@@ -101,6 +104,7 @@ class QueryResult(NamedTuple):
This may not be an `int` where the primary key isn't an `int`. As such, no guarantees
are made about this feild for tables which don't feature an `int` primary key.
next: Callable[[], Optional[Tuple[Any, ...]]]
Retreive the next item in the query results
......@@ -108,10 +112,12 @@ class QueryResult(NamedTuple):
Think of this as a lazy sequence of times. Each call pops one element off of the lazy
all: Callable[[], Sequence[Tuple[Any, ...]]]
Produce a sequence of all records returned by the execution of the query
class QueryRequest(NamedTuple):
A description of a single SQL statement
......@@ -123,6 +129,7 @@ class QueryRequest(NamedTuple):
This is as simple as providing a string containing an SQL statement as well as
arguments to be substituted in
query: str
A string containing a single SQL statement
......@@ -134,6 +141,7 @@ class QueryRequest(NamedTuple):
using concatination or regular string formatting is **very dangerous**. Instead,
prefer to use substitutions using :attr:`args`
args: Tuple[Any, ...] | List[Any]
Arguments to be substituted into :attr:`query`
......@@ -215,6 +223,7 @@ class Unfinished(Generic[T, E]):
**See also:** :meth:`Query.handle_results`
next_query: 'Query[T, E]'
The query that should now be run in place of the original
......@@ -267,6 +276,7 @@ class Query(Protocol[T, E]):
class has no methods for *executing* those statements. If you have a `Query` you want
to run, you'll need a driver, such as :func:`mystic.query_driver.drive_query_to_end()`
def get_query(self) -> QueryRequest:
Describe the next SQL statement necessary for this Query
......@@ -278,6 +288,7 @@ class Query(Protocol[T, E]):
def handle_results(self, results: QueryResult | SqlIntegrityError) -> Finished[T] | Error[E] | Unfinished[T, E]:
Interpret the results of the execution of an SQL statement
......@@ -9,7 +9,6 @@ from typing import Mapping, TypeVar
T = TypeVar('T')
E = TypeVar('E')
def drive_query_to_end(c: Cursor, query: Query[T, E]) -> Finished[T] | Error[E]:
Completely evaluate a query with regards to a real database
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment