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

feat: add support for Proto columns #1991

Merged
merged 19 commits into from
May 15, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat(spanner): fix tests lint
  • Loading branch information
harshachinta committed May 7, 2024
commit 0c7a91a1c96aceaee532e87fa36624b85647cf03
3 changes: 2 additions & 1 deletion samples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"@google-cloud/kms": "^4.0.0",
"@google-cloud/precise-date": "^4.0.0",
"@google-cloud/spanner": "^7.7.0",
"yargs": "^17.0.0"
"yargs": "^17.0.0",
"protobufjs": "^7.0.0"
},
"devDependencies": {
"chai": "^4.2.0",
Expand Down
32 changes: 16 additions & 16 deletions samples/resource/singer.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ $root.spanner = (function () {
i < keys.length;
++i
)
if (properties[keys[i]] != null)
if (properties[keys[i]] !== null)
this[keys[i]] = properties[keys[i]];
}

Expand Down Expand Up @@ -137,24 +137,24 @@ $root.spanner = (function () {
SingerInfo.encode = function encode(message, writer) {
if (!writer) writer = $Writer.create();
if (
message.singerId != null &&
message.singerId !== null &&
Object.hasOwnProperty.call(message, 'singerId')
)
writer.uint32(/* id 1, wireType 0 =*/ 8).int64(message.singerId);
if (
message.birthDate != null &&
message.birthDate !== null &&
Object.hasOwnProperty.call(message, 'birthDate')
)
writer.uint32(/* id 2, wireType 2 =*/ 18).string(message.birthDate);
if (
message.nationality != null &&
message.nationality !== null &&
Object.hasOwnProperty.call(message, 'nationality')
)
writer
.uint32(/* id 3, wireType 2 =*/ 26)
.string(message.nationality);
if (
message.genre != null &&
message.genre !== null &&
Object.hasOwnProperty.call(message, 'genre')
)
writer.uint32(/* id 4, wireType 0 =*/ 32).int32(message.genre);
Expand Down Expand Up @@ -242,7 +242,7 @@ $root.spanner = (function () {
SingerInfo.verify = function verify(message) {
if (typeof message !== 'object' || message === null)
return 'object expected';
if (message.singerId != null && message.hasOwnProperty('singerId'))
if (message.singerId !== null && message.hasOwnProperty('singerId'))
if (
!$util.isInteger(message.singerId) &&
!(
Expand All @@ -252,16 +252,16 @@ $root.spanner = (function () {
)
)
return 'singerId: integer|Long expected';
if (message.birthDate != null && message.hasOwnProperty('birthDate'))
if (message.birthDate !== null && message.hasOwnProperty('birthDate'))
if (!$util.isString(message.birthDate))
return 'birthDate: string expected';
if (
message.nationality != null &&
message.nationality !== null &&
message.hasOwnProperty('nationality')
)
if (!$util.isString(message.nationality))
return 'nationality: string expected';
if (message.genre != null && message.hasOwnProperty('genre'))
if (message.genre !== null && message.hasOwnProperty('genre'))
switch (message.genre) {
default:
return 'genre: enum value expected';
Expand All @@ -286,7 +286,7 @@ $root.spanner = (function () {
if (object instanceof $root.spanner.examples.music.SingerInfo)
return object;
var message = new $root.spanner.examples.music.SingerInfo();
if (object.singerId != null)
if (object.singerId !== null)
if ($util.Long)
(message.singerId = $util.Long.fromValue(
object.singerId
Expand All @@ -300,9 +300,9 @@ $root.spanner = (function () {
object.singerId.low >>> 0,
object.singerId.high >>> 0
).toNumber();
if (object.birthDate != null)
if (object.birthDate !== null)
message.birthDate = String(object.birthDate);
if (object.nationality != null)
if (object.nationality !== null)
message.nationality = String(object.nationality);
switch (object.genre) {
default:
Expand Down Expand Up @@ -357,7 +357,7 @@ $root.spanner = (function () {
object.nationality = '';
object.genre = options.enums === String ? 'POP' : 0;
}
if (message.singerId != null && message.hasOwnProperty('singerId'))
if (message.singerId !== null && message.hasOwnProperty('singerId'))
if (typeof message.singerId === 'number')
object.singerId =
options.longs === String
Expand All @@ -373,14 +373,14 @@ $root.spanner = (function () {
message.singerId.high >>> 0
).toNumber()
: message.singerId;
if (message.birthDate != null && message.hasOwnProperty('birthDate'))
if (message.birthDate !== null && message.hasOwnProperty('birthDate'))
object.birthDate = message.birthDate;
if (
message.nationality != null &&
message.nationality !== null &&
message.hasOwnProperty('nationality')
)
object.nationality = message.nationality;
if (message.genre != null && message.hasOwnProperty('genre'))
if (message.genre !== null && message.hasOwnProperty('genre'))
object.genre =
options.enums === String
? $root.spanner.examples.music.Genre[message.genre] ===
Expand Down
8 changes: 4 additions & 4 deletions samples/system-test/spanner.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1720,11 +1720,11 @@ describe('Autogenerated Admin Clients', () => {
);
assert.match(
output,
new RegExp(`Waiting for creation of ${DATABASE_ID} to complete...`)
new RegExp(`Waiting for creation of ${PROTO_DATABASE_ID1} to complete...`)
);
assert.match(
output,
new RegExp(`Created database ${DATABASE_ID} with proto column.`)
new RegExp(`Created database ${PROTO_DATABASE_ID1} with proto column.`)
);
});

Expand All @@ -1735,11 +1735,11 @@ describe('Autogenerated Admin Clients', () => {
);
assert.match(
output,
new RegExp(`Waiting for update on ${DATABASE_ID} to complete...`)
new RegExp(`Waiting for update on ${PROTO_DATABASE_ID2} to complete...`)
);
assert.match(
output,
new RegExp(`Updated database ${DATABASE_ID} with proto column.`)
new RegExp(`Updated database ${PROTO_DATABASE_ID2} with proto column.`)
);
});

Expand Down
32 changes: 16 additions & 16 deletions test/data/singer.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ $root.spanner = (function () {
i < keys.length;
++i
)
if (properties[keys[i]] != null)
if (properties[keys[i]] !== null)
this[keys[i]] = properties[keys[i]];
}

Expand Down Expand Up @@ -137,24 +137,24 @@ $root.spanner = (function () {
SingerInfo.encode = function encode(message, writer) {
if (!writer) writer = $Writer.create();
if (
message.singerId != null &&
message.singerId !== null &&
Object.hasOwnProperty.call(message, 'singerId')
)
writer.uint32(/* id 1, wireType 0 =*/ 8).int64(message.singerId);
if (
message.birthDate != null &&
message.birthDate !== null &&
Object.hasOwnProperty.call(message, 'birthDate')
)
writer.uint32(/* id 2, wireType 2 =*/ 18).string(message.birthDate);
if (
message.nationality != null &&
message.nationality !== null &&
Object.hasOwnProperty.call(message, 'nationality')
)
writer
.uint32(/* id 3, wireType 2 =*/ 26)
.string(message.nationality);
if (
message.genre != null &&
message.genre !== null &&
Object.hasOwnProperty.call(message, 'genre')
)
writer.uint32(/* id 4, wireType 0 =*/ 32).int32(message.genre);
Expand Down Expand Up @@ -242,7 +242,7 @@ $root.spanner = (function () {
SingerInfo.verify = function verify(message) {
if (typeof message !== 'object' || message === null)
return 'object expected';
if (message.singerId != null && message.hasOwnProperty('singerId'))
if (message.singerId !== null && message.hasOwnProperty('singerId'))
if (
!$util.isInteger(message.singerId) &&
!(
Expand All @@ -252,16 +252,16 @@ $root.spanner = (function () {
)
)
return 'singerId: integer|Long expected';
if (message.birthDate != null && message.hasOwnProperty('birthDate'))
if (message.birthDate !== null && message.hasOwnProperty('birthDate'))
if (!$util.isString(message.birthDate))
return 'birthDate: string expected';
if (
message.nationality != null &&
message.nationality !== null &&
message.hasOwnProperty('nationality')
)
if (!$util.isString(message.nationality))
return 'nationality: string expected';
if (message.genre != null && message.hasOwnProperty('genre'))
if (message.genre !== null && message.hasOwnProperty('genre'))
switch (message.genre) {
default:
return 'genre: enum value expected';
Expand All @@ -286,7 +286,7 @@ $root.spanner = (function () {
if (object instanceof $root.spanner.examples.music.SingerInfo)
return object;
var message = new $root.spanner.examples.music.SingerInfo();
if (object.singerId != null)
if (object.singerId !== null)
if ($util.Long)
(message.singerId = $util.Long.fromValue(
object.singerId
Expand All @@ -300,9 +300,9 @@ $root.spanner = (function () {
object.singerId.low >>> 0,
object.singerId.high >>> 0
).toNumber();
if (object.birthDate != null)
if (object.birthDate !== null)
message.birthDate = String(object.birthDate);
if (object.nationality != null)
if (object.nationality !== null)
message.nationality = String(object.nationality);
switch (object.genre) {
default:
Expand Down Expand Up @@ -357,7 +357,7 @@ $root.spanner = (function () {
object.nationality = '';
object.genre = options.enums === String ? 'POP' : 0;
}
if (message.singerId != null && message.hasOwnProperty('singerId'))
if (message.singerId !== null && message.hasOwnProperty('singerId'))
if (typeof message.singerId === 'number')
object.singerId =
options.longs === String
Expand All @@ -373,14 +373,14 @@ $root.spanner = (function () {
message.singerId.high >>> 0
).toNumber()
: message.singerId;
if (message.birthDate != null && message.hasOwnProperty('birthDate'))
if (message.birthDate !== null && message.hasOwnProperty('birthDate'))
object.birthDate = message.birthDate;
if (
message.nationality != null &&
message.nationality !== null &&
message.hasOwnProperty('nationality')
)
object.nationality = message.nationality;
if (message.genre != null && message.hasOwnProperty('genre'))
if (message.genre !== null && message.hasOwnProperty('genre'))
object.genre =
options.enums === String
? $root.spanner.examples.music.Genre[message.genre] ===
Expand Down
Loading