-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Schemas endpoint: ignore '_metadata' key, convert 'map' type to Object #256
Schemas endpoint: ignore '_metadata' key, convert 'map' type to Object #256
Conversation
Legacy Parse platform databases have additional fields that database-to-api-response conversion. This commit accounts for - the '_metadata' field, which doesn't appear in the api-response version of Schema, and whose value (an object), crashes the conversion function (which expects only string values) - the 'map' type, which appears in legacy database representations to describe Objects
Good catch! Thank you especially for testing pre-release features. Can you add some tests for these changes? Then I will merge. |
@drew-gross thanks for review! I spent some time looking at how to add tests for this fix. It's tricky because we are testing a case where the data in the database isn't as it would be when created through parse-server. I don't see any examples in the specs of seeding the database with raw data. The testing pain makes me think maybe this fix is at the wrong level. It looks like Schema intends to intercept the |
Hmmm, I think you are right. The schemas API isn't finished yet, so maybe in the schema creation portion of the API, we can add insertion of the The Those are both big jobs, so I'll merge this PR without those tests. If you want to keep working on this, that would be awesome :) otherwise, I'll make sure I write tests for these before we release the schemas API. |
Whoops, looks like there are now some merge conflicts. Could you fix those and then I will merge? |
@wasnotrice updated the pull request. |
Schemas endpoint: ignore '_metadata' key, convert 'map' type to Object
Thanks to everyone working so hard on parse-server!
Legacy Parse platform databases may have additional fields that aren't supported in the current
database-to-api-response conversion. This PR accounts for some discrepancies that appear in schemas created on the Parse platform, and newer schemas created with parse-server. For example, here's a _Role schema created on legacy Parse:
and here's one created with parse-server:
_metadata
field doesn't appear in the api-response versionof Schema. Its value (an object), crashes the conversion function,
because it isn't a string, so it doesn't have a
startsWith
function.object
type. It was added to Schema in Added map to schema object types, fixed expiresAt #87, but it isn't incorporated into the conversion.There may be more exceptions that these, and it may make sense to make the conversion more robust to unexpected values, rather than just adding an exception for
_metadata
. But this seems like a sensible place to start.No tests, because existing tests create objects using parse-server, and those objects don't have the problematic keys. I'd love to add some, but not sure what would be the best approach.