Skip to content

Commit

Permalink
fix: Revert untyped param type feature (#2012)
Browse files Browse the repository at this point in the history
This fix is reverting the feature untyped param type added in [PR](https://togithub.com/googleapis/nodejs-spanner/pull/1869) and released in [7.4.0](https://togithub.com/googleapis/nodejs-spanner/releases/tag/v7.4.0)

This fixes issue #2009 which was introduced by untyped param type feature.
  • Loading branch information
surbhigarg92 authored Mar 4, 2024
1 parent e3abd5f commit 49fa60d
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 420 deletions.
15 changes: 0 additions & 15 deletions samples/dml.js
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Loading

0 comments on commit 49fa60d

Please sign in to comment.