Skip to content

Commit

Permalink
fixes #16
Browse files Browse the repository at this point in the history
  • Loading branch information
jph00 committed Aug 15, 2024
1 parent 20e2073 commit c7336cb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion fastlite/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ def _get_flds(tbl):
def _dataclass(self:Table, store=True, suf='')->type:
"Create a `dataclass` with the types and defaults of this table"
res = make_dataclass(self.name.title()+suf, _get_flds(self))
flexiclass(res)
if store: self.cls = res
return res

Expand Down Expand Up @@ -154,7 +155,7 @@ def create(
strict=False, # Apply STRICT mode to table
):
"Create table from `cls`, default name to snake-case version of class name"
mk_dataclass(cls)
flexiclass(cls)
if name is None: name = camel2snake(cls.__name__)
typs = {o.name: o.type for o in fields(cls)}
res = self.create_table(
Expand Down
5 changes: 3 additions & 2 deletions nbs/00_core.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,7 @@
"def _dataclass(self:Table, store=True, suf='')->type:\n",
" \"Create a `dataclass` with the types and defaults of this table\"\n",
" res = make_dataclass(self.name.title()+suf, _get_flds(self))\n",
" flexiclass(res)\n",
" if store: self.cls = res\n",
" return res\n",
"\n",
Expand Down Expand Up @@ -770,7 +771,7 @@
" strict=False, # Apply STRICT mode to table\n",
"):\n",
" \"Create table from `cls`, default name to snake-case version of class name\"\n",
" mk_dataclass(cls)\n",
" flexiclass(cls)\n",
" if name is None: name = camel2snake(cls.__name__)\n",
" typs = {o.name: o.type for o in fields(cls)}\n",
" res = self.create_table(\n",
Expand All @@ -797,7 +798,7 @@
{
"data": {
"text/plain": [
"Cat(id=1, name=None, age=None, city='Unknown')"
"Cat(id=1, name=UNSET, age=UNSET, city='Unknown')"
]
},
"execution_count": null,
Expand Down

0 comments on commit c7336cb

Please sign in to comment.