Skip to content

Fix bug metadata named params #460

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

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "vscode-couchbase",
"displayName": "Couchbase",
"description": "",
"version": "2.2.7",
"version": "2.2.8",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These numberings are too confusing. Plus we need to start from 2.2.4 (Whatever was last release version)

"engines": {
"vscode": "^1.63.1"
},
Expand Down Expand Up @@ -1410,7 +1410,7 @@
"type": "object",
"additionalProperties": {
"type": "string",
"value": "string"
"value": ["string", "number", "boolean", "object", "array"]
},
"title": "User Named Parameters",
"default": {},
Expand Down
2 changes: 1 addition & 1 deletion src/commands/documents/getDocumentMetaData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const getDocumentMetaData = async (node: DocumentNode, context: vscode.Ex
if (hasQueryService(connection.services)) {
try {
result = await connection.cluster?.query(
`SELECT META(b).* FROM \`${node.bucketName}\`.\`${node.scopeName}\`.\`${node.collectionName}\` b WHERE META(b).id = \"${node.documentName}\"`
`SELECT META(b) as meta, XATTRS(b) as xattrs FROM \`${node.bucketName}\`.\`${node.scopeName}\`.\`${node.collectionName}\` b WHERE META(b).id = "${node.documentName}"`
);
result = result?.rows;
} catch {
Expand Down
3 changes: 1 addition & 2 deletions src/types/IKeyValuePair.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@

export interface IKeyValuePair{
key: string;
value: string;
value: any;
}

16 changes: 14 additions & 2 deletions src/util/namedParameters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,25 @@ import path from 'path';
export function getUsersNamedParameters(): IKeyValuePair[] {
try {
let config = vscode.workspace.getConfiguration('couchbase');
let userNamedParametersObject = config.get<{ [key: string]: string }>('workbench.userNamedParameters');
let userNamedParametersObject = config.get<{ [key: string]: any }>('workbench.userNamedParameters');
if (!userNamedParametersObject) {
return [];
}
let userNamedParameters: IKeyValuePair[] = Object.entries(
userNamedParametersObject
).map(([key, value]) => ({ key, value }));
).map(([key, value]) => {
// Non string returned as is
if (typeof value !== 'string') {
return { key, value };
}
try {
const parsedValue = JSON.parse(value);
return { key, value: parsedValue };
} catch (e) {
// Default to returning the string value if JSON parsing fails
return { key, value };
}
});
return userNamedParameters;
} catch (error) {
console.log("Error reading userNamedParameters from config:", error);
Expand Down
Loading