-
Notifications
You must be signed in to change notification settings - Fork 14
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
Schema.newType doesn't add Type to Schema #304
Comments
Using the |
I was looking for usecase where I add type one by one. It looks odd that we do this |
I don't think it's a good idea to change the behavior of the existing Why don't we have an API that modifies a schema in place? If a schema is immutable, then it is safe to share between threads. If schemas are mutable, and a new type has the same name as an existing type (thus replacing it), then we might have to replace all references to that type in every other type that is loaded into the schema system. Are you looking at adding types one by one mixed with validation, or would it work to have a |
That makes sense, immutability will make it easier to share between threads. I tried using
|
Here, I want to create Schema v2 and that's why I start with |
Thanks for this example. You've helped identify an edge case here where a schema with only one top-level Ion value is not being handled correctly. We'll have a fix for this bug soon. |
I'd also like to understand—do you need to be adding the types one by one or could you do something like this?
I know it's not very ergonomic to have to insert the version marker, but we can try to improve that. Even with the extra List, this is still going to be more efficient than using |
We have a usecase to add Type one by one. I started with |
Though, ideally I'd have preferred to just use |
Intuitively, I'd expect Schema.newType() to not just create the type but also register the type to Schema, but it doesn't. For ex: in this test, after I create a Type [email protected], I would expect to get the type when I call Schema.getType("[email protected]") but I get null.
If not this then what is the way to add Type to Schema. The only way I see it to initialize the schema with all the type as construction time itself through
IonSchemaSystem.loadSchema()
orIonSchemaSystem.newSchema()
. Why can't I add type to Schema after creation.The text was updated successfully, but these errors were encountered: