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
db[table].create(..., transform=True) and create-table --transform #468
Conversation
Codecov Report
@@ Coverage Diff @@
## main #468 +/- ##
==========================================
- Coverage 96.60% 96.47% -0.13%
==========================================
Files 6 6
Lines 2590 2640 +50
==========================================
+ Hits 2502 2547 +45
- Misses 88 93 +5
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
The main challenge here is coming up with comprehensive tests. The cases I need to cover are from this block of code: sqlite-utils/sqlite_utils/db.py Lines 1468 to 1480 in c5f8a2e
|
For the moment I'm not going to pay attention to |
Interesting challenge with Introspecting that is a bit tricky: >>> import sqlite_utils
>>> db = sqlite_utils.Database(memory=True)
>>> db["blah"].create({"id": int, "name": str}, not_null=("name",), defaults={"name": "bob"})
<Table blah (id, name)>
>>> db["blah"].columns
[Column(cid=0, name='id', type='INTEGER', notnull=0, default_value=None, is_pk=0), Column(cid=1, name='name', type='TEXT', notnull=1, default_value="'bob'", is_pk=0)] Note how a default value of the Python string So comparing default values from introspecting the database needs me to first parse that syntax. This may require a new table introspection method. |
Just needs documentation now, which can go here: https://sqlite-utils--468.org.readthedocs.build/en/468/python-api.html#explicitly-creating-a-table |
Work in progress. Still needs documentation and tests (and to cover more cases of things that might have changed).
Refs:
📚 Documentation preview 📚: https://sqlite-utils--468.org.readthedocs.build/en/468/