Skip to content
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

fix: Revert untyped param type feature #2012

Merged
merged 4 commits into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Prev Previous commit
"fix: revert untyped param types (#1869)"
This reverts commit 6ef44c3.
  • Loading branch information
surbhigarg92 committed Mar 4, 2024
commit 320190094085f0c0c5aca0a0f16b72f7b03ab1bb
15 changes: 0 additions & 15 deletions samples/dml.js
Expand Up @@ -288,21 +288,6 @@ function updateUsingDmlWithStruct(instanceId, databaseId, projectId) {
params: {
name: nameStruct,
},
types: {
name: {
type: 'struct',
fields: [
{
name: 'FirstName',
type: 'string',
},
{
name: 'LastName',
type: 'string',
},
],
},
},
});

console.log(`Successfully updated ${rowCount} record.`);
Expand Down
30 changes: 0 additions & 30 deletions samples/struct.js
Expand Up @@ -111,21 +111,6 @@ async function queryDataWithStruct(instanceId, databaseId, projectId) {
params: {
name: nameStruct,
},
types: {
name: {
type: 'struct',
fields: [
{
name: 'FirstName',
type: 'string',
},
{
name: 'LastName',
type: 'string',
},
],
},
},
};

// Queries rows from the Singers table
Expand Down Expand Up @@ -265,21 +250,6 @@ async function queryStructField(instanceId, databaseId, projectId) {
params: {
name: nameStruct,
},
types: {
name: {
type: 'struct',
fields: [
{
name: 'FirstName',
type: 'string',
},
{
name: 'LastName',
type: 'string',
},
],
},
},
};

// Queries rows from the Singers table
Expand Down
5 changes: 4 additions & 1 deletion src/codec.ts
Expand Up @@ -629,6 +629,10 @@ function getType(value: Value): Type {
return {type: 'bool'};
}

if (is.string(value)) {
return {type: 'string'};
}

if (Buffer.isBuffer(value)) {
return {type: 'bytes'};
}
Expand Down Expand Up @@ -671,7 +675,6 @@ function getType(value: Value): Type {
return {type: 'json'};
}

// String type is also returned as unspecified to allow untyped parameters
return {type: 'unspecified'};
}

Expand Down
5 changes: 1 addition & 4 deletions src/transaction.ts
Expand Up @@ -1300,10 +1300,7 @@ export class Snapshot extends EventEmitter {
if (!is.empty(typeMap)) {
Object.keys(typeMap).forEach(param => {
const type = typeMap[param];
const typeObject = codec.createTypeObject(type);
if (typeObject.code !== 'TYPE_CODE_UNSPECIFIED') {
paramTypes[param] = codec.createTypeObject(type);
}
paramTypes[param] = codec.createTypeObject(type);
});
}

Expand Down