-
-
Notifications
You must be signed in to change notification settings - Fork 336
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
Implement showing and changing a column's type #498
Comments
Please assign this to me, @kgodey |
I have some suggestions in regards to the implementation. Figma linked in the wiki wasn't very helpful, unfortunately. If I shouldn't be asking this here, let me know.
|
@asharonbaltazar could you elaborate on Figma not being helpful? it's a clickable prototype that shows you different actions you can take, and there should indeed be list of types in the column dropdown. Here are some screenshots I took from the prototype: |
Oh, sorry about that. I was referring to the Figma linked in the Working with Columns wiki page. Thank you for this. |
@asharonbaltazar This is the same Figma prototype linked from the page. :). Let me know if you can't see the interactivity, there's more detail there that's not captured in the screenshots. |
Please assign this to me, @kgodey. |
I'm trying to figure out the broad algorithm of changing a type from frontend's perspective. As I see it at the moment:
Does that sound right? Also, am I right in assuming that You'll notice, I introduced the term default target DB-layer type to describe what is the default DB-layer type when switching a column to some Mathesar type. It's essetially the information needed to request the backend to change a column's type (since the backend expects DB-layer types, but user is dealing in Mathesar types). The What I'm getting at is that the Mathesar type construct has these two parts, mapping of DB-layers to it and mapping of it to DB-layers, but at the moment only one of them is formally defined. A simple fix could be to add a
But, there could be valid reasons to keep Mathesar type descriptions on the frontend, like letting the user change the default target type or a more over-arching architectural choice to not use Mathesar types on the backend. In fact, I think @kgodey mentioned somewhere that Mathesar types are owned by the web service, which means the frontend, right? Either way, concerning the definition of a Mathesar type (what it means to convert from and to it) it would be intuitive to keep it all in one place, either backend or frontend. Also, if we were to centralize Mathesar type information, another bit of it is whether a given Mathesar type can be converted to (conversion to it is implemented). For example, at the moment Number and Text can be converted to. To sum up, I'm proposing to centralize the Mathesar type description and to make some insights into them explicit. |
@dmos62 There are multiple points here. I'll cover them individually. The algorithm on the frontend:The steps you've mentioned is mostly correct. However, we also need to factor in
Options:For the purpose of this issue, we will present the user with all valid choices based on valid_target_types (Not just number and text). Source of truth, for types:I agree with providing the default target type in the API. Essentially, the frontend should not contain any type related checks. Moving forward, all type related information, including icons, conditions to show for filters, grouping options etc., will only be maintained on the backend. The goal is to support addition of dynamic types. If new types are added, there should be no code changes on the frontend. Other types:The db types in 'other' mathesar type will not be presented to the user while switching types. Let me know if this answers all your queries. @kgodey Please take a look to see if I missed something here. |
@pavish you answered my queries. Moving type logic to backendThat brings up another concern. If the backend has all information necessary to fulfil column type conversion requests that are parametrized in Mathesar types, it might be preferable to move that logic to backend. This could be exposed to the frontend together with what is now
Rationale to expose both is the user or frontend might choose to deal in either Mathesar types or DB-layer types depending on circumstance (probably depending on whether fine grained type control is desired). Then the PATCH Location of valid target types declarationAt the moment
I suspect there's plans to make valid target types column-specific, so this last point might be moot. PSI'm slightly self-conscious about suggesting refactors and, for example, pushing work to backend, given that I'm a new contributor and was invited to work on a smaller scope issue than what we're discussing now. I'm aware that social norms might dictate more timidity on my part at this point, but I'm working under the assumption that I can be more helpful if I forego that. I hope that my proposals or insights are useful. That said if this leads to work on the backend, I'd be happy to do it. |
@dmos62 We work incrementally, and often come up with refactors and new ideas with the entire scope of a feature, while implementing a smaller portion. Suggesting refactors and bringing in a new perspective is more than welcome :) Regarding your points: Moving type logic to backendI do not think it is essential to provide both
Location of valid target types declaration
|
Central issue seems to be whether or not Mathesar types are specific to the frontend. If they are, backend ideally wouldn't be aware of them (and wouldn't hold related definitions). If they aren't specific to the frontend, it would be desirable to centralize the definitions and logic on the backend. The situation I'm trying to side-step is where we have logic and definitions split between front and back ends. |
@dmos62 The logic and definitions are supposed to be only on the backend, as mentioned earlier. The only logic portion on the frontend is mapping between the db types -> backend types (bi-directional). This information is also fetched from the backend, nothing is hardcoded on the frontend. I do not see the logic and definition overlap you're mentioning. |
@dmos62 As per your point, fetching this data avoids the overlap.
But, I do not see any co-dependent information split between the frontend and backend here. Could you please elaborate? |
I just caught up on this conversation, the idea of adding a Mathesar types are a convenience that the API provides, they can be used by other clients as well and are not limited to the frontend. However, we do not want clients to have to use Mathesar types, they're simply a convenience to make types friendlier to non-technical users. The eventual idea is that users could plug in their own types in a particular Mathesar instance and create their own mappings between Mathesar types and DB types and the frontend could work with it automatically. Right now, the main problem we haven't solved yet is how to store the logic in the backend for choosing the right DB type when multiple DB types map to a Mathesar type. (e.g. when is a type an |
@pavish If all the information needed for constructing the bi-directional mapping between Mathesar and DB types (which includes the default target DB type) is put in the backend, the overlap between front and back ends is that the backend holds the Mathesar type definitions (information necessary for converting to and from it) and the frontend holds the (sole) logic for using those definitions. Having the definitions on the backend and logic on the frontend is better than having part of the definitions here and part there (ditto for logic), but from what both of you are saying it sounds like there isn't a reason to have any Mathesar-type-related things on the backend. Should I hardcode the contents of the database types endpoint ( |
@dmos62 There are a couple of reasons to have Mathesar type-related things in the backend: It would be best to continue pulling the database type information from the backend (and add the |
@dmos62 All the information needed for the bi-directional mapping, is already in the backend. We don't have to hardcode anything regarding this, on the frontend. The only information we need to hardcode is the |
@kgodey's last comment covers my concerns. @pavish the hardcoding I suggested in the last comment is moving everything Mathesar type related out of the backend and into the frontend. The rationale was that both the Mathesar type information and the conversion logic would be in the same place. I'll see if I can salvage @asharonbaltazar's draft PR. |
Thanks @dmos62. FYI (in case it wasn't clear), implementing the type conversion logic to types other than the |
@dmos62 I hope you're referring to the latest UX. We missed to update the issue description with it. If you could please take a look at the above link,
The information required to implement (1) is provided by the backend, except the icon, and I hope this covers everything, and that we are on the same page. |
I did miss the latest design. Thanks for catching me up. I think this covers everything 👍 |
@pavish I'm trying to get the database ID. Is the intended way to do that to take the database name, as derived from the URL in |
@dmos62 It can be obtained from the You could create a new method in the file, The current db name, is passed on to each route from |
Problem
Users might want to change the data type of an existing column on their table.
Proposed solution
The "Working with Columns" design spec has a solution for showing and changing column types, which we need to implement on the frontend.
Please note that we're only implementing changing the Mathesar data type in this milestone. Options specific to individual data types will be implemented in the next milestone.
Number data types should save as
NUMERIC
.Text data types should save as
VARCHAR
.Date/time data types can be disabled for now since they're not fully implemented on the backend.
Additional context
The text was updated successfully, but these errors were encountered: