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
🦉 Updates from OwlBot post-processor
  • Loading branch information
gcf-owl-bot[bot] committed May 7, 2024
commit a35d89080591b698a14d45b41c5a5bde469447cb
2 changes: 0 additions & 2 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,3 @@ docs/
protos/
samples/generated/
system-test/**/fixtures
samples/resource/
test/data/
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,12 @@ Samples are in the [`samples/`](https://github.com/googleapis/nodejs-spanner/tre
| CRUD | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/crud.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/crud.js,samples/README.md) |
| Creates a new database with a specific default leader | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/database-create-with-default-leader.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/database-create-with-default-leader.js,samples/README.md) |
| Database-create-with-encryption-key | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/database-create-with-encryption-key.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/database-create-with-encryption-key.js,samples/README.md) |
| Creates a new database with a proto column and enum | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/database-create-with-proto-descriptor.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/database-create-with-proto-descriptor.js,samples/README.md) |
| Database-create-with-version-retention-period | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/database-create-with-version-retention-period.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/database-create-with-version-retention-period.js,samples/README.md) |
| Gets the schema definition of an existing database | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/database-get-ddl.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/database-get-ddl.js,samples/README.md) |
| Gets the default leader option of an existing database | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/database-get-default-leader.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/database-get-default-leader.js,samples/README.md) |
| Updates the default leader of an existing database | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/database-update-default-leader.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/database-update-default-leader.js,samples/README.md) |
| Database-update-with-proto-descriptor | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/database-update-with-proto-descriptor.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/database-update-with-proto-descriptor.js,samples/README.md) |
| Updates a Cloud Spanner Database. | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/database-update.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/database-update.js,samples/README.md) |
| Datatypes | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/datatypes.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/datatypes.js,samples/README.md) |
| Runs an execute sql request with directed read options | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/directed-reads.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/directed-reads.js,samples/README.md) |
Expand Down Expand Up @@ -167,6 +169,10 @@ Samples are in the [`samples/`](https://github.com/googleapis/nodejs-spanner/tre
| Alters a sequence in a PostgreSQL database. | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/pg-sequence-alter.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/pg-sequence-alter.js,samples/README.md) |
| Creates sequence in PostgreSQL database. | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/pg-sequence-create.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/pg-sequence-create.js,samples/README.md) |
| Drops a sequence in PostgreSQL database. | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/pg-sequence-drop.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/pg-sequence-drop.js,samples/README.md) |
| Proto-column-dml-insert | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/proto-column-dml-insert.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/proto-column-dml-insert.js,samples/README.md) |
| Proto-column-mutation-insert | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/proto-column-mutation-insert.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/proto-column-mutation-insert.js,samples/README.md) |
| Proto-column-query | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/proto-column-query.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/proto-column-query.js,samples/README.md) |
| Proto-column-read | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/proto-column-read.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/proto-column-read.js,samples/README.md) |
| Queryoptions | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/queryoptions.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/queryoptions.js,samples/README.md) |
| Quickstart | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/quickstart.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/quickstart.js,samples/README.md) |
| Read data with database role | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/read-data-with-database-role.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/read-data-with-database-role.js,samples/README.md) |
Expand Down
108 changes: 108 additions & 0 deletions samples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,12 @@ and automatic, synchronous replication for high availability.
* [CRUD](#crud)
* [Creates a new database with a specific default leader](#creates-a-new-database-with-a-specific-default-leader)
* [Database-create-with-encryption-key](#database-create-with-encryption-key)
* [Creates a new database with a proto column and enum](#creates-a-new-database-with-a-proto-column-and-enum)
* [Database-create-with-version-retention-period](#database-create-with-version-retention-period)
* [Gets the schema definition of an existing database](#gets-the-schema-definition-of-an-existing-database)
* [Gets the default leader option of an existing database](#gets-the-default-leader-option-of-an-existing-database)
* [Updates the default leader of an existing database](#updates-the-default-leader-of-an-existing-database)
* [Database-update-with-proto-descriptor](#database-update-with-proto-descriptor)
* [Updates a Cloud Spanner Database.](#updates-a-cloud-spanner-database.)
* [Datatypes](#datatypes)
* [Runs an execute sql request with directed read options](#runs-an-execute-sql-request-with-directed-read-options)
Expand Down Expand Up @@ -92,6 +94,10 @@ and automatic, synchronous replication for high availability.
* [Alters a sequence in a PostgreSQL database.](#alters-a-sequence-in-a-postgresql-database.)
* [Creates sequence in PostgreSQL database.](#creates-sequence-in-postgresql-database.)
* [Drops a sequence in PostgreSQL database.](#drops-a-sequence-in-postgresql-database.)
* [Proto-column-dml-insert](#proto-column-dml-insert)
* [Proto-column-mutation-insert](#proto-column-mutation-insert)
* [Proto-column-query](#proto-column-query)
* [Proto-column-read](#proto-column-read)
* [Queryoptions](#queryoptions)
* [Quickstart](#quickstart)
* [Read data with database role](#read-data-with-database-role)
Expand Down Expand Up @@ -418,6 +424,23 @@ __Usage:__



### Creates a new database with a proto column and enum

View the [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/database-create-with-proto-descriptor.js).

[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/database-create-with-proto-descriptor.js,samples/README.md)

__Usage:__


`node database-create-with-proto-descriptor.js <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>`


-----




### Database-create-with-version-retention-period

View the [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/database-create-with-version-retention-period.js).
Expand Down Expand Up @@ -486,6 +509,23 @@ __Usage:__



### Database-update-with-proto-descriptor

View the [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/database-update-with-proto-descriptor.js).

[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/database-update-with-proto-descriptor.js,samples/README.md)

__Usage:__


`node samples/database-update-with-proto-descriptor.js`


-----




### Updates a Cloud Spanner Database.

View the [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/database-update.js).
Expand Down Expand Up @@ -1455,6 +1495,74 @@ __Usage:__



### Proto-column-dml-insert

View the [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/proto-column-dml-insert.js).

[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/proto-column-dml-insert.js,samples/README.md)

__Usage:__


`node samples/proto-column-dml-insert.js`


-----




### Proto-column-mutation-insert

View the [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/proto-column-mutation-insert.js).

[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/proto-column-mutation-insert.js,samples/README.md)

__Usage:__


`node samples/proto-column-mutation-insert.js`


-----




### Proto-column-query

View the [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/proto-column-query.js).

[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/proto-column-query.js,samples/README.md)

__Usage:__


`node samples/proto-column-query.js`


-----




### Proto-column-read

View the [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/proto-column-read.js).

[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/proto-column-read.js,samples/README.md)

__Usage:__


`node samples/proto-column-read.js`


-----




### Queryoptions

View the [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/queryoptions.js).
Expand Down
14 changes: 7 additions & 7 deletions samples/resource/singer.js
Original file line number Diff line number Diff line change
Expand Up @@ -350,8 +350,8 @@ $root.spanner = (function () {
options.longs === String
? long.toString()
: options.longs === Number
? long.toNumber()
: long;
? long.toNumber()
: long;
} else object.singerId = options.longs === String ? '0' : 0;
object.birthDate = '';
object.nationality = '';
Expand All @@ -368,11 +368,11 @@ $root.spanner = (function () {
options.longs === String
? $util.Long.prototype.toString.call(message.singerId)
: options.longs === Number
? new $util.LongBits(
message.singerId.low >>> 0,
message.singerId.high >>> 0
).toNumber()
: message.singerId;
? new $util.LongBits(
message.singerId.low >>> 0,
message.singerId.high >>> 0
).toNumber()
: message.singerId;
if (message.birthDate !== null && message.hasOwnProperty('birthDate'))
object.birthDate = message.birthDate;
if (
Expand Down
14 changes: 7 additions & 7 deletions test/data/singer.js
Original file line number Diff line number Diff line change
Expand Up @@ -350,8 +350,8 @@ $root.spanner = (function () {
options.longs === String
? long.toString()
: options.longs === Number
? long.toNumber()
: long;
? long.toNumber()
: long;
} else object.singerId = options.longs === String ? '0' : 0;
object.birthDate = '';
object.nationality = '';
Expand All @@ -368,11 +368,11 @@ $root.spanner = (function () {
options.longs === String
? $util.Long.prototype.toString.call(message.singerId)
: options.longs === Number
? new $util.LongBits(
message.singerId.low >>> 0,
message.singerId.high >>> 0
).toNumber()
: message.singerId;
? new $util.LongBits(
message.singerId.low >>> 0,
message.singerId.high >>> 0
).toNumber()
: message.singerId;
if (message.birthDate !== null && message.hasOwnProperty('birthDate'))
object.birthDate = message.birthDate;
if (
Expand Down
Loading