Fix model json conversion (#108)

* Add all fields when converting model to json
* Fix switched image/description in page meta
This commit is contained in:
Nikhil Rao 2022-12-15 01:43:24 -08:00 committed by GitHub
parent 622a8ef3c2
commit 933c3678d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 2 deletions

View File

@ -228,7 +228,9 @@ class App(Base):
component = component if isinstance(component, Component) else component(*args)
# Add the title to the component.
compiler_utils.add_meta(component, title, description, image)
compiler_utils.add_meta(
component, title=title, image=image, description=description
)
# Format the route.
route = utils.format_route(path)

View File

@ -22,6 +22,17 @@ class Model(Base, sqlmodel.SQLModel):
# The primary key for the table.
id: int = sqlmodel.Field(primary_key=True)
def dict(self, **kwargs):
"""Convert the object to a dictionary.
Args:
kwargs: Ignored but needed for compatibility.
Returns:
The object as a dictionary.
"""
return {name: getattr(self, name) for name in self.__fields__}
@staticmethod
def create_all():
"""Create all the tables."""

View File

@ -190,7 +190,7 @@ class Var(ABC):
and hasattr(self.type_, "__fields__")
and name in self.type_.__fields__
):
type_ = self.type_.__fields__[name].type_
type_ = self.type_.__fields__[name].outer_type_
if isinstance(type_, ModelField):
type_ = type_.type_
return BaseVar(