sql-love 1.1.1 → 1.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,13 +1,13 @@
1
- <img alt="SQL Love Logo" src="https://github.com/kensnyder/sql-love/raw/main/assets/sql-love-logo.png?v=1.1.0" width="250" height="208" />
1
+ <img alt="SQL Love Logo" src="https://github.com/kensnyder/sql-love/raw/main/assets/sql-love-logo.png?v=1.1.4" width="250" height="208" />
2
2
 
3
3
  # sql-love
4
4
 
5
- [![NPM Link](https://badgen.net/npm/v/sql-love?v=1.1.0)](https://npmjs.com/package/sql-love)
6
- [![Language](https://badgen.net/static/language/TS?v=1.1.0)](https://github.com/search?q=repo:kensnyder/sql-love++language:TypeScript&type=code)
7
- [![Code Coverage](https://codecov.io/gh/kensnyder/sql-love/branch/main/graph/badge.svg?v=1.1.0)](https://codecov.io/gh/kensnyder/sql-love)
5
+ [![Language](https://badgen.net/static/language/TS?v=1.1.4)](https://github.com/search?q=repo:kensnyder/sql-love++language:TypeScript&type=code)
6
+ [![Code Coverage](https://codecov.io/gh/kensnyder/sql-love/branch/main/graph/badge.svg?v=1.1.4)](https://codecov.io/gh/kensnyder/sql-love)
8
7
  ![Dependencies](https://badgen.net/static/dependencies/0/green)
9
8
  ![Tree shakeable](https://badgen.net/static/tree%20shakeable/Yes/green)
10
- [![ISC License](https://badgen.net/static/license/ISC/green?v=1.1.0)](https://opensource.org/licenses/ISC)
9
+ ![Gzip Size](https://badgen.net/static/gzip%20size/9kb/blue)
10
+ [![ISC License](https://badgen.net/static/license/ISC/green?v=1.1.4)](https://opensource.org/licenses/ISC)
11
11
 
12
12
  Classes for parsing and building SQL select queries in Node/Bun/Deno.
13
13
 
@@ -189,7 +189,7 @@ Use the following methods to build queries. And see
189
189
  - `query.having(columnValueRecord)` - Add multiple conditions
190
190
  - `query.orHaving(expressions)` - Multiple `having()`s joined by OR
191
191
  - `query.orderBy(column, direction)` - Add ORDER BY clause
192
- - `query.sortField(column, mapNames, modifier)` - Add ORDER BY clause with mapNames
192
+ - `query.sortField(field, mapNames, modifier)` - Add ORDER BY clause for an allowed field in mapNames
193
193
  - `query.limit(num)` - Limit by the given number
194
194
  - `query.offset(num)` - Specify an offset
195
195
  - `query.page(num)` - Automatically calculate offset based on limit and page
@@ -316,8 +316,11 @@ query.orderBy('modified_at DESC NULLS LAST'); // ORDER BY modified_at DESC NULLS
316
316
  query.orderBy('modified_at USING >'); // ORDER BY modified_at USING >
317
317
 
318
318
  // Sorting with support for hyphens and mapping
319
- query.sortField('-modified_at'); // ORDER BY modified_at DESC
319
+ // Only fields present in mapNames are allowed, so field names may safely
320
+ // come from user input (e.g. a "?sort=-created" query string param).
321
+ // Unknown fields emit a console.warn and add no ORDER BY clause.
320
322
  query.sortField('-created', { created: 'created_at' }); // ORDER BY created_at DESC
323
+ query.sortField('-foo', { created: 'created_at' }); // console.warn; no ORDER BY added
321
324
  query.sortField(
322
325
  '-created_at',
323
326
  {