-
Notifications
You must be signed in to change notification settings - Fork 689
Node spanner pg driver #8838
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
Draft
surbhigarg92
wants to merge
3
commits into
main
Choose a base branch
from
node-spanner-pg-driver
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Node spanner pg driver #8838
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| **/node_modules | ||
| **/coverage | ||
| build/ | ||
| docs/ | ||
| test/pg-suite/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| { | ||
| "root": true, | ||
| "extends": "./node_modules/gts" | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| **/*.log | ||
| **/node_modules | ||
| /.coverage | ||
| /coverage | ||
| /.nyc_output | ||
| /docs/ | ||
| /out/ | ||
| /build/ | ||
| *.lock | ||
| .DS_Store | ||
| package-lock.json | ||
| pg-suite |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| // Copyright 2026 Google LLC | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| const config = { | ||
| "enable-source-maps": true, | ||
| "throw-deprecation": true, | ||
| "timeout": 10000, | ||
| "recursive": true | ||
| } | ||
| if (process.env.MOCHA_THROW_DEPRECATION === 'false') { | ||
| delete config['throw-deprecation']; | ||
| } | ||
| if (process.env.MOCHA_REPORTER) { | ||
| config.reporter = process.env.MOCHA_REPORTER; | ||
| } | ||
| if (process.env.MOCHA_REPORTER_OUTPUT) { | ||
| config['reporter-option'] = `output=${process.env.MOCHA_REPORTER_OUTPUT}`; | ||
| } | ||
| module.exports = config |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| **/node_modules | ||
| **/coverage | ||
| build/ | ||
| docs/ | ||
| test/pg-suite/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| // Copyright 2026 Google LLC | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // https://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| module.exports = { | ||
| ...require('gts/.prettierrc.json') | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| { | ||
| "name": "@google-cloud/spanner-pg", | ||
| "version": "0.1.0", | ||
| "description": "Node.js pg-compatible driver wrapper for Google Cloud Spanner", | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "https://github.com/googleapis/google-cloud-node.git", | ||
| "directory": "handwritten/spanner-pg" | ||
| }, | ||
| "license": "Apache-2.0", | ||
| "author": "Google LLC", | ||
| "main": "./build/cjs/src/index.cjs", | ||
| "module": "./build/esm/src/index.js", | ||
| "types": "./build/cjs/src/index.d.ts", | ||
| "type": "module", | ||
| "exports": { | ||
| ".": { | ||
| "import": { | ||
| "types": "./build/esm/src/index.d.ts", | ||
| "default": "./build/esm/src/index.js" | ||
| }, | ||
| "require": { | ||
| "types": "./build/cjs/src/index.d.ts", | ||
| "default": "./build/cjs/src/index.cjs" | ||
| } | ||
| } | ||
| }, | ||
| "files": [ | ||
| "build/esm/src", | ||
| "build/cjs/src" | ||
| ], | ||
| "scripts": { | ||
| "clean": "gts clean", | ||
| "compile:esm": "tsc -p .", | ||
| "compile:cjs": "tsc -p ./tsconfig.cjs.json && babel build/cjs --out-dir build/cjs --out-file-extension .cjs && node scripts/fix-extensions.cjs", | ||
| "compile": "npm run compile:esm && npm run compile:cjs", | ||
| "fix": "gts fix", | ||
| "lint": "gts check", | ||
| "prepare": "npm run compile", | ||
| "test:esm": "c8 mocha build/esm/test/**/*.js", | ||
| "test:cjs": "c8 mocha build/cjs/test/**/*.cjs", | ||
| "test": "npm run test:esm && npm run test:cjs" | ||
| }, | ||
| "dependencies": { | ||
| "spannerlib-node": "file:/Users/gargsurbhi/Work/Github/go-sql-spanner/spannerlib/wrappers/spannerlib-node", | ||
| "@google-cloud/spanner": "^8.7.1" | ||
| }, | ||
| "devDependencies": { | ||
| "@types/mocha": "^10.0.10", | ||
| "@types/node": "^22.13.9", | ||
| "@types/sinon": "^17.0.4", | ||
| "c8": "^10.1.3", | ||
| "gts": "^6.0.2", | ||
| "mocha": "^11.1.0", | ||
| "sinon": "^21.0.3", | ||
| "typescript": "^5.8.2", | ||
| "@babel/core": "^7.24.0", | ||
| "@babel/cli": "^7.23.9" | ||
| }, | ||
| "engines": { | ||
| "node": ">=18" | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| // Copyright 2026 Google LLC | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| const fs = require('fs'); | ||
| const path = require('path'); | ||
|
|
||
| const cjsDir = path.join(__dirname, '../build/cjs'); | ||
|
|
||
| function traverseDir(dir) { | ||
| fs.readdirSync(dir).forEach(file => { | ||
| const fullPath = path.join(dir, file); | ||
| if (fs.statSync(fullPath).isDirectory()) { | ||
| traverseDir(fullPath); | ||
| } else if (fullPath.endsWith('.cjs')) { | ||
| let content = fs.readFileSync(fullPath, 'utf8'); | ||
| // Replace require paths starting with . / or .. / and ending with .js | ||
| content = content.replace(/require\(['"]((\.|\.\.)\/[^'"]+)\.js['"]\)/g, "require('$1.cjs')"); | ||
| // Fix import.meta.url syntax error in CommonJS | ||
| content = content.replace(/import\.meta\.url/g, '""'); | ||
| fs.writeFileSync(fullPath, content); | ||
| } else if (fullPath.endsWith('.js')) { | ||
| // Delete the original .js file generated by tsc | ||
| fs.unlinkSync(fullPath); | ||
| } | ||
| }); | ||
| } | ||
|
|
||
| if (fs.existsSync(cjsDir)) { | ||
| traverseDir(cjsDir); | ||
| console.log('Fixed extensions in .cjs files and removed .js files in build/cjs'); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| // Copyright 2026 Google LLC | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| import {Client} from './lib/client.js'; | ||
| import {Pool} from './lib/pool.js'; | ||
| import {Query} from './lib/query.js'; | ||
| import {types} from './lib/types.js'; | ||
|
|
||
| export {Client, Pool, Query, types}; | ||
| export const native = {Client, Pool}; | ||
|
|
||
| export const defaults = { | ||
| host: 'localhost', | ||
| port: 5432, | ||
| user: 'postgres', | ||
| password: '', | ||
| database: 'postgres', | ||
| }; | ||
|
|
||
| export class DatabaseError extends Error { | ||
| severity?: string; | ||
| code?: string; | ||
| detail?: string; | ||
| hint?: string; | ||
| position?: string; | ||
| internalPosition?: string; | ||
| internalQuery?: string; | ||
| where?: string; | ||
| schema?: string; | ||
| table?: string; | ||
| column?: string; | ||
| dataType?: string; | ||
| constraint?: string; | ||
| file?: string; | ||
| line?: string; | ||
| routine?: string; | ||
| } | ||
|
|
||
| export const escapeIdentifier = (str: string) => `"${str.replace(/"/g, '""')}"`; | ||
| export const escapeLiteral = (str: string) => `'${str.replace(/'/g, "''")}'`; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The dependency
spannerlib-nodepoints to a hardcoded local file path on your machine (file:/Users/gargsurbhi/...). This will cause installation and build failures in CI/CD environments and for other developers. Please replace this with a published version or a workspace reference.