Skip to content

Commit 49fa60d

Browse files
authored
fix: Revert untyped param type feature (#2012)
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.
1 parent e3abd5f commit 49fa60d

File tree

8 files changed

+27
-420
lines changed

8 files changed

+27
-420
lines changed

samples/dml.js

-15
Original file line numberDiff line numberDiff line change
@@ -288,21 +288,6 @@ function updateUsingDmlWithStruct(instanceId, databaseId, projectId) {
288288
params: {
289289
name: nameStruct,
290290
},
291-
types: {
292-
name: {
293-
type: 'struct',
294-
fields: [
295-
{
296-
name: 'FirstName',
297-
type: 'string',
298-
},
299-
{
300-
name: 'LastName',
301-
type: 'string',
302-
},
303-
],
304-
},
305-
},
306291
});
307292

308293
console.log(`Successfully updated ${rowCount} record.`);

samples/struct.js

-30
Original file line numberDiff line numberDiff line change
@@ -111,21 +111,6 @@ async function queryDataWithStruct(instanceId, databaseId, projectId) {
111111
params: {
112112
name: nameStruct,
113113
},
114-
types: {
115-
name: {
116-
type: 'struct',
117-
fields: [
118-
{
119-
name: 'FirstName',
120-
type: 'string',
121-
},
122-
{
123-
name: 'LastName',
124-
type: 'string',
125-
},
126-
],
127-
},
128-
},
129114
};
130115

131116
// Queries rows from the Singers table
@@ -265,21 +250,6 @@ async function queryStructField(instanceId, databaseId, projectId) {
265250
params: {
266251
name: nameStruct,
267252
},
268-
types: {
269-
name: {
270-
type: 'struct',
271-
fields: [
272-
{
273-
name: 'FirstName',
274-
type: 'string',
275-
},
276-
{
277-
name: 'LastName',
278-
type: 'string',
279-
},
280-
],
281-
},
282-
},
283253
};
284254

285255
// Queries rows from the Singers table

src/codec.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -629,6 +629,10 @@ function getType(value: Value): Type {
629629
return {type: 'bool'};
630630
}
631631

632+
if (is.string(value)) {
633+
return {type: 'string'};
634+
}
635+
632636
if (Buffer.isBuffer(value)) {
633637
return {type: 'bytes'};
634638
}
@@ -671,7 +675,6 @@ function getType(value: Value): Type {
671675
return {type: 'json'};
672676
}
673677

674-
// String type is also returned as unspecified to allow untyped parameters
675678
return {type: 'unspecified'};
676679
}
677680

src/transaction.ts

+1-4
Original file line numberDiff line numberDiff line change
@@ -1300,10 +1300,7 @@ export class Snapshot extends EventEmitter {
13001300
if (!is.empty(typeMap)) {
13011301
Object.keys(typeMap).forEach(param => {
13021302
const type = typeMap[param];
1303-
const typeObject = codec.createTypeObject(type);
1304-
if (typeObject.code !== 'TYPE_CODE_UNSPECIFIED') {
1305-
paramTypes[param] = codec.createTypeObject(type);
1306-
}
1303+
paramTypes[param] = codec.createTypeObject(type);
13071304
});
13081305
}
13091306

0 commit comments

Comments
 (0)