-
Notifications
You must be signed in to change notification settings - Fork 9
Cleanup rowid #48
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
base: main
Are you sure you want to change the base?
Cleanup rowid #48
Conversation
5aa095f to
5d70f8a
Compare
jph00
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Danny! My only question is about whether we really want all that code to auto-select 'id' for users. My guess is that we don't, but I might be missing something.
| ) | ||
|
|
||
| column_defs = [] | ||
| # All minidata tables get a primary key: https://docs.fastht.ml/explains/minidataapi.html#creating-tables |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minutils does not support the spec - that's fastlite. We shouldn't add a pk here automatically IMO, unless I'm missing something.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll work to get tests to pass without it.
| columns_to_drop = [ | ||
| column for column in existing_columns if column not in columns | ||
| ] | ||
| # If no primary key was specified and id was added automatically, we prevent |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we can remove this then?
| # Has the primary key changed? | ||
| current_pks = table.pks | ||
| desired_pk = None | ||
| if isinstance(pk, str): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You know, with a ternary op, these 4 lines would be just one line... ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh n/m I see this was just a move of some lines Simon wrote.
| if transform and self[name].exists(): | ||
| table = cast(Table, self[name]) | ||
| should_transform = False | ||
| # Has the primary key changed? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought changing the pk already worked? IIRC I used that feature during development of solveit...
| defaults=defaults, | ||
| pk=pk, | ||
| ) | ||
| # There has been set a primary key that isn't ['id'].It is now safe to drop the ID column. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and remove this.
| "Primary key columns for this table." | ||
| names = [column.name for column in self.columns if int(column.is_pk)] | ||
| if not names: | ||
| names = ["rowid"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we want to force people to not use rowid do we?
| ignore, | ||
| ) | ||
|
|
||
| if isinstance(pk, Union[str, None]): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK so this one could definitely be a ternary op!
Why does this exist?
insert_chunkwas still dependant on last_rowid in non-upsert scenariosWhat this does:
int:idto serve in this roleTests to be done: