Skip to content

Commit 09e3ef7

Browse files
committed
document the sqlpage function parameter rule relaxation
1 parent f643eaf commit 09e3ef7

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@
88
- Added a [new example](https://github.com/lovasoa/SQLpage/tree/main/examples/CRUD%20-%20Authentication) to the documentation
99
- Bug fix: points with a latitude of 0 are now displayed correctly on the map component.
1010
- Bug fix: in sqlite, lower(NULL) now returns NULL instead of an empty string. This is consistent with the standard behavior of lower() in other databases. SQLPage has its own implementation of lower() that supports unicode characters, and our implementation now matches the standard behavior of lower() in mainstream SQLite.
11-
- Allow passing data from the database to sqlpage functions. This fixes most errors like: `Arbitrary SQL expressions as function arguments are not supported.`.
11+
- Allow passing data from the database to sqlpage functions.
12+
- SQLPage functions are special, because they are not executed inside your database, but by SQLPage itself before sending the query to your database. Thus, they used to require all the parameters to be known at the time the query is sent to your database.
13+
- This limitation is now relaxed, and you can pass data from your database to SQLPage functions, at one condition: the function must be called at the top level of a `SELECT` statement. In this case, SQLPage will get the value of the function arguments from the database, and then execute the function after the query has been executed.
14+
- This fixes most errors like: `Arbitrary SQL expressions as function arguments are not supported.`.
1215
- Better error messages in the dynamic component when properties are missing.
1316

1417
## 0.24.0 (2024-06-23)

examples/official-site/functions.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ These functions are special, because they are not executed inside your database,
1515
but by SQLPage itself before sending the query to your database.
1616
Thus, they require all the parameters to be known at the time the query is sent to your database.
1717
Function parameters cannot reference columns from the rest of your query.
18+
The only case when you can call a SQLPage function with a parameter that is not a constant is when it appears at the top level of a `SELECT` statement.
19+
For example, `SELECT sqlpage.url_encode(url) FROM t` is allowed because SQLPage can execute `SELECT url FROM t` and then apply the `url_encode` function to each value.
1820
' as contents_md;
1921

2022
select 'list' as component, 'SQLPage functions' as title;

0 commit comments

Comments
 (0)