[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/emacsql a09911a205 125/427: Add LIMIT and OFFSET expanders
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/emacsql a09911a205 125/427: Add LIMIT and OFFSET expanders. |
Date: |
Tue, 13 Dec 2022 02:59:34 -0500 (EST) |
branch: elpa/emacsql
commit a09911a2056b725a7526b5cd36ecf34684518945
Author: Christopher Wellons <wellons@nullprogram.com>
Commit: Christopher Wellons <wellons@nullprogram.com>
Add LIMIT and OFFSET expanders.
---
README.md | 9 +++++++++
emacsql-tests.el | 13 +++++++++++++
emacsql.el | 6 ++++++
3 files changed, 28 insertions(+)
diff --git a/README.md b/README.md
index 0c8f789266..e8d0263b58 100644
--- a/README.md
+++ b/README.md
@@ -170,6 +170,15 @@ Provides `ORDER BY`.
[... :order-by [(width :asc) (- height)]]
```
+#### :limit `<limit>|[<offset> <limit>]`
+
+Provides `LIMIT` and `OFFSET`.
+
+```el
+[... :limit 50]
+[... :limit [150 50]]
+```
+
#### :insert, :replace
Provides `INSERT`, `REPLACE`.
diff --git a/emacsql-tests.el b/emacsql-tests.el
index eb5fcc880c..377e5a794c 100644
--- a/emacsql-tests.el
+++ b/emacsql-tests.el
@@ -102,6 +102,19 @@
([:order-by [(a :asc) ((/ b 2) :desc)]] '()
"ORDER BY a ASC, b / 2 DESC;")))
+(ert-deftest emacsql-limit ()
+ (emacsql-tests-with-queries
+ ([:limit 10] '()
+ "LIMIT 10;")
+ ([:limit $1] '(11)
+ "LIMIT 11;")
+ ([:limit [12]] '()
+ "LIMIT 12;")
+ ([:limit [2 10]] '()
+ "LIMIT 2, 10;")
+ ([:limit [$1 $2]] '(4 30)
+ "LIMIT 4, 30;")))
+
(ert-deftest emacsql-system ()
(should-not (emacsql-sqlite3-unavailable-p))
(emacsql-with-connection (db nil)
diff --git a/emacsql.el b/emacsql.el
index 1deea2ede0..71206e71ab 100644
--- a/emacsql.el
+++ b/emacsql.el
@@ -551,6 +551,12 @@ definitions for return from a `emacsql-defexpander'."
into parts
finally (cl-return (mapconcat #'identity parts ", ")))))))
+(emacsql-defexpander :limit (limits)
+ (emacsql-with-vars "LIMIT "
+ (if (vectorp limits)
+ (mapconcat #'expr limits ", ")
+ (expr limits))))
+
(emacsql-defexpander :create-table (table schema)
(emacsql-with-vars "CREATE "
(let (temporary if-not-exists name)
- [nongnu] elpa/emacsql e8c090e11f 353/427: Improve Makefile portability and dump Cask, (continued)
- [nongnu] elpa/emacsql e8c090e11f 353/427: Improve Makefile portability and dump Cask, ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 0ba12b89d5 084/427: Drop "work in progress.", ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 364bf466ea 086/427: Linkify the issue in the README., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql dd3f153406 089/427: Drop old with-errors macro., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 72c1954517 096/427: Block on connection until the output has flushed., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 1e9857ccc4 103/427: Allow variables inside vectors., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 8a66563af6 105/427: Combine :insert and :into., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql d04ef64ce0 109/427: Add IF NOT EXISTS and TEMPORARY to CREATE TABLE., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 58641b9827 115/427: Fill out keywords in README., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql fc941d7c75 118/427: Capture a common identifier vector pattern., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql a09911a205 125/427: Add LIMIT and OFFSET expanders.,
ELPA Syncer <=
- [nongnu] elpa/emacsql 8945af0dd8 129/427: Add :check and allow schemas to have variables., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 4206b17f39 134/427: Add support for AS with CREATE TABLE., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 6c32f02139 137/427: Add emacsql-thread macro., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 54c180017e 138/427: Add :pragma and note in README., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 5e2ab842f7 139/427: Add foreign key test., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 42c2fd7569 145/427: Tweak limitation wording., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql fe0c7004fc 146/427: Add :begin, :commit, and :rollback., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 2550196816 162/427: Drop SQLite version requirements., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 9a1b4209ba 164/427: Add PostgreSQL front-end., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 5f4c2ed5a7 166/427: Add emacsql-psql-unavailable-p., ELPA Syncer, 2022/12/13