Skip to content

Commit

Permalink
"fix: revert untyped param types (googleapis#1869)"
Browse files Browse the repository at this point in the history
This reverts commit 6ef44c3.
  • Loading branch information
surbhigarg92 committed Mar 4, 2024
1 parent e57b897 commit 3201900
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 3201900

Please sign in to comment.