-
Notifications
You must be signed in to change notification settings - Fork 23
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
More intelligent migrations #1197
base: master
Are you sure you want to change the base?
Conversation
Love what you're doing with these, @Dhghomon. A few things I wanted to ask about:
In this instance, Not sure if a cast using Note unrelated to this example: as I'm going through the migration questionnaire, it occurs to me it would be really great to see a few lines of context from the SDL as I'm being asked the questions. Instead, I'm flipping back and forth between tabs so I can cross-reference what it's asking me about.
Same feedback as the previous question regarding array vs. set functions. The suggestion here doesn't work without user modification. I think that's intentional. If it is, I might prefer leaving it blank to avoid suggesting we've provided something that may just work. (This could be feedback on the previous question as well now that I think about it. Maybe we need to consider how we feel more generally about providing a default cast expression that requires modification versus giving the user a blank field.) If we want to suggest something here, in this particular context, I think it makes sense to make the default value the property in question. Here's what the theoretical alternative might look like:
Changes here:
My assumption here is that, if you're migrating a given property, its new value is more likely to be based on its current value than on the value of a different, similarly named property. It might also be good to make sure we refer to it as a "link property" in the question. I know we immediately follow "property" with "of link," but even that's long enough for my brain to disconnect and lose the context.
just to be 100% explicit about what the user is dealing with here.
This one didn't suggest a cast at all. It moved right on to the next question. 🤔 Not sure why or what the implications of that are going to be.
The way this one suggests the output against the ambiguity is different from the first example. In the first example, we fill the The more problematic issue with this one is that I changed both the property and the link property, but the output here has not indicated which it's asking me about. I can work backwards and, since I changed one to I went forward and was surprised that it didn't ask about the other change, which was the
Very cool that the user-defined function is suggested! That feels kinda like magic. |
True, looking at the functions that have anytype, anyreal etc. they aren't that useful when it comes down to it. I've slimmed the check down to something simpler that just looks for complete name equality for the input and return types.
Yeah. Maybe the best output when the name of a property is both that of a regular property and a link property is to just default to . but with a note that the user should change it to @ if it refers to a link property. I've changed to that.
This output comes directly from the compiler on the non-Rust side so maybe it could be changed there in the future. I agree that it would be nice to be a tad more explicit.
Yeah! Was interesting to poke through queries on schema::Function for this and see that the user-defined ones show up in the exact same way as the rest. |
Resolves #1188 as well as adds two more improvements: checking if a cast will even work in the first place, and looking for any helpful functions to do the job if not.
prompt_id
be relied on or might it change in the future?Current behaviour: when a property is changed to a new scalar type, the CLI will simply suggest a cast from the old type to the new type. This will often work but not every scalar type can be cast into another scalar type, plus it doesn't recognize when a property is a link property and requires @ instead of . (which is what 1188 above is about).
New behaviour:
Now here's the part I'm looking for feedback on:
Right now the old-to-new pointer logic is done inside a function that only has access to
required_user_input
, which only has the following:// "required_user_input": [
// {
// "prompt": "Please specify a conversion expression to alter the type of property 'strength'",
// "new_type": "std::str",
// "old_type": "std::int64",
// "placeholder": "cast_expr",
// "pointer_name": "strength",
// "new_type_is_object": false,
// "old_type_is_object": false
// }
So with that you can do a query on whether the type name matches regular or link properties somewhere inside the schema, but not necessarily for the current type being modified. That means that if there is a duplicate name anywhere in the schema the user will still get the output asking them to make a choice between . and @.
This could be improved by passing on the entire Proposal output, which looks like this:
// Example:
//
// "proposed": {
// "prompt": "did you alter the type of property 'strength' of link 'times'?",
// "data_safe": false,
// "prompt_id": "SetPropertyType PROPERTY default::|strength@default|||times&default||Time",
// "confidence": 1.0,
// "statements": [
// {
// "text": "ALTER TYPE default::Time {\n ALTER LINK times {\n ALTER PROPERTY strength {\n SET TYPE std::str USING (\(cast_expr));\n };\n };\n};"
// }
I'm curious how set in stone the output for
prompt_id
is. If it is then it could be used, but if future output from the server might change then best not to pass it on.Schema to try out changes: