-
Notifications
You must be signed in to change notification settings - Fork 61
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
drop column primitive #210
Conversation
src/db.rs
Outdated
@@ -918,9 +918,45 @@ impl Db { | |||
Self::open_inner(options, OpeningMode::ReadOnly) | |||
} | |||
|
|||
/// Drop a column from the database, optionally changing its options. | |||
/// This shutdown and restart the db in write mode. | |||
pub fn drop_column(&mut self, index: u8, new_options: Option<ColumnOptions>) -> Result<()> { |
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.
This should be called clear_column
, as the column is not really removed. Also, similar to add_column
, this should be an associated function that does not require &self
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.
Btw there is clear_column
in migration.rs:
Line 158 in 084ef6a
pub fn clear_column(path: &Path, column: ColId) -> Result<()> { |
It removes all data without removing the actual column. I think clear_column
for this function too will be confusing.
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 yes, it is basically doing the same thing (I should have use this 🤦 ), there is also one for moving column, will fix that redundancy (and make that if column is at last index and no new option is provided, we remove the column (as your use case is the last number it will be usefull).
I switch to using existing code, and add |
src/db.rs
Outdated
|
||
Ok(()) | ||
} | ||
|
||
fn drop_files_column(options: &mut Options, index: u8) -> Result<()> { |
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.
drop_column_files
or remove_column_files
Great work @cheme. Thank you very much!
Just curious - what does 'truncating a column' means? |
Drop all content index from column, but column still exsists (just cleared and new). Probably the work come to my mind from sql truncate table. |
No rush, but if this is ready for merging I'm eager to use it :) |
published as 0.4.8 |
Could also be refactor to run on options only.
Should allow truncating a column by removing files.
fix #209