-
-
Couldn't load subscription status.
- Fork 122
Description
Creating a table should stash its settings in self._defaults?
I bodged around this in:
See this snippet of suggestion from Gemini 2.5 Flash: https://gist.github.com/simonw/d867a1791b40b3a5fbfb66b75417c0a3#response-2
But really what should happen is that this code here:
sqlite-utils/sqlite_utils/db.py
Lines 1695 to 1713 in 72f6c82
| with self.db.conn: | |
| self.db.create_table( | |
| self.name, | |
| columns, | |
| pk=pk, | |
| foreign_keys=foreign_keys, | |
| column_order=column_order, | |
| not_null=not_null, | |
| defaults=defaults, | |
| hash_id=hash_id, | |
| hash_id_columns=hash_id_columns, | |
| extracts=extracts, | |
| if_not_exists=if_not_exists, | |
| replace=replace, | |
| ignore=ignore, | |
| transform=transform, | |
| strict=strict, | |
| ) | |
| return self |
Should record ALL of the interesting things on self._defaults.
This matters because if you do table = db.table("name_of_table") (where that table does not exist yet) and then call table.insert({...}, pk="id", ...) the table gets created but self._defaults is not updated, so future methods on that table don't know what the settings are.
This differs from if you do:
table = db.insert({...}, pk="id")Because in that case the returned table DOES know it settings (I think, maybe because it can introspect them? Not 100% sure.)