201 Commits

Author SHA1 Message Date
lovasoa 93ca430e14 add a test for simple static set that sets a variable to the value of another variable 2025-10-14 16:37:23 +02:00
lovasoa 9dfbf42f56 enable arbitrary precision in the internal representation of values
- Enabled arbitrary precision for `serde_json` to handle large numbers without rounding.
- Refactored decimal handling in `sql_to_json.rs` to utilize a new function for converting decimals to JSON format.

Fixes https://github.com/sqlpage/SQLPage/issues/1052
2025-10-14 16:33:10 +02:00
lovasoa 3c6dda30b5 test fixes 2025-10-02 10:51:11 +02:00
lovasoa 746c70c95b Refactor SQL column handling to ensure consistent JSON output
- Updated column name handling in `row_to_json` to use lowercase for ODBC databases.
- Added `canonical_col_name` function to standardize column names.
- Modified SQL queries in tests to use lowercase column names for consistency.
- Enhanced tests for edge cases and variations in column naming.
2025-10-01 23:39:34 +02:00
Ophir LOJKINE 625deb973b Add and document sqlpage.hmac function (#1033)
* feat: Add sqlpage.hmac function for cryptographic signing

Co-authored-by: contact <contact@ophir.dev>

* feat: Add sqlpage.hmac function for secure data signing

Co-authored-by: contact <contact@ophir.dev>

* Test HMAC function with RFC vectors and update tests

Co-authored-by: contact <contact@ophir.dev>

* feat: Add sqlpage.hmac() function for secure signatures

Co-authored-by: contact <contact@ophir.dev>

* feat: Add base64 output option to hmac function

Co-authored-by: contact <contact@ophir.dev>

* Refactor hmac function for cleaner output formatting

Co-authored-by: contact <contact@ophir.dev>

* Add webhook HMAC signature validation tests

Co-authored-by: contact <contact@ophir.dev>

* Refactor HMAC function and update SQL examples for clarity and consistency

- Changed function parameters to remove Option types for data and key in the HMAC function.
- Improved SQL documentation and examples for HMAC usage, including clearer descriptions and updated error handling.
- Enhanced test cases for webhook HMAC validation to ensure accurate signature checks and responses.
- Removed obsolete test file for HMAC with null values.

* Update HMAC validation logic to handle NULL values in SQL queries

- Modified conditions in SQL queries to check for NULL values alongside signature mismatches.
- Enhanced documentation on NULL handling for HMAC checks to improve clarity and portability.

* remove debug logging from ci

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
2025-10-01 21:07:36 +02:00
lovasoa ebdac5b29b Update sqlx dependencies to new commit hash and modify SQL queries in CSV data tests for consistency 2025-09-30 17:39:36 +02:00
lovasoa 12daf3eb8f Refactor test files for improved clarity and consistency
- Updated SQL queries in CSV data tests to use uppercase column names.
- Simplified database table management in core tests by separating drop and create statements.
- Enhanced transaction tests to utilize an enum for database type handling.
2025-09-30 15:07:01 +02:00
lovasoa 112ef55b11 Refactor SQL test file to derive database type from app state instead of environment variable for improved consistency and clarity. 2025-09-26 16:21:42 +02:00
lovasoa e5fa8d56a1 Refactor database handling to consistently use DbInfo and AnyKind across filesystem and SQL modules for improved clarity and flexibility. 2025-09-26 16:21:42 +02:00
lovasoa 659183e0df Refactor database handling in tests to use database_type instead of any_kind for improved clarity and consistency. 2025-09-26 16:21:42 +02:00
lovasoa 7399b1084a Fix basic auth test assertions
Use "Unauthorized" instead of "not authorized" to match the expected
response.

Add tests for basic auth error cases.
2025-09-15 14:01:28 +02:00
lovasoa ddd52fd74c Refactor unauthorized response
Use ErrorWithStatus for unauthorized errors to set the WWW-Authenticate
header.
2025-09-15 11:34:23 +02:00
lovasoa 08cfbcbcfe Rename "priority" to "level" in log handling and update corresponding SQL test file 2025-09-14 00:44:54 +02:00
Lenardt Gerhardts 68b600595e Feature logger component (#1013)
* implemented logger Component

* changed target for logger to "sqlpage::logger" and made the log::Level case insensitive

* changed error message on missing message key, to be more precise

* changed custom method for String to log::Level conversion to builtin method log::Level::from_str()

* switched to utility method get_object_str and inlined constants

* dynamically target based on file and statement

* disabled ci error (large difference in enum variants) for ResponseWithWriter<S>

* added functionality to work in Header context

* Refactor log component to use compact error handling

* Rename comp_str variable to component_name

* Documented log component

* fixxed missing values statement

* fixxed pipeline errors

* very simple test case for logger

---------

Co-authored-by: Lenardt Gerhardts <lenardt.ger+git@gmail.com>
Co-authored-by: lovasoa <contact@ophir.dev>
2025-09-12 13:38:47 +02:00
lovasoa 474815244f Update it_works_set_case.sql 2025-09-09 16:22:37 +02:00
lovasoa b04f021d6c Fix handling of NULL values in sqlpage.link
NULL values were encoded as the string `'null'` instead of being omitted
from the link's parameters.
2025-09-08 23:56:18 +02:00
lovasoa 9ff1d9f98b Add test case for SET case expression 2025-09-08 23:43:09 +02:00
lovasoa b0dadea0ae feat: add download component
- Introduce a new download component to facilitate file downloads.
- Implement download handling in the header context, supporting data URLs.
- Add a test for the download functionality to ensure correct behavior.

see https://github.com/sqlpage/SQLPage/discussions/996
2025-08-28 22:43:53 +02:00
lovasoa db536bad90 feat: Add encoding parameter to fetch function
- Adds a new parameter `response_encoding` to the fetch function. - This
parameter allows the user to specify a charset for decoding the response
body. - It supports all standard web encodings, and also `hex` and
`base64`. - If no encoding is specified, the response is decoded as
utf-8, or as base64 if it contains binary data.
2025-08-21 23:27:33 +02:00
Ophir LOJKINE 33125565d3 Check for 404 before redirecting on no-extension paths (#972)
* Check for 404 before redirecting on no-extension paths

The commit improves routing logic by checking if a path would result in
a 404

fixes https://github.com/sqlpage/SQLPage/issues/971 before adding a
trailing slash. This prevents unnecessary redirects when a custom 404
handler exists.

* Fix test function signature formatting in routing module (#973)

Co-authored-by: Cursor Agent <cursoragent@cursor.com>

* Simplify path resolution and redirect logic

The shorter code more clearly handles finding files with .sql extensions
and decides whether to add trailing slashes based on index file
presence.

* clippy

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
2025-07-28 17:54:23 +02:00
lovasoa ae30d82917 biome fixes 2025-07-27 00:09:39 +02:00
lovasoa 21b4287753 test new modal component + changelog 2025-06-27 15:49:34 +02:00
francesco-cattoglio cc6a391810 Added a compile time flag to compile SQLite with builtin math functions (#938)
* Added a compile time flag to compile SQLite with builtin math funcions

* Added a test, improved the comments in cargo config file
2025-06-20 21:19:47 +02:00
lovasoa 5ade60fa95 Return plain text 404 for non-HTML requests
Checks the `Accept` header for 404 responses. If HTML is not
preferred, a plain text 404 is returned, avoiding the
`_default_404.sql` processing. HTML-preferring clients
continue to receive the custom SQL-based 404 page.
2025-05-30 22:49:26 +02:00
lovasoa 7da1b2882a implement default 404 error page
... and update routing logic to serve it; remove old 404 handling code; add tests for new behavior
2025-05-29 22:44:22 +02:00
lovasoa 60aac0b181 update e2d tests 2025-05-26 01:00:10 +02:00
lovasoa 0446b092f3 clippy SQL tests 2025-05-26 00:57:29 +02:00
lovasoa b48826a19e handle skipped tests and improve result reporting 2025-05-26 00:50:08 +02:00
lovasoa e7951ee721 dynamic port choice
also: better error messages in tests
2025-05-26 00:46:04 +02:00
lovasoa 7009f65374 run sql test files 2025-05-26 00:05:45 +02:00
lovasoa 2d307fa6f0 move 404 test 2025-05-25 23:31:58 +02:00
lovasoa acdc03891d clippy fixes 2025-05-25 23:22:41 +02:00
lovasoa 5cbd12fcfd reorganize tests: better structure 2025-05-25 23:20:31 +02:00
lovasoa 0695cfe668 better assert message 2025-05-25 22:49:23 +02:00
lovasoa c00446ca21 clippy 2025-05-06 22:47:12 +02:00
Gus Power 1582956ae5 Extend CSP Configuration to handle user-supplied values that can contain {NONCE} (#911)
* Extend CSP Configuration to handle user-supplied values that can contain {NONCE}

* fix RequestContext to use CSP value from AppConfig

* update documentation to describe usage

* generate nonce per request; config is a string (again); added playwright test to verify subsequent requests return a different nonce.

* fix js lint `let` -> `const`

* format

* remove some useless string copies

we are still re-parsing the csp template on every request

* implement a proper csp template struct

* parse the content-security-policy just once

* fix merge issue.

* fix docs

* fix docs

* clippy

---------

Co-authored-by: lovasoa <contact@ophir.dev>
2025-05-06 09:34:46 +02:00
Amruta.org 74d5b24f9a Replace hardcoded strings with customizable attributes in multiple components (#893)
* Update shell.handlebars

adding two options:
search_button
search_placeholder

* Update table.handlebars

adding search_placeholder option

* Update 01_documentation.sql

documentation update for the shell component options:
search_placeholder
search_button
and for the table component option: search_placeholder

* avoid failing tests on long loading map tiles

* add an example for search_placeholder

---------

Co-authored-by: lovasoa <contact@ophir.dev>
2025-04-24 16:01:25 +02:00
lovasoa 74447eaee7 hide dotfiles 2025-03-22 17:48:20 +01:00
Gus Power 261f76c2bc Add unsafe_contents_md to text component, add related file tests, add documentation parameters 2025-03-17 11:08:36 +00:00
lovasoa 913f45b2ea fix tests 2025-02-27 21:43:42 +01:00
lovasoa e75fc22d7f fix tests on mssql
CI / compile_and_lint (push) Has been cancelled
CI / test (mssql) (push) Has been cancelled
CI / test (mysql) (push) Has been cancelled
CI / test (postgres) (push) Has been cancelled
CI / windows_test (push) Has been cancelled
CI / docker_build (linux/amd64) (push) Has been cancelled
CI / docker_build (linux/arm/v7) (push) Has been cancelled
CI / docker_build (linux/arm64) (push) Has been cancelled
CI / docker_push (push) Has been cancelled
Create Release / Build sqlpage binaries (target/superoptimized/sqlpage, macos-latest) (push) Has been cancelled
Create Release / Build sqlpage binaries (target/superoptimized/sqlpage, ubuntu-20.04) (push) Has been cancelled
Create Release / Build sqlpage binaries (target/superoptimized/sqlpage.exe, windows-latest) (push) Has been cancelled
Create Release / Build AWS Lambda Serverless zip image (push) Has been cancelled
Create Release / Create Github Release (push) Has been cancelled
Create Release / Publish to crates.io (push) Has been cancelled
no json_extract
2025-02-24 22:22:03 +01:00
Ophir LOJKINE 5fd1c83df1 new function: fetch_with_meta (#827)
* new function: fetch_with_meta

closes https://github.com/sqlpage/SQLPage/issues/792

* fmt

* clippy auto

* test fetch_with_meta

* fix tests

* update deps

* retry failed deps downloads

* better json serializing

* test fetch_with_meta error handling

* add logging

* fix tests



closes #792
2025-02-24 22:01:30 +01:00
Ophir LOJKINE 668a87764f fix parameter binding order (#825)
* use numbered parameters in sqlite

* implement parameter deduplication

* implement parameter re-duplication for mysql

* Improve error messages on invalid sqlpage function calls. The messages now contain actionable advice.

* simplify extract_set_variable
2025-02-22 14:13:45 +01:00
lovasoa 2aac5f3aa2 docs and tests 2025-02-17 14:31:41 +01:00
lovasoa 3ab42fced6 new function: sqlpage.headers()
closes https://github.com/sqlpage/SQLPage/discussions/810
2025-02-13 17:33:02 +01:00
francesco-cattoglio c57d82c12a Added an option to format numbers using toLocaleString() for table columns (#807)
* Added an option to format numbers using `toLocaleString()` for table columns

* format numbers in tables

---------

Co-authored-by: lovasoa <contact@ophir.dev>
2025-02-11 23:57:18 +01:00
lovasoa 817fd97476 new sqlpage functions to read HTTP request body
sqlpage.request_body and sqlpage.request_body_base64

closes https://github.com/sqlpage/SQLPage/issues/316
2025-02-10 16:53:24 +01:00
lovasoa 5a7ca66c03 forbid invalid fields in sqlpage.fetch http request definitions 2025-02-10 10:18:41 +01:00
lovasoa 8a7682fe4d increase test timeout 2025-02-03 03:34:10 +01:00
lovasoa 13eecc843a fix test with mem db 2025-02-03 03:26:12 +01:00