diff options
author | Adam Chlipala <adam@chlipala.net> | 2019-12-04 09:19:55 -0500 |
---|---|---|
committer | Adam Chlipala <adam@chlipala.net> | 2019-12-04 09:19:55 -0500 |
commit | 2bca6e48c0ea8043c5300f4ebdefa5167e6472bf (patch) | |
tree | 1c61579ca6a1e1b8e8cbe309302c33857b191181 /tests | |
parent | 73c287964e8d41d9b3b53a81f0ace3f509dc6a20 (diff) |
SQL SIMILAR (via pg_trgm)
Diffstat (limited to 'tests')
-rw-r--r-- | tests/filter.urp | 1 | ||||
-rw-r--r-- | tests/trgm.ur | 25 | ||||
-rw-r--r-- | tests/trgm.urp | 6 | ||||
-rw-r--r-- | tests/trgm.urs | 1 |
4 files changed, 33 insertions, 0 deletions
diff --git a/tests/filter.urp b/tests/filter.urp index 102a1871..ddf1a3df 100644 --- a/tests/filter.urp +++ b/tests/filter.urp @@ -1,4 +1,5 @@ debug database dbname=filter +sql filter.sql filter diff --git a/tests/trgm.ur b/tests/trgm.ur new file mode 100644 index 00000000..45783366 --- /dev/null +++ b/tests/trgm.ur @@ -0,0 +1,25 @@ +table turtles : { Nam : string } + +fun add name = + dml (INSERT INTO turtles(Nam) + VALUES ({[name]})) + +fun closest name = + List.mapQuery (SELECT * + FROM turtles + ORDER BY similarity(turtles.Nam, {[name]}) DESC + LIMIT 5) + (fn r => r.Turtles.Nam) + +val main = + name <- source ""; + results <- source []; + return <xml><body> + Name: <ctextbox source={name}/><br/> + <button value="Add" onclick={fn _ => n <- get name; rpc (add n)}/><br/> + <button value="Search" onclick={fn _ => n <- get name; ls <- rpc (closest n); set results ls}/><br/> + <dyn signal={rs <- signal results; + return <xml><ol> + {List.mapX (fn n => <xml><li>{[n]}</li></xml>) rs} + </ol></xml>}/> + </body></xml> diff --git a/tests/trgm.urp b/tests/trgm.urp new file mode 100644 index 00000000..326151e7 --- /dev/null +++ b/tests/trgm.urp @@ -0,0 +1,6 @@ +database dbname=trgm +sql trgm.sql +rewrite all Trgm/* + +$/list +trgm diff --git a/tests/trgm.urs b/tests/trgm.urs new file mode 100644 index 00000000..61778b87 --- /dev/null +++ b/tests/trgm.urs @@ -0,0 +1 @@ +val main : transaction page |