-
-
Notifications
You must be signed in to change notification settings - Fork 813
Description
Say I have a /databases/ directory with multiple sqlite db files in that dir (1.db & 2.db) and an inspect-data.json file.
If I start datasette via datasette -h 0.0.0.0 /databases/ then the resulting databases are set to is_mutable: true as inspected via http://127.0.0.1:8001/-/databases.json
I don't want to have to list out the databases by name, e.g. datasette -i /databases/1.db -i /databases/2.db as i want the system to autodetect the sqlite dbs i have in the configuration directory
According to the docs outlined in https://docs.datasette.io/en/latest/settings.html?highlight=immutable#configuration-directory-mode this should be possible
inspect-data.jsonthe result of running datasette inspect - any database files listed here will be treated as immutable, so they should not be changed while Datasette is running
I believe that if the inspect-json.json file present, then in theory the databases will be automatically set to immutable via this code
Lines 211 to 216 in 9603d89
| inspect_data = json.load((config_dir / "inspect-data.json").open()) | |
| if immutables is None: | |
| immutable_filenames = [i["file"] for i in inspect_data.values()] | |
| immutables = [ | |
| f for f in self.files if Path(f).name in immutable_filenames | |
| ] |
However it appears the Click Multiple Options will return a tuple via
Lines 311 to 317 in 9603d89
| @click.option( | |
| "-i", | |
| "--immutable", | |
| type=click.Path(exists=True), | |
| help="Database files to open in immutable mode", | |
| multiple=True, | |
| ) |
The resulting tuple is passed to the Datasette app via kwargs and overrides the behaviour to set the databases to immutable via this arg
Line 182 in 9603d89
| immutables=None, |
If you think this is a bug and needs fixing, I am willing to make a PR to check for the empty immutable tuple before calling the Datasette class initializer as I think leaving that class interface alone is the best path here.
Thoughts?
Also - i'm loving Datasette, it truly is a wonderful tool, thank you :)