-
-
Notifications
You must be signed in to change notification settings - Fork 323
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
Support for creating a view based on an existing table or view #782
Comments
@ghislaineguerin @pavish @mathemancer @seancolsen @silentninja This issue has been updated and is ready for review. Please look through it and unassign yourself after you've added any feedback that you might have. |
There is no way to save most relevant changes to a pre-existing view at the DB layer. From the docs:
What this means is that you can't drop or add columns in a view without creating a new view, for example, or change the row order, or filter. You can rename the view, and alter some of its other metadata. For most changes to views that I've seen discussed, the only possibility (I can think of; open to other ideas) is to create a new view, silently delete the old one, and attach the service layer model to the new view (thus preserving any service-layer options). I think we'll need to really figure out how to portray this to the user, since some of the failure states will be very confusing if their mental model is "save changes". For example, we may fail to delete the old version of the view because it has dependent objects (or some other reason, but I suspect that would be a common one). Maybe a better way to portray this would be "save view version". So, we'd just keep each view version (we could even rename them automatically in some reasonable fashion). Maybe there could be a service layer marker for which version is "current", and we could have a way to restrict to only showing those. We could also provide help for deleting old versions of views (though for non-materialized views, the space savings are minimal, and we'd want to make sure that users understand they're not really freeing up space by deleting views). Finally, we'd probably want to make sure that we've clearly categorized which changes can be saved to the same view, and which changes would create a new view (or view version). This might be a source of confusion for users. |
There are two types of views, Temporary views and Materialized views, and we should split the uses cases(when we suggest views) based on those. Temporary views should be suggested for most (disposable) use cases and materialized views very rarely as this helps in keeping views lightweight making them really flexible and helpful in a lot of use cases. When it comes to updating, views should be treated as immutable(replaced rather than repaired) due to the reason @mathemancer mentioned. In terms of restful api, updating view should be |
On points 2 through 5 (both inclusive):
I don't think we should prompt the user to create a new view, for these usecases. I do think we should allow creating a view after applying these, however the user should be able to do them on the table/view itself. These operations do not strike sense to me as global settings/at the db level. They would be better suited as user specific settings, which only apply to mathesar clients/api users. We do not have to do it on the backend for the initial release, but we can have it persisted on the browser local storage. |
Let's split the operations on a table based on what the user is planning to do:
Usually, the formats good for writes won't be good for reads and vice versa When using any database based app we don't get the whole table like a spreadsheet and apply modification on top of it, we use So I feel it would be better if we don't touch the table when it comes to reading data(groups and hiding column). Let the table be the actual representation of the truth, let the view do the talking when it comes to data representation the user wants. We are hiding the actual truth when we end up doing a reading operation on a table, we should rather be using the tool that fits the job. To make it convenient for the user, we could let the users do a reading data modification on the table itself, but we should prompt them to create a view to bring in certain advantages like persistence, versioning, sharing, permission |
Regarding the limitations which prevent the user from saving the changes they make to the view:
|
Responding to various comments:
I think this is exactly what we should do. In addition, we should transfer dependent objects from the old view to the new one, and if we cannot do that automatically, then we don't allow the view to be updated.
If we do everything in a single transaction, then there won't be a failure state where the new view has been created but the old view is still floating around. If any operation fails, the whole things fails. Am I missing something here?
This implementation will be for temporary views. We are not dealing with materialized views yet.
This is exactly what we'll be doing.
Agreed, I've updated the issue above to say the user can do that and they need to create a view to save them.
I'm not sure what limitations you're referring to. Users should be able to save changes to views. |
Marking as ready and moving to the backlog. Please feel free to add comments if any of you have additional concerns. |
"Failure state" was the wrong word on my part, sorry. I'm talking about the feedback to the user; If they have no clue what's going on under the hood, it's likely we'll fail sometimes for reasons that make no sense to them: If they get an error message that says "could not update My point is not that we should completely discard the concept of a mutable view, but that if we want that we need to be very conscientious about how we portray the process to the user, and thoughtful about error messages and instructions for how to fix the issue. This is especially tricky since a few metadata associated with views can be updated: name, schema, comment, etc. If we make it seem to the user that adding a column is essentially the same as changing the name, even though the underlying processes are completely different, it seems bound to lead to confusion whenever something unexpected happens. |
There are three occurrences of the text "not be saved" in the ticket description. That's what I'm referring to. I'd expect that if I adjust the filter in a view, I'd have a way to save my new filter settings within the view I already created. It sounds like I won't be able to save those filter adjustments (and other adjustments), and I'd call that a limitation. Are those limitations short-term or long-term? |
Thanks @kgodey that explains it |
Although we are doing work related to this in Cycle 3, this ticket no longer covers accurate design requirements, so I'm going to close it. |
We would like users to use the Views feature if they would like to persist a specific view of their data, such as filters, sorts, groups, column order, etc. The Mathesar UI should prompt users to create a new database view from an existing view or table as needed in these cases.
Creating a view could take the form of:
We should choose one of these options based on the use-case.
Scenarios
Design problems to solve
We have been treating Filters, Sorts, and Groups as the same type of operation, but they are not.
We need to convey this to the user somehow.
Additional context
The text was updated successfully, but these errors were encountered: