Registry / database / sql-bulkinsert

sql-bulkinsert

JSON →
library1.0.5jsnpmunverified

A JavaScript SQL string builder for PostgreSQL, MySQL, Microsoft SQL Server, Oracle, and SQLite dialects. This fork (v1.0.5) updates the lodash dependency to resolve a vulnerability in the original `brianc/node-sql` package. Active maintenance unknown; no recent releases. Key differentiator: builds parameterized SQL queries programmatically with composable table definitions, joins, and named queries. TypeScript types included.

npm install sql-bulkinsert
INSTALL
IMPORT
SIG · SQL-BULKINSERT
S
sql-bulkinsert
databasejavascriptv1.0.5
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.

default
import sql from 'sql-bulkinsert'
import * as sql from 'sql-bulkinsert'
ESM default export. TypeScript users should set 'esModuleInterop'.
require
const sql = require('sql-bulkinsert')
CommonJS require works as the package provides both ESM and CJS.
define
const user = sql.define({ name: 'user', columns: ['id', 'name'] })
const user = sql.define('user', ['id', 'name'])
define() expects an object, not positional arguments.

Basic query building: define a table, select columns, add where clause, and get parameterized SQL text and values.

import sql from 'sql-bulkinsert'; sql.setDialect('postgres'); const user = sql.define({ name: 'user', columns: ['id', 'name', 'email'] }); const query = user.select(user.id, user.name) .from(user) .where(user.name.equals('Alice')) .toQuery(); console.log(query.text); // SELECT "user"."id", "user"."name" FROM "user" WHERE ("user"."name" = $1) console.log(query.values); // ['Alice']
Debug
Known issues
gotchasetDialect('mysql') generates different SQL syntax. Always set dialect before query building.
fix
Call sql.setDialect('postgres') (or your target) at the start of your app.
affects: >=1.0.0
deprecatedThe original brianc/node-sql is unmaintained with a known lodash vulnerability. This fork fixes that but may not receive future updates.
fix
Use sql-bulkinsert >=1.0.0 instead of brianc/node-sql.
affects: <=0.0.1
gotchaColumn names with underscores or special chars must be used as-is in JavaScript unless a 'property' alias is defined.
fix
Use { name: 'state_or_province', property: 'state' } in column definition.
affects: >=1.0.0
breakingTypeScript types may be incomplete. The package ships .d.ts but some methods like `toNamedQuery` might lack full typings.
fix
Add custom type declarations if needed, or use `as any` as a workaround.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: Cannot read properties of undefined (reading 'text')
Calling .toQuery() on a query that hasn't been built correctly (e.g., missing .from() or .select()).
fix
Ensure the query chain includes .from() and .select()/update()/delete() before .toQuery().
sql.setDialect is not a function
Using an older version of the package or a different fork that doesn't export setDialect.
fix
Use version >=1.0.0 of sql-bulkinsert and import it correctly (ESM: import sql from 'sql-bulkinsert').
Expected column definition object with 'name' property
Passing an array of strings instead of an object with columns array.
fix
Use { name: 'table', columns: ['col1', 'col2'] } or { name: 'table', columns: [{ name: 'col1' }] }.
Upgrade
Version history
1.0.5latest on npm
Audit
Dependencies
lodashrequiredUsed internally for dialect and query building; updated from vulnerable version.
Agent activity
13 hits · last 30 days
node
10
Meta
1
OpenAI (training)
1
Resources
sql-bulkinsert — npm install sql-bulkinsert · libregistry