Skip to content

Commit

Permalink
update sql parser
Browse files Browse the repository at this point in the history
  • Loading branch information
lovasoa committed Feb 14, 2025
1 parent 389bad3 commit 436ca17
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 23 deletions.
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,29 @@
- Add a new `description_md` row-level property to the form component to allow displaying markdown in a form field description.
- Improve the error message when a header component (e.g. status_code, json, cookie) is used in the wrong place (after data has already been sent to the client).
- New function: [`sqlpage.headers`](https://sql-page.com/functions.sql?function=headers).
- Updated sqlparser to [v0.54](https://github.com/apache/datafusion-sqlparser-rs/blob/main/changelog/0.54.0.md) which fixes parse errors when using some advanced SQL syntax
- Add support for `INSERT INTO ... SELECT ... RETURNING` statements, like
```sql
INSERT INTO table1(x, y)
SELECT :x, :y
WHERE :x IS NOT NULL
RETURNING
'redirect' as component,
'inserted.sql?id=' || id as link;
```
- Add support for PostgreSQL's `overlaps` operator, like
```sql
select 'card' as component;
select event_name as title, start_time || ' - ' || end_time as description
from events
where (start_time, end_time) overlaps ($start_filter::timestamp, $end_filter::timestamp);
```
- Add support for MySQL's `INSERT INTO ... SET` syntax, like
```sql
insert into users
set name = :name, email = :email
```


## 0.32.1 (2025-01-03)

Expand Down
84 changes: 63 additions & 21 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ anyhow = "1"
serde = "1"
serde_json = { version = "1.0.82", features = ["preserve_order", "raw_value"] }
lambda-web = { version = "0.2.1", features = ["actix4"], optional = true }
sqlparser = { version = "0.53.0", features = ["visitor"] }
sqlparser = { version = "0.54.0", features = ["visitor"] }
async-stream = "0.3"
async-trait = "0.1.61"
async-recursion = "1.0.0"
Expand Down
6 changes: 5 additions & 1 deletion src/webserver/database/sql_to_json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,9 @@ mod tests {
INTERVAL '4 hours' as hour_interval,
INTERVAL '1.5 days' as fractional_interval,
'{\"key\": \"value\"}'::JSON as json,
'{\"key\": \"value\"}'::JSONB as jsonb",
'{\"key\": \"value\"}'::JSONB as jsonb,
age('2024-03-14'::timestamp, '2024-01-01'::timestamp) as age_interval,
justify_interval(interval '1 year 2 months 3 days') as justified_interval",
)
.fetch_one(&mut c)
.await?;
Expand All @@ -208,6 +210,8 @@ mod tests {
"fractional_interval": "1 day 12:00:00",
"json": {"key": "value"},
"jsonb": {"key": "value"},
"age_interval": "2 mons 13 days",
"justified_interval": "1 year 2 mons 3 days"
}),
);
Ok(())
Expand Down

0 comments on commit 436ca17

Please sign in to comment.