simonw / git-history

Tools for analyzing Git history using SQLite
Apache License 2.0
191 stars 18 forks source link

Change how reserved columns work to have an underscore prefix #14

Closed simonw closed 3 years ago

simonw commented 3 years ago

Right now I've implemented it such that id and commit and version and item are reserved columns, and any user-provided data with those columns gets renamed to commit_ and id_ and so-on - see #8.

I've changed my mind. I think this tool's columns should all have a _ prefix instead (like semi-private class properties in Python).

I'm even going to do that for the _id column, mainly so I don't have to explain a special case for id.

simonw commented 3 years ago

I'm also going to change how "banned" columns work. Currently if your data has a item_ column the tool raises an error. The new reserved column will be _item but my rule will be that if your column is reserved I'll add a trailing _ to it - and if you also have a _item_ column I'll rename that to _item__ and so-on.

Current implementation: https://github.com/simonw/git-history/blob/d58f4466ac4fd16f4adc430ab1988ac6508cf3b1/git_history/cli.py#L288-L300

simonw commented 3 years ago

I'm going to split out some of this logic into a utils.py module, and write some separate tests for it.

simonw commented 3 years ago

Well this was a mistake... Datasette treats columns that start with an underscore as querystring parameters it should ignore!

bchydro__item_versions__99_918_rows

Switching to underscore suffixes instead.

simonw commented 3 years ago

... I do like underscore prefixes though. I'm tempted to fix the bug I filed in Datasette instead and keep this:

simonw commented 3 years ago

I released Datasette 0.59.2 with a fix for this, so I'm free to use _id and friends here.