-
-
Notifications
You must be signed in to change notification settings - Fork 317
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
Extend column API to support duplicating columns #452
Comments
We'll need to have the ability to create any column at a specified index to accomplish this. Currently, added columns are placed to the right of the currently-existing columns. At the DB layer, the norm for viewing columns in a particular order is to use a view. I think we should avoid calling some views tables in the UI (and calling others views). This is quite non-trivial to implement, since column order isn't usually a "controlled" part of a table definition. |
@mathemancer Thanks! I updated the issue to remove the reference to creating it at a specific index. We can figure out creating a column at a specific position later if that's something people want to do. |
Should this only copy data, or would we also like to preserve constraints? Also, what should the naming scheme look like? I'm imagining just |
Good questions! |
W.r.t. preserving constraints: Should this include
Should the last row above be prevented from insert by the new constraint?
|
I think copying constraints means that
Yes, it should, because it violates Separately, now that I think about it more, I think it would be good for the function to take an argument about copying constraints. That way, we can have an option in the UI that allows the user to copy constraints or not. I think copying data should also be toggled by an argument. |
What would not copying data look like? Set nullable to true and just copy constraints? |
@eito-fis Yes, copy the data type and constraints and set nullable to true if needed. Once we have column-specific formatting/display options, those should copy over too. |
I've started writing code for this, which has brought up some additional questions:
|
(1) I think we shouldn't try to get similar behavior by using other constraints since that's not duplicating the column. It's probably better to have a warning in the UI saying that we won't duplicate the PK constraint. (2) No, just copy unique and not-null constraints for now. |
Problem
The design spec for Working with Columns calls for the ability to duplicate a column.
Proposed solution
The Column creation endpoint should be extended to accept a reference to a another column in the same table. If this parameter is passed in, it should create a new column that's a copy of the column that has been passed in. All data in the column should also be copied.
Additional context
The text was updated successfully, but these errors were encountered: