Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
451 changes: 286 additions & 165 deletions Cargo.lock

Large diffs are not rendered by default.

24 changes: 17 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,34 @@ panic = "abort"
codegen-units = 2

[dependencies]
sqlx = { package = "sqlx-oldapi", version = "0.6.56", default-features = false, features = [
"any",
"runtime-tokio-rustls",
sqlx = { version = "0.9.0", default-features = false, features = [
"runtime-tokio",
"tls-rustls",
"migrate",
"sqlite",
"sqlite-load-extension",
"postgres",
"mysql",
"mssql",
"odbc",
"chrono",
"bigdecimal",
"json",
"uuid",
] }
sqlx-sqlserver = { version = "0.0.3", features = [
"bigdecimal",
"chrono",
"migrate",
"uuid",
] }
sqlx-odbc = { version = "0.0.1", features = ["runtime-tokio"] }
# sqlx-sqlserver currently uses native-tls. Enable vendored OpenSSL so Docker cross-builds
# do not depend on target-architecture OpenSSL development packages.
openssl = { version = "0.10", features = ["vendored"] }
libsqlite3-sys = "0.37"
chrono = "0.4.23"
actix-web = { version = "4", features = ["rustls-0_23", "cookies"] }
percent-encoding = "2.2.0"
url = "2"
handlebars = "6.2.0"
log = "0.4.17"
mime_guess = "2.0.4"
Expand Down Expand Up @@ -77,7 +88,6 @@ clap = { version = "4.5.17", features = ["derive"] }
tokio-util = "0.7.12"
openidconnect = { version = "4.0.0", default-features = false, features = ["accept-rfc3339-timestamps"] }
encoding_rs = "0.8.35"
odbc-sys = { version = "0", optional = true }
regex = "1"

# OpenTelemetry / tracing
Expand All @@ -95,7 +105,7 @@ opentelemetry-semantic-conventions = { version = "0.32", features = ["semconv_ex

[features]
default = []
odbc-static = ["odbc-sys", "odbc-sys/vendored-unix-odbc"]
odbc-static = ["sqlx-odbc/vendored-unix-odbc"]
lambda-web = ["dep:lambda-web", "odbc-static"]

[dev-dependencies]
Expand Down
17 changes: 5 additions & 12 deletions examples/microsoft sql server advanced forms/survey.sql
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,16 @@ FROM questions;
-- Save all the answers to the database, whatever the number and id of the questions
INSERT INTO survey_answers (question_id, answer)
SELECT
question_id,
json_unquote(
json_extract(
sqlpage.variables('post'),
concat('$."', question_id, '"')
)
)
FROM json_table(
json_keys(sqlpage.variables('post')),
'$[*]' columns (question_id int path '$')
) as question_ids;
TRY_CONVERT(int, answers.[key]) as question_id,
answers.value as answer
FROM OPENJSON(sqlpage.variables('post')) as answers
WHERE TRY_CONVERT(int, answers.[key]) IS NOT NULL;

-- Show the answers
select 'card' as component, 'Survey results' as title;
select
questions.question_text as title,
survey_answers.answer as description,
'On ' || survey_answers.timestamp as footer
'On ' + CONVERT(varchar(33), survey_answers.timestamp, 126) as footer
from survey_answers
inner join questions on questions.id = survey_answers.question_id;
12 changes: 6 additions & 6 deletions examples/mysql json handling/index.sql
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
select 'form' as component, 'Create a new Group' as title, 'Create' as validate;
select 'Name' as name;

insert into groups(name) select :Name where :Name is not null;
insert into `groups`(name) select :Name where :Name is not null;

select 'list' as component, 'Groups' as title, 'No group yet' as empty_title;
select name as title from groups;
select name as title from `groups`;

select 'form' as component, 'Add a user' as title, 'Add' as validate;
select 'UserName' as name, 'Name' as label;
Expand All @@ -15,7 +15,7 @@ select
TRUE as multiple,
'press ctrl to select multiple values' as description,
json_arrayagg(json_object("label", name, "value", id)) as options
from groups;
from `groups`;

insert into users(name) select :UserName where :UserName is not null;
insert into group_members(group_id, user_id)
Expand All @@ -28,8 +28,8 @@ where :Memberships is not null;
select 'list' as component, 'Users' as title, 'No user yet' as empty_title;
select
users.name as title,
group_concat(groups.name) as description
group_concat(`groups`.name) as description
from users
left join group_members on users.id = group_members.user_id
left join groups on groups.id = group_members.group_id
group by users.id, users.name;
left join `groups` on `groups`.id = group_members.group_id
group by users.id, users.name;
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ create table users (
name varchar(255) not null
);

create table groups (
create table `groups` (
id int primary key auto_increment,
name varchar(255) not null
);
Expand All @@ -12,6 +12,6 @@ create table group_members (
group_id int not null,
user_id int not null,
primary key (group_id, user_id),
foreign key (group_id) references groups (id),
foreign key (group_id) references `groups` (id),
foreign key (user_id) references users (id)
);
);
2 changes: 1 addition & 1 deletion examples/mysql json handling/survey.sql
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ select 'card' as component, 'Survey results' as title;
select
questions.question_text as title,
survey_answers.answer as description,
'On ' || survey_answers.timestamp as footer
CONCAT('On ', survey_answers.timestamp) as footer
from survey_answers
inner join questions on questions.id = survey_answers.question_id;
2 changes: 1 addition & 1 deletion examples/nginx/website/add_comment.sql
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
INSERT INTO comments (post_id, user_id, content) VALUES ($id, 1, :content);
SELECT 'redirect' as component, '/post/' || $id AS link;
SELECT 'redirect' as component, CONCAT('/post/', $id) AS link;
4 changes: 2 additions & 2 deletions examples/nginx/website/index.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ SELECT
p.title,
u.username AS description,
'user' AS icon,
'/post/' || p.id AS link
CONCAT('/post/', p.id) AS link
FROM posts p
JOIN users u ON p.user_id = u.id
ORDER BY p.created_at DESC;
ORDER BY p.created_at DESC;
2 changes: 1 addition & 1 deletion examples/nginx/website/post.sql
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ SELECT 'divider' as component;
SELECT 'form' as component,
'Add a comment' as title,
'Post comment' as validate,
'/add_comment.sql?id=' || $id as action;
CONCAT('/add_comment.sql?id=', $id) as action;

SELECT 'textarea' as type,
'content' as name,
Expand Down
6 changes: 3 additions & 3 deletions examples/web servers - apache/website/index.sql
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
select
'text' as component,
true as article,
'
CONCAT('
# Welcome to my website

Using SQLPage v' || sqlpage.version() || '
Using SQLPage v', sqlpage.version(), '

Connected to **MySQL** v' || version () as contents_md;
Connected to **MySQL** v', version ()) as contents_md;
1 change: 1 addition & 0 deletions scripts/setup-cross-compilation.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ BUILDARCH="$2"
BINDGEN_EXTRA_CLANG_ARGS=""

apt-get update
apt-get install -y perl

if [ "$TARGETARCH" = "$BUILDARCH" ]; then
TARGET="$(rustup target list --installed | head -n1)"
Expand Down
Loading
Loading