Skip to content

Commit bb9ecbc

Browse files
authored
Merge branch 'main' into markdown-dangerous-options
2 parents 811568f + e75fc22 commit bb9ecbc

File tree

16 files changed

+637
-179
lines changed

16 files changed

+637
-179
lines changed

CHANGELOG.md

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

3-
## 0.33.1 (unreleased)
3+
## 0.33.1 (2025-02-25)
44

55
- Fix a bug where the table component would not format numbers if sorting was not enabled.
66
- Fix a bug with date sorting in the table component.
77
- Center table descriptions.
88
- Fix a rare crash on startup in some restricted linux environments.
9+
- Fix a rare but serious issue when on SQLite and MySQL, some variable values were assigned incorrectly
10+
- `CASE WHEN $a THEN $x WHEN $b THEN $y` would be executed as `CASE WHEN $a THEN $b WHEN $x THEN $y` on these databases.
11+
- the issue only occured when using in case expressions where variables were used both in conditions and results.
12+
- Implement parameter deduplication.
13+
Now, when you write `select $x where $x is not null`, the value of `$x` is sent to the database only once. It used to be sent as many times as `$x` appeared in the statement.
14+
- Improve error messages on invalid sqlpage function calls. The messages now contain actionable advice.
15+
- Fix top navigation bar links color. They appeared "muted", with low contrast, since v0.33
16+
- update to apex charts v4.5.0. This fixes a bug where tick positions in scatter plots would be incorrect.
17+
- New function: `sqlpage.fetch_with_meta`
18+
- This function is similar to `sqlpage.fetch`, but it returns a json object with the following properties:
19+
- `status`: the http status code of the response.
20+
- `headers`: a json object with the response headers.
21+
- `body`: the response body.
22+
- `error`: an error message if the request failed.
23+
- This is useful when interacting with complex or unreliable external APIs.
924

1025
## 0.33.0 (2025-02-15)
1126

Cargo.lock

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

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "sqlpage"
3-
version = "0.33.0"
3+
version = "0.33.1"
44
edition = "2021"
55
description = "Build data user interfaces entirely in SQL. A web server that takes .sql files and formats the query result using pre-made configurable professional-looking components."
66
keywords = ["web", "sql", "framework"]

build.rs

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use actix_rt::spawn;
2+
use actix_rt::time::sleep;
23
use libflate::gzip;
34
use std::collections::hash_map::DefaultHasher;
45
use std::fs::File;
@@ -99,21 +100,37 @@ fn copy_cached_to_opened_file(source: &Path, outfile: &mut impl std::io::Write)
99100
}
100101

101102
async fn download_url_to_path(client: &awc::Client, url: &str, path: &Path) {
102-
let mut resp = client.get(url).send().await.unwrap_or_else(|err| {
103-
let path = make_url_path(url);
104-
panic!(
105-
"We need to download external frontend dependencies to build the static frontend. \n\
106-
Could not download static asset. You can manually download the file with: \n\
107-
curl {url:?} > {path:?} \n\
108-
{err}"
109-
)
110-
});
111-
if resp.status() != 200 {
112-
panic!("Received {} status code from {}", resp.status(), url);
103+
let mut attempt = 1;
104+
let max_attempts = 2;
105+
106+
loop {
107+
match client.get(url).send().await {
108+
Ok(mut resp) => {
109+
if resp.status() != 200 {
110+
panic!("Received {} status code from {}", resp.status(), url);
111+
}
112+
let bytes = resp.body().limit(128 * 1024 * 1024).await.unwrap();
113+
std::fs::write(path, &bytes)
114+
.expect("Failed to write external frontend dependency to local file");
115+
break;
116+
}
117+
Err(err) => {
118+
if attempt >= max_attempts {
119+
let path = make_url_path(url);
120+
panic!(
121+
"We need to download external frontend dependencies to build the static frontend. \n\
122+
Could not download static asset after {} attempts. You can manually download the file with: \n\
123+
curl {url:?} > {path:?} \n\
124+
{err}",
125+
max_attempts
126+
);
127+
}
128+
sleep(Duration::from_secs(1)).await;
129+
println!("cargo:warning=Retrying download of {url} after {err}.");
130+
attempt += 1;
131+
}
132+
}
113133
}
114-
let bytes = resp.body().limit(128 * 1024 * 1024).await.unwrap();
115-
std::fs::write(path, &bytes)
116-
.expect("Failed to write external frontend dependency to local file");
117134
}
118135

119136
// Given a filename, creates a new unique filename based on the file contents

examples/official-site/sqlpage/migrations/40_fetch.sql

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,12 @@ The fetch function accepts either a URL string, or a JSON object with the follow
8888
- `username`: Optional username for HTTP Basic Authentication. Introduced in version 0.33.0.
8989
- `password`: Optional password for HTTP Basic Authentication. Only used if username is provided. Introduced in version 0.33.0.
9090
91+
# Error handling and reading response headers
92+
93+
If the request fails, this function throws an error, that will be displayed to the user.
94+
The response headers are not available for inspection.
95+
96+
If you need to handle errors or inspect the response headers, use [`sqlpage.fetch_with_meta`](?function=fetch_with_meta).
9197
'
9298
);
9399
INSERT INTO sqlpage_function_parameters (

0 commit comments

Comments
 (0)