Skip to content

Commit f3f1440

Browse files
committed
update sql parser
fixes #133 fixes #127
1 parent 8e69339 commit f3f1440

File tree

4 files changed

+54
-30
lines changed

4 files changed

+54
-30
lines changed

CHANGELOG.md

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# CHANGELOG.md
22

3-
## unreleased
3+
## 0.17.0
44

55
### Uploads
66

@@ -110,6 +110,30 @@ No need to restart SQLPage either, or to worry about renewing your certificate w
110110
SQLPage will automatically request a certificate from [Let's Encrypt](https://letsencrypt.org/) by default,
111111
and does not even need to listen on port 80 to do so.
112112

113+
### SQL parser improvements
114+
115+
SQLPage needs to parse SQL queries to be able to bind the right parameters to them,
116+
and to inject the results of built-in sqlpage functions in them.
117+
The parser we user is very powerful and supports most SQL features,
118+
but there are some edge cases where it fails to parse a query.
119+
That's why we contribute to it a lot, and bring the latest version of the parser to SQLPage as soon as it is released.
120+
121+
#### JSON functions in MS SQL Server
122+
123+
SQLPage now supports the [`FOR JSON` syntax](https://learn.microsoft.com/en-us/sql/relational-databases/json/format-query-results-as-json-with-for-json-sql-server?view=sql-server-ver16&tabs=json-path) in MS SQL Server.
124+
125+
This unlocks a lot of new possibilities, that were previously only available in other databases.
126+
127+
This is particularly interesting to build complex menus with the `shell` component,
128+
to build multiple-answer select inputs with the `form` component,
129+
and to create JSON APIs.
130+
131+
#### Other sql syntax enhancements
132+
133+
- SQLPage now supports the custom `CONVERT` expression syntax for MS SQL Server, and the one for MySQL.
134+
- SQLPage now supports the `VARCHAR(MAX)` type in MS SQL Server.
135+
- `INSERT INTO ... DEFAULT VALUES ...` is now supported
136+
113137
### Other news
114138

115139
- Dates and timestamps returned from the database are now always formatted in ISO 8601 format, which is the standard format for dates in JSON. This makes it easier to use dates in SQLPage.

Cargo.lock

Lines changed: 26 additions & 26 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "sqlpage"
3-
version = "0.16.1"
3+
version = "0.17.0"
44
edition = "2021"
55
description = "A SQL-only web application framework. Takes .sql files and formats the query result using pre-made configurable professional-looking components."
66
keywords = ["web", "sql", "framework"]
@@ -34,7 +34,7 @@ anyhow = "1"
3434
serde = "1"
3535
serde_json = { version = "1.0.82", features = ["preserve_order"] }
3636
lambda-web = { version = "0.2.1", features = ["actix4"], optional = true }
37-
sqlparser = { version = "0.39.0", features = ["visitor"] }
37+
sqlparser = { version = "0.40.0", features = ["visitor"] }
3838
async-stream = "0.3"
3939
async-trait = "0.1.61"
4040
async-recursion = "1.0.0"

src/webserver/database/sql.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ impl ParameterExtractor {
274274
let data_type = match self.db_kind {
275275
// MySQL requires CAST(? AS CHAR) and does not understand CAST(? AS TEXT)
276276
AnyKind::MySql => DataType::Char(None),
277-
AnyKind::Mssql => DataType::Varchar(Some(CharacterLength {
277+
AnyKind::Mssql => DataType::Varchar(Some(CharacterLength::IntegerLength {
278278
length: 8000,
279279
unit: None,
280280
})),

0 commit comments

Comments
 (0)