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

Dude, Where's My bool? #583

Open
miklevin opened this issue Nov 20, 2024 · 1 comment
Open

Dude, Where's My bool? #583

miklevin opened this issue Nov 20, 2024 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@miklevin
Copy link

Describe the bug

Auto create-table fails on bool fields. System thinks field name is bool value (True)

(bool broke)

Debugging table schemas:

task schema:
id: <class 'int'> (<class 'type'>)
title: <class 'str'> (<class 'type'>)
done: <class 'bool'> (<class 'type'>)
priority: <class 'int'> (<class 'type'>)
profile_id: <class 'int'> (<class 'type'>)
pk: id (<class 'str'>)
Traceback (most recent call last):
File "/home/mike/repos/botifython/botifymograph.py", line 2147, in
app, rt, (tasks, Task) = debug_fast_app(
^^^^^^^^^^^^^^^
File "/home/mike/repos/botifython/botifymograph.py", line 2142, in debug_fast_app
result = fast_app(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/mike/repos/botifython/.venv/lib/python3.11/site-packages/fasthtml/fastapp.py", line 84, in fast_app
dbtbls = [_get_tbl(db.t, k, v) for k,v in tbls.items()]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/mike/repos/botifython/.venv/lib/python3.11/site-packages/fasthtml/fastapp.py", line 84, in
dbtbls = [_get_tbl(db.t, k, v) for k,v in tbls.items()]
^^^^^^^^^^^^^^^^^^^^
File "/home/mike/repos/botifython/.venv/lib/python3.11/site-packages/fasthtml/fastapp.py", line 16, in _get_tbl
if tbl not in dt: tbl.create(**schema)
^^^^^^^^^^^^^^^^^^^^
File "/home/mike/repos/botifython/.venv/lib/python3.11/site-packages/fastlite/kw.py", line 80, in create
return self._orig_create(
^^^^^^^^^^^^^^^^^^
File "/home/mike/repos/botifython/.venv/lib/python3.11/site-packages/sqlite_minutils/db.py", line 1645, in create
self.db.create_table(
File "/home/mike/repos/botifython/.venv/lib/python3.11/site-packages/sqlite_minutils/db.py", line 997, in create_table
sql = self.create_table_sql(
^^^^^^^^^^^^^^^^^^^^^^
File "/home/mike/repos/botifython/.venv/lib/python3.11/site-packages/sqlite_minutils/db.py", line 876, in create_table_sql
column_type=COLUMN_TYPE_MAPPING[column_type],
~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^
KeyError: True

Minimal Reproducible Example

# Debug wrapper
def debug_fast_app(*args, **kwargs):
    print("\nDebugging table schemas:")
    for k, v in kwargs.items():
        if isinstance(v, dict) and 'pk' in v:  # This identifies our table schemas
            print(f"\n{k} schema:")
            for field, type_ in v.items():
                print(f"  {field}: {type_} ({type(type_)})")
    
    result = fast_app(*args, **kwargs)
    return result


app, rt, (tasks, Task) = debug_fast_app(
    "data/data.db",
    live=True,
    task={
        "id": int,
        "title": str,
        "done": bool,
        "priority": int,
        "profile_id": int,
        "pk": "id"
    }
)

Expected behavior
Table to be created

Environment Information
FAILS ON FASTHTML VERSIONS 0.7.0 to 0.10.0

Name: fastlite
Version: 0.0.13

Name: fastcore
Version: 1.7.20

Name: python-fasthtml
Version: 0.10.0

THE VERSION IT WORKS UNDER <-- Pinning to 0.6.14 (at the latest) fixes

Name: fastlite
Version: 0.0.13

Name: fastcore
Version: 1.7.20

Name: python-fasthtml
Version: 0.6.14

Confirmation
Please confirm the following:

  • [ yes siree ] I have read the FAQ (https://docs.fastht.ml/explains/faq.html)
  • [ todo... done! ] I have provided a minimal reproducible example
  • [ meticulously, including cutoff where it broke ] I have included the versions of fastlite, fastcore, and fasthtml
  • [ and I thank you profusely ] I understand that this is a volunteer open source project with no commercial support.

Additional context
Impossible to believe I'm the only one encounterng / reporting as it is THE use case example.

@miklevin miklevin added the bug Something isn't working label Nov 20, 2024
@jph00
Copy link
Contributor

jph00 commented Nov 22, 2024

@pydanny @audreyfeldroy would you like to look at this one?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants