{"id":42735,"library":"extra-sql-builder","title":"extra-sql-builder","description":"A lightweight, composable SQL builder for TypeScript and JavaScript that constructs SQL statements programmatically without string concatenation or ORM overhead. Current stable version 0.3.4 (semver pre-1.0). It provides a flexible `sql` tagged template literal and function, along with a `ParameterCollector` for named or indexed parameters to prevent SQL injection. Key differentiators: no dependency on ORM, intuitive function-based query construction (e.g., `INSERT_INTO`, `SELECT`, `WHERE`), support for conditional fragments via falsy values, and a small API surface focused solely on SQL generation. TypeScript types included.","status":"active","version":"0.3.4","language":"javascript","source_language":"en","source_url":"ssh://git@github.com/BlackGlory/extra-sql-builder","tags":["javascript","sql","query","builder","typescript"],"install":[{"cmd":"npm install extra-sql-builder","lang":"bash","label":"npm"},{"cmd":"yarn add extra-sql-builder","lang":"bash","label":"yarn"},{"cmd":"pnpm add extra-sql-builder","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Package is ESM-only. Use named import, not default.","wrong":"const sql = require('extra-sql-builder')","symbol":"sql","correct":"import { sql } from 'extra-sql-builder'"},{"note":"All fragment functions (e.g., INSERT_INTO, VALUES, SELECT) are named exports, not default exports.","wrong":"import InsertInto from 'extra-sql-builder'","symbol":"INSERT_INTO, VALUES, SELECT, etc.","correct":"import { INSERT_INTO, VALUES, SELECT } from 'extra-sql-builder'"},{"note":"Use named import with ES module syntax.","wrong":"const pc = new (require('extra-sql-builder').ParameterCollector)('$')","symbol":"ParameterCollector","correct":"import { ParameterCollector } from 'extra-sql-builder'"}],"quickstart":{"code":"import { sql, INSERT_INTO, VALUES, integer, text, ParameterCollector } from 'extra-sql-builder'\n\nconst cond = true\nconst collector = new ParameterCollector('$param')\n\nconst result = sql(\n  INSERT_INTO('users', ['id', 'name']),\n  VALUES(\n    [collector.add(1), collector.add('Alice')],\n    cond && [collector.add(2), collector.add('Bob')]\n  )\n)\n// result: INSERT INTO users (id, name) VALUES ($param1, $param2), ($param3, $param4)\n\nconst params = collector.toRecord()\n// { param1: 1, param2: 'Alice', param3: 2, param4: 'Bob' }\n\nconsole.log(result, params)","lang":"typescript","description":"Shows building a parameterized INSERT with conditional rows using ParameterCollector."},"warnings":[{"fix":"Use only one calling convention per statement: either `sql\\`...\\`` or `sql(...)`.","message":"The `sql` function accepts both tagged template literals and function arguments, but mixing them can cause unexpected results.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Explicitly cast to string or use a wrapper for values that could be falsy but intended to be included.","message":"Falsy values (false, null, undefined, 0, '') are omitted from fragments, which may inadvertently drop zero or empty strings used as legitimate values.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Call `add()` with the final value and avoid mutation afterwards.","message":"The `ParameterCollector` stores values by reference; mutating values after adding them does not affect collected parameters.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Pin exact version or use ^0.3.4 and review changelog on updates.","message":"Pre-1.0 semver: minor version bumps may introduce breaking changes. No stable API yet.","severity":"breaking","affected_versions":"<1.0.0"},{"fix":"Ensure your project uses ESM (e.g., `\"type\": \"module\"` in package.json) and import via `import`.","message":"The package does not support CommonJS; using `require()` will fail.","severity":"deprecated","affected_versions":">=0.0.0"}],"env_vars":null,"search_vec":"'-1.0':31 '0.3.4':28 'along':42 'api':82 'base':64 'builder':4,9,95 'compos':7 'concaten':21 'condit':74 'construct':15,66 'current':25 'depend':58 'differenti':56 'e.g':67 'extra':2 'extra-sql-build':1 'falsi':77 'flexibl':35 'focus':84 'fragment':75 'function':41,63 'function-bas':62 'generat':88 'includ':91 'index':49 'inject':54 'insert':68 'intuit':61 'javascript':13,92 'key':55 'lightweight':6 'liter':39 'name':47 'orm':23,60 'overhead':24 'paramet':50 'parametercollector':45 'pre':30 'prevent':52 'programmat':18 'provid':33 'queri':65,94 'select':70 'semver':29 'small':81 'sole':85 'sql':3,8,16,36,53,87,93 'stabl':26 'statement':17 'string':20 'support':72 'surfac':83 'tag':37 'templat':38 'type':90 'typescript':11,89,96 'valu':78 'version':27 'via':76 'without':19","created_at":"2026-06-05T16:56:25.420546+00:00","updated_at":"2026-06-05T16:56:25.420546+00:00","problems":[{"fix":"Switch to ESM imports: use `import { sql } from 'extra-sql-builder'` instead of `require()`.","cause":"Package is ESM-only, CommonJS require() not supported.","error":"Error [ERR_REQUIRE_ESM]: require() of ES Module"},{"fix":"Use `import { sql } from 'extra-sql-builder'`.","cause":"Importing incorrectly (e.g., default import instead of named).","error":"TypeError: sql is not a function"},{"fix":"Add to import: `import { INSERT_INTO, VALUES } from 'extra-sql-builder'`.","cause":"Fragment functions are named exports; not importing them.","error":"ReferenceError: INSERT_INTO is not defined"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/BlackGlory/extra-sql-builder#readme","github":"ssh://git@github.com/BlackGlory/extra-sql-builder","docs":null,"changelog":null,"pypi":null,"npm":"extra-sql-builder","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-06-05","next_check":"2026-09-03","install_tag":null}}