Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

transform keyword doesn't work outside core.ipynb #21

Open
pydanny opened this issue Aug 23, 2024 · 0 comments
Open

transform keyword doesn't work outside core.ipynb #21

pydanny opened this issue Aug 23, 2024 · 0 comments

Comments

@pydanny
Copy link
Contributor

pydanny commented Aug 23, 2024

This script doesn't appear to work:

from fastlite import *

db = Database(':memory:')

print('original')
class User: name: str; age: int
print(User.__annotations__)
users = db.create(User, pk='name')
print(users.__repr__())

print('-'*20)
# Transform!
print('transformation to add pwd:str field')
class User: name: str; age: int; pwd: str
print(User.__annotations__)
users2 = db.create(User, pk='name', transform=True)
print(users2.__repr__())

This should return this string:

original
{'name': <class 'str'>, 'age': <class 'int'>}
<Table user (name, age)>
--------------------
transform
{'name': <class 'str'>, 'age': <class 'int'>, 'pwd': <class 'str'>}
<Table user (name, age, pwd)>

Instead, it returns this:

original
{'name': <class 'str'>, 'age': <class 'int'>}
<Table user (name, age)>
--------------------
transform
{'name': <class 'str'>, 'age': <class 'int'>, 'pwd': <class 'str'>}
<Table user (name, age)> # <----------------------------------------- missing pwd

Additionally, this doesn't work in index.ipynb of this repo. Add this to the bottom cell:

class Cat: id:int; name:str; weight:float; uid:int; breed:str
cats = db.create(Cat, transform=True)
cats

The result that should be returned is missing fields, specifically uid and breed:

<Table cat (id, name, weight)>
@pydanny pydanny changed the title transform keyword doesn't work outside the core.ipynb notebook transform keyword doesn't work outside core.ipynb Aug 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant