ADO.NET Provider for Couchbase

Build 24.0.9062

AllowJSONParameters

Allows raw JSON to be used in parameters when QueryPassthrough is enabled.

データ型

bool

デフォルト値

false

解説

This option affects how string parameters are handled when using direct N1QL and SQL++ queries through QueryPassthrough. For example, consider this query:

INSERT INTO `bucket` (KEY, VALUE) VALUES ("1", @x)

By default, this option is disabled and string parameters are quoted and escaped into JSON strings. That means that any value can be safely used as a string parameter, but it also means that parameters cannot be used as raw JSON documents:

/*
 * If @x is set to: test value " contains quote
 *
 * Result is a valid query
*/
INSERT INTO `bucket` (KEY, VALUE) VALUES ("1", "test value \" contains quote")

/*
 * If @x is set to: {"a": ["valid", "JSON", "value"]}
 *
 * Result contains string instead of JSON document
*/
INSERT INTO `bucket` (KEY, VALUE) VALUES ("1", "{\"a\": [\"valid\", \"JSON\", \"value\"]})

When this option is enabled, string parameters are assumed to be valid JSON. This means that raw JSON documents can be used as parameters, but it also means that all simple strings must be escaped:

/*
 * If @x is set to: test value " contains quote
 *
 * Result is an invalid query
*/
INSERT INTO `bucket` (KEY, VALUE) VALUES ("1", test value " contains quote)

/*
 * If @x is set to: {"a": ["valid", "JSON", "value"]}
 *
 * Result is a JSON document
*/
INSERT INTO `bucket` (KEY, VALUE) VALUES ("1", {"a": ["valid", "JSON", "value"]})

Please refer to ValidateJSONParameters for more details on how parameters are validated when this option is enabled.

Copyright (c) 2024 CData Software, Inc. - All rights reserved.
Build 24.0.9062