{"id":43959,"library":"sql-template-strings-ts","title":"sql-template-strings-ts","description":"Functional wrapper around sql-template-strings providing an fp-ts-friendly, pipeable API for building parameterized SQL queries. v1.1.0 is current, with a focus on FP patterns using fp-ts. Requires peer dependencies fp-ts ^2.9.5 and sql-template-strings ^2.2.2. Differentiates from raw sql-template-strings by offering pointfree combinators (append, setName, useBind) for composing queries without imperative statements.","status":"active","version":"1.1.0","language":"javascript","source_language":"en","source_url":"https://github.com/DenisFrezzato/sql-template-strings-ts","tags":["javascript","mysql","mysql2","postgres","postgresql","pg","prepared","statements","placeholder","typescript"],"install":[{"cmd":"npm install sql-template-strings-ts","lang":"bash","label":"npm"},{"cmd":"yarn add sql-template-strings-ts","lang":"bash","label":"yarn"},{"cmd":"pnpm add sql-template-strings-ts","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required for pipe and functional combinators","package":"fp-ts","optional":false},{"reason":"Core library providing SQLStatement type and template tag functionality","package":"sql-template-strings","optional":false}],"imports":[{"note":"ESM-only; named export.","wrong":"const { t } = require('sql-template-strings-ts')","symbol":"t","correct":"import { t } from 'sql-template-strings-ts'"},{"note":"No default export; use namespace import.","wrong":"import SQL from 'sql-template-strings-ts'","symbol":"SQL module","correct":"import * as SQL from 'sql-template-strings-ts'"},{"note":"append is exported from this package, not from the underlying sql-template-strings.","wrong":"import { append } from 'sql-template-strings'","symbol":"append","correct":"import { append } from 'sql-template-strings-ts'"},{"note":"setName is specific to this wrapper.","wrong":"import { setName } from 'sql-template-strings'","symbol":"setName","correct":"import { setName } from 'sql-template-strings-ts'"},{"note":"useBind is from this package.","wrong":"import { useBind } from 'sql-template-strings'","symbol":"useBind","correct":"import { useBind } from 'sql-template-strings-ts'"}],"quickstart":{"code":"import * as SQL from 'sql-template-strings-ts';\nimport { pipe } from 'fp-ts/function';\n\nconst name = 'Alice';\nconst limit = 10;\nconst offset = 0;\n\nconst query = pipe(\n  SQL.t`SELECT * FROM users WHERE name = ${name}`,\n  SQL.append(SQL.t` LIMIT ${limit} OFFSET ${offset}`)\n);\n\nconsole.log(query.text);\nconsole.log(query.values);","lang":"typescript","description":"Demonstrates creating a parameterized SQL query using the t template tag and appending clauses via pipe."},"warnings":[{"fix":"Use backticks with ${} syntax.","message":"Must provide only TemplateStringsArray and values to t; passing a variable as first argument will fail.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Switch to `import * as SQL from 'sql-template-strings-ts'`.","message":"Breaking: default export removed in 1.0.0; must use named exports or namespace import.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Ensure sql-template-strings is at ^2.2.2.","message":"The sql-template-strings dependency may have breaking changes; always check compatibility.","severity":"deprecated","affected_versions":"*"},{"fix":"Always use t tag for dynamic values.","message":"append does not validate SQL; misuse may cause injection if values are not parameterized.","severity":"gotcha","affected_versions":"*"},{"fix":"npm install fp-ts sql-template-strings sql-template-strings-ts","message":"Error: Cannot find module 'fp-ts' if peer dependency missing.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'2.2.2':51 '2.9.5':45 'api':20 'append':63 'around':8 'build':22 'combin':62 'compos':67 'current':28 'depend':41 'differenti':52 'focus':31 'fp':16,33,37,43 'fp-ts':36,42 'fp-ts-friend':15 'friend':18 'function':6 'imper':70 'javascript':72 'mysql':73 'mysql2':74 'offer':60 'parameter':23 'pattern':34 'peer':40 'pg':77 'pipeabl':19 'placehold':80 'pointfre':61 'postgr':75 'postgresql':76 'prepar':78 'provid':13 'queri':25,68 'raw':54 'requir':39 'setnam':64 'sql':2,10,24,48,56 'sql-template-str':9,47,55 'sql-template-strings-t':1 'statement':71,79 'string':4,12,50,58 'templat':3,11,49,57 'ts':5,17,38,44 'typescript':81 'use':35 'usebind':65 'v1.1.0':26 'without':69 'wrapper':7","created_at":"2026-06-05T17:02:18.146702+00:00","updated_at":"2026-06-05T17:02:18.146702+00:00","problems":[{"fix":"import { t } from 'sql-template-strings-ts'","cause":"Importing t as default instead of named export.","error":"TypeError: t is not a function"},{"fix":"npm install fp-ts","cause":"Peer dependency fp-ts not installed.","error":"Cannot find module 'fp-ts'"},{"fix":"import { append } from 'sql-template-strings-ts'","cause":"Importing from 'sql-template-strings' instead of 'sql-template-strings-ts'.","error":"Property 'append' does not exist on type 'typeof import(...)'"}],"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/DenisFrezzato/sql-template-strings-ts","github":"https://github.com/DenisFrezzato/sql-template-strings-ts","docs":null,"changelog":null,"pypi":null,"npm":"sql-template-strings-ts","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}}