Skip to content

Commit ea75ae7

Browse files
committed
Rename
1 parent 4977f38 commit ea75ae7

File tree

3 files changed

+24
-21
lines changed

3 files changed

+24
-21
lines changed

README.md

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
# sql-query-builder
1+
# sql-string-builder
2+
3+
[![CI](https://github.com/glideapps/sql-string-builder/actions/workflows/ci.yml/badge.svg)](https://github.com/glideapps/sql-string-builder/actions/workflows/ci.yml)
4+
[![npm version](https://img.shields.io/npm/v/sql-string-builder.svg)](https://www.npmjs.com/package/sql-string-builder)
25

36
This package provides utilities for building SQL query strings in a safe, composable, and parameterized manner. It is designed to prevent SQL injection vulnerabilities and enhance code readability when constructing complex queries.
47

@@ -7,7 +10,7 @@ Primary author: [Alex Corrado](https://github.com/chkn)
710
## Installation
811

912
```bash
10-
npm install sql-query-builder
13+
npm install sql-string-builder
1114
```
1215

1316
## Core Concepts
@@ -22,7 +25,7 @@ Additionally, the package offers `UnsafeQueryLiteral` for situations where direc
2225
## `sql` Tagged Template Literal
2326

2427
```typescript
25-
import { sql } from "sql-query-builder";
28+
import { sql } from "sql-string-builder";
2629
```
2730

2831
The `sql` tagged template literal is the most convenient and recommended way to create `QueryStringBuilder` instances. It allows you to write SQL queries in a template literal syntax, embedding JavaScript/TypeScript expressions as parameterized values.
@@ -40,7 +43,7 @@ const query = sql`SQL query text with ${parameter1} and ${parameter2}`;
4043
**Example:**
4144

4245
```typescript
43-
import { sql } from "sql-query-builder";
46+
import { sql } from "sql-string-builder";
4447

4548
const productName = "Awesome Gadget";
4649
const price = 99.99;
@@ -60,7 +63,7 @@ console.log(values); // Output: [ 'Awesome Gadget', 99.99 ]
6063
## `UnsafeQueryLiteral`
6164

6265
```typescript
63-
import { UnsafeQueryLiteral } from "sql-query-builder";
66+
import { UnsafeQueryLiteral } from "sql-string-builder";
6467
```
6568

6669
`UnsafeQueryLiteral` is a special type that wraps a string. When a `QueryStringBuilder` encounters an `UnsafeQueryLiteral`, it **directly interpolates** the string value into the SQL query without parameterization or escaping.
@@ -77,7 +80,7 @@ import { UnsafeQueryLiteral } from "sql-query-builder";
7780
**Example (Use with Caution - for illustration only):**
7881

7982
```typescript
80-
import { sql, UnsafeQueryLiteral } from "sql-query-builder";
83+
import { sql, UnsafeQueryLiteral } from "sql-string-builder";
8184

8285
const tableName = new UnsafeQueryLiteral("users_table"); // Static, known table name
8386
const columnName = new UnsafeQueryLiteral("username"); // Static, known column name
@@ -94,7 +97,7 @@ console.log(values); // Output: [ 123 ]
9497
## `QueryStringBuilder`
9598

9699
```typescript
97-
import { QueryStringBuilder, sql } from "sql-query-builder";
100+
import { QueryStringBuilder, sql } from "sql-string-builder";
98101
```
99102

100103
`QueryStringBuilder` is the primary class in this package for constructing SQL queries. It provides a fluent interface for appending SQL fragments and parameterized values.
@@ -132,7 +135,7 @@ Appends another `QueryStringBuilder` to the current builder. This is the core me
132135
**Example:**
133136

134137
```typescript
135-
import { sql } from "sql-query-builder";
138+
import { sql } from "sql-string-builder";
136139

137140
const selectClause = sql`SELECT * FROM users`;
138141
const whereClause = sql`WHERE age > ${18}`;
@@ -163,7 +166,7 @@ Similar to `UnsafeQueryLiteral`, `appendRawString` bypasses parameterization and
163166
**Example (Use with Caution - for illustration only):**
164167

165168
```typescript
166-
import { sql } from "sql-query-builder";
169+
import { sql } from "sql-string-builder";
167170

168171
const orderByClause = sql`ORDER BY created_at`;
169172
const direction = "DESC"; // Static, known direction
@@ -186,7 +189,7 @@ Creates a new, mutable `QueryStringBuilder` that is a copy of the current builde
186189
**Example:**
187190

188191
```typescript
189-
import { sql } from "sql-query-builder";
192+
import { sql } from "sql-string-builder";
190193

191194
const baseQuery = sql`SELECT * FROM products`;
192195
const query1 = baseQuery.clone().append(sql` WHERE price < ${100}`);
@@ -221,7 +224,7 @@ Finalizes the `QueryStringBuilder` and generates the SQL query string and an arr
221224
**Example:**
222225

223226
```typescript
224-
import { sql } from "sql-query-builder";
227+
import { sql } from "sql-string-builder";
225228

226229
const name = "John Doe";
227230
const age = 30;
@@ -246,7 +249,7 @@ Returns an approximate length of the SQL query string being built. This can be u
246249
**Example:**
247250

248251
```typescript
249-
import { sql } from "sql-query-builder";
252+
import { sql } from "sql-string-builder";
250253

251254
const longQuery = sql``;
252255
for (let i = 0; i < 100; i++) {
@@ -258,7 +261,7 @@ console.log(longQuery.approximateLength()); // Output: A number representing the
258261

259262
## Helper Functions
260263

261-
The `sql-query-builder` package provides several helper functions to simplify common SQL construction tasks.
264+
The `sql-string-builder` package provides several helper functions to simplify common SQL construction tasks.
262265

263266
### `joinSQL(items: readonly QueryStringBuilder[], separator: string): QueryStringBuilder`
264267

@@ -276,7 +279,7 @@ Joins an array of `QueryStringBuilder` instances into a single `QueryStringBuild
276279
**Example:**
277280

278281
```typescript
279-
import { sql, joinSQL } from "sql-query-builder";
282+
import { sql, joinSQL } from "sql-string-builder";
280283

281284
const conditions = [
282285
sql`age > ${18}`,
@@ -308,7 +311,7 @@ A convenience function that joins an array of `QueryStringBuilder` instances usi
308311
**Example:**
309312

310313
```typescript
311-
import { sql, commaJoinSQL } from "sql-query-builder";
314+
import { sql, commaJoinSQL } from "sql-string-builder";
312315

313316
const columns = [sql`name`, sql`email`, sql`created_at`];
314317

@@ -336,7 +339,7 @@ A helper function that takes an array of strings and converts them into a comma-
336339
**Example:**
337340

338341
```typescript
339-
import { sql, commaJoinStringsToSQL } from "sql-query-builder";
342+
import { sql, commaJoinStringsToSQL } from "sql-string-builder";
340343

341344
const userEmails = [
342345
@@ -360,7 +363,7 @@ console.log(values); // Output: [ '[email protected]', '[email protected]', 'use
360363
- **SQL Injection Prevention:** This package is designed to help prevent SQL injection vulnerabilities by promoting the use of parameterized queries. Always use parameterized values (using `${expression}` within the `sql` template literal) for any data that originates from user input or untrusted sources.
361364
- **`UnsafeQueryLiteral` and `appendRawString`:** These features should be used with extreme caution and only when absolutely necessary for static, trusted parts of the SQL query. Improper use can reintroduce SQL injection risks. Thoroughly review and understand the security implications before using them.
362365

363-
By using the `sql-query-builder` package correctly, you can build robust, readable, and secure SQL queries in your applications.
366+
By using the `sql-string-builder` package correctly, you can build robust, readable, and secure SQL queries in your applications.
364367

365368
## License
366369

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "sql-query-builder",
2+
"name": "sql-string-builder",
33
"version": "0.0.1",
44
"description": "Builds SQL query strings and parameters from an interpolated string",
55
"main": "dist/index.js",
@@ -26,7 +26,7 @@
2626
"license": "MIT",
2727
"repository": {
2828
"type": "git",
29-
"url": "git+https://github.com/glideapps/sql-query-builder.git"
29+
"url": "git+https://github.com/glideapps/sql-string-builder.git"
3030
},
3131
"dependencies": {
3232
"@glideapps/ts-necessities": "^2.4.0"

0 commit comments

Comments
 (0)