{"id":28041,"library":"pg-query-string","title":"pg-query-string","description":"pg-query-string is a small library (v0.1.7, stable) for building PostgreSQL query strings with parameterized values. It is a fork of squel, hardcoded to PostgreSQL, with type coercion and ES6 class-based schema/table constructs. Current version is 0.1.7, no recent updates. Key differentiator: produces both SQL text and parameter arrays for safe execution.","status":"maintenance","version":"0.1.7","language":"javascript","source_language":"en","source_url":"https://github.com/pyramation/sql-query","tags":["javascript","postgres","query"],"install":[{"cmd":"npm install pg-query-string","lang":"bash","label":"npm"},{"cmd":"yarn add pg-query-string","lang":"bash","label":"yarn"},{"cmd":"pnpm add pg-query-string","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Package is ESM-only. Default export is not available.","wrong":"const { Table } = require('pg-query-string')","symbol":"Table","correct":"import { Table } from 'pg-query-string'"},{"note":"Default import does not exist; use named imports.","wrong":"import pgqs from 'pg-query-string'","symbol":"Schema","correct":"import { Schema } from 'pg-query-string'"},{"note":"For dynamic imports, use ESM dynamic import syntax in Node >= 13.2 or with type: module.","wrong":"const Table = require('pg-query-string').Table","symbol":"Table","correct":"const { Table } = await import('pg-query-string')"}],"quickstart":{"code":"import { Schema, Table } from 'pg-query-string';\n\nconst schema = new Schema('my_schema');\nconst table = schema.table('users', {\n  id: 'uuid',\n  username: 'text',\n  active: 'boolean'\n});\n\nconst result = table.update(\n  { active: true },\n  { id: 1 }\n);\n\nconsole.log(result.text);\n// UPDATE \"my_schema\".users SET active = $1::boolean WHERE (id = $2::uuid)\nconsole.log(result.values);\n// [ true, 1 ]","lang":"typescript","description":"Creates a schema and table with typed columns, then builds an UPDATE query with parameterized values."},"warnings":[{"fix":"Use import syntax or configure bundler to handle ESM.","message":"Package is ESM-only; requires Node >= 13 or a bundler like webpack/esbuild.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Consider using 'pg' or 'knex' for more maintained query building.","message":"The package has not been updated since 2019 and may have unpatched security issues.","severity":"deprecated","affected_versions":">=0.1.0"},{"fix":"Use Map or arrays to guarantee order.","message":"Object literals for insert/update produce $1, $2, etc. in the order of object keys, which is non-deterministic in older JavaScript engines.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Use snake_case for schema/table names to avoid quoting issues.","message":"Schema and table names are quoted with double quotes, which are case-sensitive in PostgreSQL. Ensure lowercase names.","severity":"gotcha","affected_versions":">=0.1.0"}],"env_vars":null,"search_vec":"'0.1.7':45 'array':57 'base':39 'build':16 'class':38 'class-bas':37 'coercion':34 'construct':41 'current':42 'differenti':50 'es6':36 'execut':60 'fork':26 'hardcod':29 'javascript':61 'key':49 'librari':12 'paramet':56 'parameter':21 'pg':2,6 'pg-query-str':1,5 'postgr':62 'postgresql':17,31 'produc':51 'queri':3,7,18,63 'recent':47 'safe':59 'schema/table':40 'small':11 'sql':53 'squel':28 'stabl':14 'string':4,8,19 'text':54 'type':33 'updat':48 'v0.1.7':13 'valu':22 'version':43","created_at":"2026-05-09T05:53:25.475611+00:00","updated_at":"2026-05-09T05:53:25.475611+00:00","problems":[{"fix":"Change to: import { Table } from 'pg-query-string'","cause":"Using default import instead of named import.","error":"TypeError: (0 , _pgQueryString.Table) is not a constructor"},{"fix":"Add 'type': 'module' to package.json or use dynamic import().","cause":"Using ESM import in a CommonJS file without 'type': 'module'.","error":"SyntaxError: Cannot use import statement outside a module"},{"fix":"Correct import: import { Schema } from 'pg-query-string'","cause":"Using const without assigning import result.","error":"Missing initializer in const declaration"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/pyramation/sql-query","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/pg-query-string","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-05-09","next_check":"2026-08-07","install_tag":null}}