Home > database >  Disable Schema Validation for Cosmos DB?
Disable Schema Validation for Cosmos DB?

Time:02-11

I'm using Cosmos DB in Azure. I recently changed the schema to add more information. However, I'm confused because Cosmos uses SQL to query the database. Further, it seems I can't query based on the new schema because I receive the following error messsage:

 Message: {"errors":[{"severity":"Error","location":{"start":22,"end":29},"code":"SC2001","message":"Identifier 'comment' could not be resolved."}]}

So I'm wondering is it possible to disable schema validation so I can query on the new comment attribute, without getting this error message.

Further, I'm confused how Cosmos DB can be considered a NoSQL database if it behaves much the same as MySQL.

Edit: The query I am using is

SELECT * FROM c
WHERE comment = ""

CodePudding user response:

The error is not related to the schema, the error is saying your query is incorrectly written.

Following the official documentation (for example, https://docs.microsoft.com/azure/cosmos-db/sql/sql-query-getting-started#query-the-json-items)

The query should be:

SELECT * FROM c
WHERE c.comment = ""

Keep in mind that that query is not checking for documents that do not have the comment property, it's basically filtering documents that do have the comment property with an empty string value.

  • Related