{"id":21831355,"url":"https://github.com/nodef/pg-slang","last_synced_at":"2026-04-24T21:31:56.314Z","repository":{"id":57322652,"uuid":"136447368","full_name":"nodef/pg-slang","owner":"nodef","description":"Convert informal SQL SELECT to formal SQL.","archived":false,"fork":false,"pushed_at":"2025-04-08T17:10:23.000Z","size":13,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-09-22T00:35:53.037Z","etag":null,"topics":["column","formal","informal","pg","row","select","slang","sql","table"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/pg-slang","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nodef.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2018-06-07T08:34:49.000Z","updated_at":"2025-04-08T17:10:27.000Z","dependencies_parsed_at":"2025-06-10T08:48:26.723Z","dependency_job_id":null,"html_url":"https://github.com/nodef/pg-slang","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/nodef/pg-slang","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nodef%2Fpg-slang","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nodef%2Fpg-slang/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nodef%2Fpg-slang/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nodef%2Fpg-slang/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nodef","download_url":"https://codeload.github.com/nodef/pg-slang/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nodef%2Fpg-slang/sbom","scorecard":{"id":692459,"data":{"date":"2025-08-11","repo":{"name":"github.com/nodef/pg-slang","commit":"8e9266e3aa6c41407957b3d9c6c993b80d92f33f"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Code-Review","score":0,"reason":"Found 0/16 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-22T02:36:37.204Z","repository_id":57322652,"created_at":"2025-08-22T02:36:37.204Z","updated_at":"2025-08-22T02:36:37.204Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32241601,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-24T13:21:15.438Z","status":"ssl_error","status_checked_at":"2026-04-24T13:21:15.005Z","response_time":64,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["column","formal","informal","pg","row","select","slang","sql","table"],"created_at":"2024-11-27T19:09:52.510Z","updated_at":"2026-04-24T21:31:56.297Z","avatar_url":"https://github.com/nodef.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pg-slang\n\n[![NPM](https://nodei.co/npm/pg-slang.png)](https://nodei.co/npm/pg-slang/)\n\nConvert informal [SQL SELECT] to formal SQL.\n\u003e NOTE: [pg-english] can convert english query to informal SQL.\n\n```sql\n-- ex: SLANG\nSELECT \"food name\", \"calcium\" FROM \"apples\"\n-- ex: SQL\nSELECT \"name\", \"ca\", \"ca_e\" FROM \"compositions\"\nWHERE TRUE AND (FALSE OR (\"tsvector\" @@ 'apples'))\n```\n\n```javascript\nconst slang = require('pg-slang');\n// slang(\u003cinformal sql\u003e, \u003cmap fn\u003e, [this], [options])\n// -\u003e Promise (formal sql)\n\n// \u003cinformal sql\u003e:\n// SELECT \"food name\", \"trans fat\" FROM \"food\" ORDER BY \"trans fat\" DESC\n// SELECT \"protein\", \"vitamin d\" FROM \"poultry ORDER BY \"vitamin d\" DESC\n// SELECT \"sum: essential amino acids\" AS \"amino\" FROM \"meat\" ORDER BY \"amino\"\n// ...\n\n// \u003cmap fn\u003e(\u003ctext\u003e, \u003ctype\u003e, [hint], [from]):\n// - text: field name, like \"food name\", \"trans fat\", \"food\", ...\n// - type: field type, can be \"from\",\"columns\", \"where\", \"having\", \"orderBy\", or \"groupBy\"\n// - hint: field hint, can be null, \"all\", \"sum\", or \"avg\"\n// - from: field from, will be null for type=table\n// -\u003e Promise [\u003cvalue\u003e]\n// - value: expression string\n\n// [options]:\n// - from: default table\n// - limit: default maximum limit\n// - limits: table specific maximum limts\n```\n\n```javascript\n// 1. \nfunction fnA(text, type, hint, from) {\n  return ['sample1', 'sample1'];\n};\nslang(`SELECT \"food name\", \"calcium\" FROM \"apples\"`, fnA).then(console.log);\n// SELECT \"sample\", \"sample\" FROM \"sample\" WHERE TRUE AND TRUE\n\n\nfunction fnB(text, type, hint, from) {\n  if(type==='column') return ['name'];\n  return ['compositions'];\n};\nslang(`SELECT \"food name\", \"calcium\" FROM \"apples\"`, fnB).then(console.log);\n// SELECT \"name\", \"name\" FROM \"compositions\" WHERE TRUE AND TRUE\n\n\nfunction fnC(text, type, hint, from) {\n  if(type==='column') return ['ca', 'ca_e'];\n  return ['compositions'];\n};\nslang(`SELECT \"food name\", \"calcium\" FROM \"apples\"`, fnC).then(console.log);\n// SELECT \"ca\", \"ca_e\", \"ca\", \"ca_e\" FROM \"compositions\" WHERE TRUE AND TRUE\n\n\nvar columns = {\n  'food code': ['code'],\n  'food name': ['name'],\n  'calcium': ['ca', 'ca_e'],\n  'magnesium': ['mg', 'mg_e']\n};\nvar tables = ['food', 'compositions'];\nfunction fnD(text, type, hint, from) {\n  if(type==='column') return columns[text];\n  return tables.includes(text)? ['compositions']:[];\n};\nslang(`SELECT \"food name\", \"calcium\" FROM \"apples\"`, fnD).then(console.log);\n// SELECT \"name\", \"ca\", \"ca_e\" FROM \"null\" WHERE TRUE AND TRUE\n\n\nfunction fnE(text, type, hint, from) {\n  if(type==='column') return columns[text];\n  return tables.includes(text)? ['compositions']:[`\"tsvector\" @@ '${text}'`];\n};\nslang(`SELECT \"food name\", \"calcium\" FROM \"apples\"`, fnE).then(console.log);\n// SELECT \"name\", \"ca\", \"ca_e\" FROM \"null\" WHERE TRUE AND (FALSE OR (\"tsvector\" @@ 'apples'))\n\n\nvar options = {from: 'compositions'};\nslang(`SELECT \"food name\", \"calcium\" FROM \"apples\"`, fnE, null, options).then(console.log);\n// SELECT \"name\", \"ca\", \"ca_e\" FROM \"compositions\" WHERE TRUE AND (FALSE OR (\"tsvector\" @@ 'apples'))\n\n\n// PRIMARY USECASE\n// ---------------\nfunction fnDB(text, type, hint, from) {\n  return new Promise((resolve, reject) =\u003e {\n    // ...\n    // \u003cdo some database lookup\u003e\n    // ...\n  });\n};\nslang(/*  */, fnDB, null, options).then(console.log);\n// SELECT \"name\", \"ca\", \"ca_e\" FROM \"compositions\" WHERE TRUE AND (FALSE OR (\"tsvector\" @@ 'apples'))\n\n\n// NOTES\n// -----\n// 1. Map function return value can be an expression array\n// 2. For column, return multiple values to select multiple columns\n// 3. But in expressions, only first return value is considered\n// 4. Hints perform an operation on matching columns\n// 5. Use hint to decide which columns to return\n// 6. For table, returning expression will append to where\n// 7. Return expression and table name for full association\n// 8. Hint can be used in column text as \"\u003chint\u003e: \u003ccolumn text\u003e\"\n// 9. Hint \"all\": all|each|every\n// 10. Hint \"sum\": sum|gross|total|whole|aggregate\n// 11. Hint \"avg\": avg|mid|par|mean|norm|center|centre|average|midpoint\n// 12. Experiment! And mail me for issues / pull requests!\n```\n\n![](https://ga-beacon.deno.dev/G-RC63DPBH3P:SH3Eq-NoQ9mwgYeHWxu7cw/github.com/nodef/pg-slang)\n\n[SQL SELECT]: https://www.postgresql.org/docs/10/static/sql-select.html\n[pg-english]: https://www.npmjs.com/package/pg-english\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnodef%2Fpg-slang","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnodef%2Fpg-slang","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnodef%2Fpg-slang/lists"}