Commit Graph

93 Commits

Author SHA1 Message Date
lovasoa d69b1d1d9f Make URL and POST parameters immutable, separate from SET variables
- URL and POST parameters are now immutable after request initialization
- SET command creates user-defined variables in separate namespace
- Variable lookup: SET variables shadow request parameters
- Added sqlpage.variables('set') to inspect user-defined variables
- Simplified API: most functions now use &RequestInfo instead of &mut
- All tests passing (151 total)
2025-11-19 02:11:03 +01:00
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
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 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 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
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 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 5cbd12fcfd reorganize tests: better structure 2025-05-25 23:20:31 +02: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 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
lovasoa 5a7ca66c03 forbid invalid fields in sqlpage.fetch http request definitions 2025-02-10 10:18:41 +01:00
lovasoa d5b3d1221c Fix a bug where subsequent requests would fail after a failed CSV import on postgres
fixes https://github.com/sqlpage/SQLPage/issues/788
2025-01-24 15:36:50 +01:00
lovasoa 0d7c91ed59 add support for coalesce in function calls 2024-12-24 22:24:23 +01:00
lovasoa 7dc8683b6e sqlpage.environment_variable('inexistant') = null
fixes https://github.com/sqlpage/SQLPage/issues/746
2024-12-20 16:30:17 +01:00
lovasoa 0d51d52393 not on a personal repo anymore 2024-12-06 21:42:55 +01:00
lovasoa 4f8d21c3a7 fix https://github.com/sqlpage/SQLPage/issues/701 2024-11-18 21:42:22 +01:00
lovasoa 1c5fb16f27 add a native sqlpage implementation of json_array, which allows passing json arrays to nested sqlpage functions 2024-11-18 16:32:29 +01:00
lovasoa 67ddf944f0 disable varchar test on mysql 2024-11-01 22:37:22 +01:00
lovasoa 3da1c3677f add a test for varchar
see https://github.com/sqlpage/SQLPage/issues/662
2024-11-01 22:25:16 +01:00
lovasoa fbf994892d json_object is different on postgres 2024-10-05 23:51:12 +02:00
lovasoa 4cafa1eac0 add a machanism to skip some tests on some dbs 2024-10-05 23:20:29 +02:00
lovasoa 9e580753e4 Easier json handling in databases without a native json type. SQLPage now detects when you use a json function in SQLite or MariaDB to generate a column, and automatically converts the resulting string to a json object. This allows easily using components that take json parameters (like the new columns component) in MariaDB and SQLite.
fixes #633
2024-10-05 22:31:29 +02:00
lovasoa dd94371c44 fix https://github.com/lovasoa/SQLpage/issues/621 2024-10-04 09:23:42 +02:00
lovasoa 38dbde4ca0 fix https://github.com/lovasoa/SQLpage/discussions/600 2024-09-24 22:39:57 +02:00
lovasoa 5abc7762aa add a test for https://github.com/lovasoa/SQLpage/issues/526 2024-08-12 22:40:29 +02:00
lovasoa 47e419b2a4 fix tests 2024-07-12 21:49:00 +02:00
lovasoa 29fa14ce7c calls to json_object in sqlpage function arguments 2024-07-12 16:27:17 +02:00
lovasoa 996ed2e2ee add test from https://github.com/lovasoa/SQLpage/pull/486/files
closes https://github.com/lovasoa/SQLpage/pull/486
2024-07-11 18:10:45 +02:00
lovasoa 9c47ec94cc fix mysql tests 2024-07-11 13:58:25 +02:00
lovasoa 6a3f2159c1 avoid cloning variables when not needed in run_sql 2024-07-11 13:07:32 +02:00
lovasoa e9fc9624f4 run_sql can now be called with a specific set of variables to pass to the included sql file
new html component
2024-07-10 23:54:41 +02:00
lovasoa c629c38a26 reintroduce good error messages for invalid function calls 2024-06-27 00:52:56 +02:00
Ophir LOJKINE b877284416 Merge branch 'main' into function_post_result 2024-06-25 08:56:56 +00:00
lovasoa a6c5a1f3f8 better dynamic component errors 2024-06-25 00:27:53 +02:00
lovasoa 12efca6aa9 WIP delayed function execution 2024-06-24 23:38:10 +02:00