Implement db.select where= with simple map and filter-table ops.
Equality maps and |字段|操作|值| rows (including like) feed parameterized AND clauses; admin smoke resets the SQLite sequence for stable ids. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
02b3dfab48
commit
c181b74a88
10 files changed
+206
-13
No files matched your search
@@ -11,6 +11,8 @@ description: Schema-derived admin forms share validate/submit (offline).
|
||||
*`store` = > web.db url="sqlite:web-fixtures/data/admin-smoke.db" *
|
||||
*`schema` = > articles.schema *
|
||||
> `store`.init name=articles fields=`schema`
|
||||
> `store`.exec sql="DELETE FROM articles"
|
||||
> `store`.exec sql="DELETE FROM sqlite_sequence WHERE name='articles'"
|
||||
*`url` = > json.get value=`store` key=url *
|
||||
|
||||
*`info` = > web_db_table_info url=`url` table=articles *
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
---
|
||||
title: web db.select where smoke
|
||||
description: Offline select with map and filter-table where (no listen).
|
||||
> ext/web/web.mq.md
|
||||
> web-fixtures/db/articles.mq.md as articles
|
||||
> lib/json.mq.md
|
||||
---
|
||||
|
||||
# main
|
||||
|
||||
*`store` = > web.db url="sqlite:web-fixtures/data/select-smoke.db" *
|
||||
*`schema` = > articles.schema *
|
||||
> `store`.init name=articles fields=`schema`
|
||||
> `store`.exec sql="DELETE FROM articles"
|
||||
|
||||
`rows` =
|
||||
|
||||
| title | body |
|
||||
|-------|------|
|
||||
| Alpha | first |
|
||||
| Beta | second |
|
||||
| Alpha again | third |
|
||||
|
||||
> `store`.insert table=articles rows=`rows`
|
||||
|
||||
`eq` =
|
||||
|
||||
| title | body |
|
||||
|-------|------|
|
||||
| Alpha | first |
|
||||
|
||||
*`hit` = > `store`.select table=articles where=`eq` limit=50 *
|
||||
*`n` = > len value=`hit` *
|
||||
1. `n` == 1
|
||||
> print text=map-where-ok
|
||||
2. *
|
||||
> print text=map-where-fail
|
||||
|
||||
`filt` =
|
||||
|
||||
| 字段 | 操作 | 值 |
|
||||
|------|------|-----|
|
||||
| title | like | %Alpha% |
|
||||
|
||||
*`like_rows` = > `store`.select table=articles where=`filt` limit=50 *
|
||||
*`ln` = > len value=`like_rows` *
|
||||
1. `ln` == 2
|
||||
> print text=like-ok
|
||||
2. *
|
||||
> print text=like-fail
|
||||
|
||||
*`all` = > `store`.select table=articles limit=50 *
|
||||
*`an` = > len value=`all` *
|
||||
1. `an` == 3
|
||||
> print text=all-ok
|
||||
2. *
|
||||
> print text=all-fail
|
||||
@@ -1325,6 +1325,22 @@ route-part-ok",
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ext_web_select_smoke() {
|
||||
let status = Command::new("cargo")
|
||||
.args(["build", "-p", "marqdo_plugin_web"])
|
||||
.current_dir(env!("CARGO_MANIFEST_DIR"))
|
||||
.status()
|
||||
.expect("build web plugin");
|
||||
assert!(status.success(), "failed to build marqdo_plugin_web");
|
||||
assert_out(
|
||||
"tests/ext/web-select-smoke.mq.md",
|
||||
"map-where-ok
|
||||
like-ok
|
||||
all-ok",
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ext_agent_framework_smoke() {
|
||||
let status = Command::new("cargo")
|
||||
|
||||
Reference in new issue
Block a user