
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
extra-sql-builder
Advanced tools
```sh npm install --save extra-sql-builder # or yarn add extra-sql-builder ```
npm install --save extra-sql-builder
# or
yarn add extra-sql-builder
It is hard to create SQL statements programmatically:
// INSERT INTO my_table (id, value)
// VALUES (1, 'hello'), (2, 'world');
const cond = true
const result1 = sql(
INSERT_INTO('my_table', ['id', 'value'])
, VALUES(
[integer(1), text('hello')],
cond && [integer(2), text('world')]
)
)
// or
const result2 = sql(
'INSERT INTO my_table (id, value)'
, VALUES(
[integer('1'), text('hello')]
, cond && [integer('2'), text('world')]
)
)
// or
const result3 = sql`
INSERT INTO my_table (id, value)
VALUES (1, 'hello')
${cond && `, (2, 'world')`};
`
// or
const result4 = `
INSERT INTO my_table (id, value)
${VALUES(
[integer('1'), text('hello')]
, cond && [integer('2'), text('world')]
)};
`
// or
const values = VALUES([integer('1'), text('hello')])
if (cond) {
values.values.push([integer('2'), text('world')])
}
const result5 = `
INSERT INTO my_table (id, value)
${values};
`
function sql(...fragments: Array<string | Falsy>): string
function sql(strings: TemplateStringsArray, ...values: unknown[]): string
function sql(...args: unknown[]): string
class ParameterCollector<T> {
constructor(prefix: string)
add(value: T): string
toRecord(): Record<string, T>
toArray(): T[]
}
const collector = new ParameterCollector('$param')
query(
sql`
INSERT INTO table (value)
VALUES (${collector.add(123)})
, (${collector.add(456)})
`
// INSERT INTO table (value)
// VALUES ($param1)
// , ($param2)
, collector.toRecord()
// {
// param1: 123
// , param2: 456
// }
)
const collector = new ParameterCollector('$')
query(
sql`
INSERT INTO table (value)
VALUES (${collector.add(123)})
, (${collector.add(456)})
`
// INSERT INTO table (value)
// VALUES ($1)
// , ($2)
, collector.toArray()
// [123, 456]
)
function boolean(val: boolean): string
function nullableBoolean(val: Nullable<boolean>): string
function integer(val: number): string
function nullableInteger(val: Nullable<number>): string
function json(val: object): string
function nullableJson(val: Nullable<object>): string
function text(val: string): string
function nullableText(val: Nullable<string>): string
function AND(condition: string): string
function DELETE_FROM(table: string): string
function FROM(...tables: Array<string | Falsy>): string
function FULL_OUTER_JOIN(table: string): string
function GROUP_BY(...fields: Array<string | Falsy>): string
function HAVING(condition: string): string
function INNER_JOIN(table: string): string
function INSERT_INTO(table: string, fields: Array<string | Falsy>): string
function INTO(table: string): string
function LEFT_OUTER_JOIN(table: string): string
function LIMIT(limit: number): string
function OFFSET(offset: number): string
function ON(condition: string): string
function OR(condition: string): string
function ORDER_BY(...fields: Array<string | Falsy>): string
function RIGHT_OUTER_JOIN(table: string): string
function SELECT(...fields: Array<string | Falsy>): string
function SET(...statements: Array<string | Falsy>): string
function UNION(all: unknown = false): string
function UPDATE(table: string): string
function VALUES<T extends string[] | Falsy>(...values: [T, ...T[]]): string
function WHERE(condition: string): string
As long as you don't take user input as a parameter, there will be no SQL injection vulnerability.
FAQs
```sh npm install --save extra-sql-builder # or yarn add extra-sql-builder ```
The npm package extra-sql-builder receives a total of 1 weekly downloads. As such, extra-sql-builder popularity was classified as not popular.
We found that extra-sql-builder demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.