Project improved and set_columns
from uuid import UUID
from querybuilder.schemas.helper import table
@table
class Person:
id : int # TODO change for UUID here
name : str
age : int
The project over a select should be separated in the following two methods:
-
project
take a variadic list of arguments and call self.column.resolve on each of them. Then check if the obtained list of columns is indeed a strict subset of the set of self.c -
set_columns
take as argument an abitrary list of columns.
The following should hold:
Person.select().project("name") == Person.select().project(1) == Person.select((Person.c.name,))
-
Person.select().project("name", 1)
should raise an error Persone.select().set_column(Person.c[["name", 0, 1, "name"]]) == Person.select(Person.c["name", 0, 1, "name"])