Skip to content

Commit

Permalink
Merge branch 'main' into markdown-dangerous-options
Browse files Browse the repository at this point in the history
  • Loading branch information
lovasoa authored Feb 25, 2025
2 parents 811568f + e75fc22 commit bb9ecbc
Show file tree
Hide file tree
Showing 16 changed files with 637 additions and 179 deletions.
17 changes: 16 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,26 @@
# CHANGELOG.md

## 0.33.1 (unreleased)
## 0.33.1 (2025-02-25)

- Fix a bug where the table component would not format numbers if sorting was not enabled.
- Fix a bug with date sorting in the table component.
- Center table descriptions.
- Fix a rare crash on startup in some restricted linux environments.
- Fix a rare but serious issue when on SQLite and MySQL, some variable values were assigned incorrectly
- `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.
- the issue only occured when using in case expressions where variables were used both in conditions and results.
- Implement parameter deduplication.
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.
- Improve error messages on invalid sqlpage function calls. The messages now contain actionable advice.
- Fix top navigation bar links color. They appeared "muted", with low contrast, since v0.33
- update to apex charts v4.5.0. This fixes a bug where tick positions in scatter plots would be incorrect.
- New function: `sqlpage.fetch_with_meta`
- This function is similar to `sqlpage.fetch`, but it returns a json object with the following properties:
- `status`: the http status code of the response.
- `headers`: a json object with the response headers.
- `body`: the response body.
- `error`: an error message if the request failed.
- This is useful when interacting with complex or unreliable external APIs.

## 0.33.0 (2025-02-15)

Expand Down
70 changes: 35 additions & 35 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
@@ -1,6 +1,6 @@
[package]
name = "sqlpage"
version = "0.33.0"
version = "0.33.1"
edition = "2021"
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."
keywords = ["web", "sql", "framework"]
Expand Down
45 changes: 31 additions & 14 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use actix_rt::spawn;
use actix_rt::time::sleep;
use libflate::gzip;
use std::collections::hash_map::DefaultHasher;
use std::fs::File;
Expand Down Expand Up @@ -99,21 +100,37 @@ fn copy_cached_to_opened_file(source: &Path, outfile: &mut impl std::io::Write)
}

async fn download_url_to_path(client: &awc::Client, url: &str, path: &Path) {
let mut resp = client.get(url).send().await.unwrap_or_else(|err| {
let path = make_url_path(url);
panic!(
"We need to download external frontend dependencies to build the static frontend. \n\
Could not download static asset. You can manually download the file with: \n\
curl {url:?} > {path:?} \n\
{err}"
)
});
if resp.status() != 200 {
panic!("Received {} status code from {}", resp.status(), url);
let mut attempt = 1;
let max_attempts = 2;

loop {
match client.get(url).send().await {
Ok(mut resp) => {
if resp.status() != 200 {
panic!("Received {} status code from {}", resp.status(), url);
}
let bytes = resp.body().limit(128 * 1024 * 1024).await.unwrap();
std::fs::write(path, &bytes)
.expect("Failed to write external frontend dependency to local file");
break;
}
Err(err) => {
if attempt >= max_attempts {
let path = make_url_path(url);
panic!(
"We need to download external frontend dependencies to build the static frontend. \n\
Could not download static asset after {} attempts. You can manually download the file with: \n\
curl {url:?} > {path:?} \n\
{err}",
max_attempts
);
}
sleep(Duration::from_secs(1)).await;
println!("cargo:warning=Retrying download of {url} after {err}.");
attempt += 1;
}
}
}
let bytes = resp.body().limit(128 * 1024 * 1024).await.unwrap();
std::fs::write(path, &bytes)
.expect("Failed to write external frontend dependency to local file");
}

// Given a filename, creates a new unique filename based on the file contents
Expand Down
6 changes: 6 additions & 0 deletions examples/official-site/sqlpage/migrations/40_fetch.sql
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,12 @@ The fetch function accepts either a URL string, or a JSON object with the follow
- `username`: Optional username for HTTP Basic Authentication. Introduced in version 0.33.0.
- `password`: Optional password for HTTP Basic Authentication. Only used if username is provided. Introduced in version 0.33.0.
# Error handling and reading response headers
If the request fails, this function throws an error, that will be displayed to the user.
The response headers are not available for inspection.
If you need to handle errors or inspect the response headers, use [`sqlpage.fetch_with_meta`](?function=fetch_with_meta).
'
);
INSERT INTO sqlpage_function_parameters (
Expand Down
Loading

0 comments on commit bb9ecbc

Please # to comment.