Registry / database / slonik-sql-tag-raw

slonik-sql-tag-raw

JSON →
library49.9.0jsnpmunverified

Slonik SQL tag for constructing dynamic queries. Version 49.9.0 requires Node >=24 and Slonik >=45.0.0. Provides a `raw` function that inlines raw SQL strings with optional positional or named parameter binding. Differentiator: only intended for externally stored static queries, not dynamic query building (use nested `sql` tags instead). Ships TypeScript types. Released under MIT license by gajus.

npm install slonik-sql-tag-raw
INSTALL
IMPORT
SIG · SLONIK-SQL-TAG-RAW
S
slonik-sql-tag-raw
databasejavascriptv49.9.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

raw
import { raw } from 'slonik-sql-tag-raw'
const { raw } = require('slonik-sql-tag-raw')
Package is ESM-only. CommonJS require will fail.
raw (as named import with TypeScript)
import { raw } from 'slonik-sql-tag-raw'
import raw from 'slonik-sql-tag-raw'
Only named export exists. Default import is not available.
RawSqlTokenType (type)
import type { RawSqlTokenType } from 'slonik-sql-tag-raw'
import { RawSqlTokenType } from 'slonik-sql-tag-raw'
This is a type export only available with import type in TypeScript.

Shows importing and using `raw` to inline SQL string and values with positional and named parameters.

import { raw } from 'slonik-sql-tag-raw'; import { sql } from 'slonik'; const tableName = 'users'; const query = sql`SELECT * FROM ${raw(tableName)} WHERE id = ${1}`; console.log(query.sql); // 'SELECT * FROM users WHERE id = $1' console.log(query.values); // [1] // With named parameters const namedQuery = sql`SELECT ${raw(':name, :age', { name: 'Alice', age: 30 })}`; console.log(namedQuery.sql); // 'SELECT $1, $2' console.log(namedQuery.values); // ['Alice', 30]
Debug
Known issues
breakingNode.js >=24 is required; older versions cause runtime errors.
fix
Upgrade Node.js to 24 or later.
affects: >=49.0.0
breakingPeer dependency slonik >=45.0.0 required; incompatible with older versions.
fix
Upgrade slonik to 45.0.0 or later.
affects: >=49.0.0
deprecatedUsing `raw` for dynamic query building (beyond static queries) is discouraged by the author.
fix
Use nested `sql` template tags or other Slonik query building methods instead.
affects: >=1.0.0
gotchaNamed parameter regex only matches `:name` patterns; does not handle uppercase or special characters.
fix
Use lowercase alphanumeric parameter names following the regex /[\s,(]:([a-z_]+)/g.
affects: >=1.0.0
gotchaEmpty string or undefined `sql` argument will produce unexpected SQL tokens.
fix
Ensure `sql` parameter is a non-empty string.
affects: >=1.0.0
Errors
Common errors & fixes
Error [ERR_REQUIRE_ESM]: require() of ES Module not supported.
Using CommonJS require() to import the module.
fix
Use import statement or dynamic import(): `import { raw } from 'slonik-sql-tag-raw'`
TypeError: raw is not a function
Attempting default import instead of named import.
fix
Change to `import { raw } from 'slonik-sql-tag-raw'`
Cannot find module 'slonik-sql-tag-raw' or its corresponding type declarations.
Missing peer dependency slonik or incompatible version.
fix
Install slonik >=45.0.0: `npm install slonik`
Upgrade
Version history
49.9.0latest on npm
Audit
Dependencies
slonikrequiredPeer dependency; required for integration with Slonik query builder.
Agent activity
5 hits · last 30 days
node
4
Meta
1
Resources
slonik-sql-tag-raw — npm install slonik-sql-tag-raw · libregistry