View Index Manager should not modify the document name if the namespace is defined

Since the introduction of the namespaced views, passing a document name that starts with “dev_” will automatically set the namespace of the request to development, regardless of the current value.

While I understand the desire to mimic the previous behaviour, I consider this to be a bug because it prevents someone from using a document name starting with “dev_” in production, knowingly.

The simple fix is to also check if the namespace has been defined by the user or not :

if (designDoc.name.startsWith('dev_') && namespace === undefined) {
 // same logic
}

See couchnode/lib/viewindexmanager.ts at master · couchbase/couchnode · GitHub

There’s already a ticket JSCBC-990 (it might be internal only).

Thanks @mreiche . The ticket is vague and I won’t assume you follow the development of every SDK :D. The node sdk already support namespaced views.

There is a compatibility logic that strips the prefix “dev_” from the name if it exists. The idea is good, but it should only apply if we are in a compatibility scenario.