-
-
Notifications
You must be signed in to change notification settings - Fork 338
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
Add database type alias information to database type endpoint #1037
Comments
I like option 1 because the frontend will have a "canonical" type to default to when a user is creating a new column. |
A couple of quick notes/details:
|
@mathemancer Do you think this is worth reflecting? I think at the moment the only types that are equivalent are By the way, I'd say that |
@dmos62 Those are not the only types that are equivalent, there's also We should use whichever type Postgres uses as canonical as canonical in our API. |
Some examples are:
Maybe more. I really think we should reflect; I'm not sure how else we can be confident we've caught most cases. Edit: @kgodey I don't think we should use |
@mathemancer I guess I didn't recall correctly. We still need a way to let the frontend know that the options for |
I agree that we'd want to reflect this in the long run. But, I'm still suggesting to hardcode it (for the time being), if that will save time in the short run. |
Agreed on hardcoding if it will save time. |
|
Ah okay, then they should not be aliases. |
After looking through the linked PR for this issue, I realized I (we) got distracted by whether we could show aliases, and how to do it, and we forgot to consider whether we should. I think if we're showing two equivalent types to the UI as options for setting the type of a column, that's a bug. We should only show one type string as an option for a given type, and that type string should be the key in the |
I assume this was resolved by the type refactor, closing. |
Problem
We have some db types that are equivalent. In such cases, we want to tell the frontend which of those types is the default or canonical one, so as to prevent it from having to hardcode it. E.g.
DECIMAL
andNUMERIC
are different in the SQL standard, but equivalent in Postgres and thus equivalent in Mathesar.Proposed solution
Off the top of my head I see two approaches:
Define a type alias as being the non-canonical equivalent types and append the following attribute in returned JSON to aliases
'alias-of': 'SOME CANONICAL TYPE'
.Define all equivalent types, canonical and not, as aliases and append an
aliases
attribute containing a list of the rest of the equivalent types to all aliases ('aliases': ['SOME OTHER ALIAS', 'SOME YET ANOTHER ALIAS']
), then on each alias append whether it's canonical or not:'is_canonical_alias': true | false
.This is in part about whether to consider all equivalent types as aliases of one another (e.g.
NUMERIC
andDECIMAL
are aliases of one another), or whether to say that the alias is the non-canonical type, while the canonical type is not the alias of its equivalent types (e.g.NUMERIC
is an alias ofDECIMAL
, but not the other way around). The latter option is less verbose, in that you just add thealias-of
attribute to non-canonicals.Additional context
Proposed here: #1035 (comment)
The text was updated successfully, but these errors were encountered: