Skip to content

Commit 1c9f81b

Browse files
committed
Merge remote-tracking branch 'refs/remotes/origin/cursor/automate-deb-and-rpm-package-generation-246a' into cursor/automate-deb-and-rpm-package-generation-246a
2 parents 5ea15b9 + 6ad5346 commit 1c9f81b

33 files changed

+681
-129
lines changed

.cargo/config.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,6 @@
55
# set by the user, and this is a good thing. If the user already set some
66
# LIBSQLITE3_FLAGS, he probably knows what he is doing.
77
LIBSQLITE3_FLAGS = "-DSQLITE_ENABLE_MATH_FUNCTIONS"
8+
9+
[build]
10+
rustflags = []

.github/workflows/ci.yml

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,11 @@ jobs:
2727
- uses: actions/checkout@v4
2828
- run: npm ci
2929
- run: npm test
30-
- name: Install ODBC dependencies
31-
run: |
32-
sudo apt-get update
33-
sudo apt-get install -y unixodbc-dev freetds-dev
3430
- name: Set up cargo cache
3531
uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6
3632
- run: cargo fmt --all -- --check
3733
- run: cargo clippy --all-targets --all-features -- -D warnings
38-
- run: cargo test
34+
- run: cargo test --features odbc-static
3935
- name: Upload Linux binary
4036
uses: actions/upload-artifact@v4
4137
with:
@@ -58,29 +54,23 @@ jobs:
5854
db_url: "mssql://root:[email protected]/sqlpage"
5955
- database: odbc
6056
container: postgres
61-
db_url: "Driver={PostgreSQL Unicode};Server=127.0.0.1;Port=5432;Database=sqlpage;UID=root;PWD=Password123!"
57+
db_url: "Driver=/usr/lib/x86_64-linux-gnu/odbc/psqlodbcw.so;Server=127.0.0.1;Port=5432;Database=sqlpage;UID=root;PWD=Password123!"
6258
setup_odbc: true
6359
steps:
6460
- uses: actions/checkout@v4
6561
- name: Set up cargo cache
6662
uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6
67-
- name: Install ODBC dependencies
68-
run: |
69-
sudo apt-get update
70-
sudo apt-get install -y unixodbc-dev freetds-dev
71-
- name: Setup ODBC for testing
63+
- name: Install PostgreSQL ODBC driver
7264
if: matrix.setup_odbc
73-
run: |
74-
# Install PostgreSQL ODBC driver (automatically registers the driver)
75-
sudo apt-get install -y odbc-postgresql
65+
run: sudo apt-get install -y odbc-postgresql
7666
- name: Start database container
7767
run: docker compose up --wait ${{ matrix.container }}
7868
- name: Show container logs
7969
if: failure()
8070
run: docker compose logs ${{ matrix.container }}
8171
- name: Run tests against ${{ matrix.database }}
8272
timeout-minutes: 5
83-
run: cargo test
73+
run: cargo test --features odbc-static
8474
env:
8575
DATABASE_URL: ${{ matrix.db_url }}
8676
RUST_BACKTRACE: 1

.github/workflows/official-site.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88
concurrency: site-deploy
99

1010
jobs:
11-
deploy:
11+
deploy_official_site:
1212
runs-on: ubuntu-latest
1313
steps:
1414
- name: Cloning repo

.github/workflows/release.yml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,10 @@ jobs:
2424
- os: windows-latest
2525
binary_extension: .exe
2626
target: x86_64-pc-windows-msvc
27+
features: ""
2728
- os: macos-latest
2829
target: x86_64-apple-darwin
30+
features: "odbc-static"
2931
steps:
3032
- uses: actions/checkout@v4
3133
- name: Install Rust toolchain
@@ -35,7 +37,7 @@ jobs:
3537
- name: Set up cargo cache
3638
uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6
3739
- name: Build
38-
run: cargo build --profile superoptimized --locked --target ${{ matrix.target }}
40+
run: cargo build --profile superoptimized --locked --target ${{ matrix.target }} --features "${{ matrix.features }}"
3941
- name: Upload unsigned Windows artifact
4042
if: matrix.os == 'windows-latest'
4143
id: upload_unsigned
@@ -83,18 +85,14 @@ jobs:
8385
container: quay.io/pypa/manylinux_2_28_x86_64
8486
steps:
8587
- uses: actions/checkout@v4
86-
- name: Install ODBC dependencies
87-
run: |
88-
yum update -y
89-
yum install -y unixODBC-devel freetds-devel
9088
- name: Install Rust toolchain
9189
uses: dtolnay/rust-toolchain@stable
9290
with:
9391
targets: x86_64-unknown-linux-gnu
9492
- name: Set up cargo cache
9593
uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6
9694
- name: Build
97-
run: cargo build --profile superoptimized --locked --target x86_64-unknown-linux-gnu
95+
run: cargo build --profile superoptimized --locked --target x86_64-unknown-linux-gnu --features "odbc-static"
9896
- uses: actions/upload-artifact@v4
9997
with:
10098
name: sqlpage ubuntu-latest
@@ -160,5 +158,6 @@ jobs:
160158
- uses: actions/checkout@v4
161159
- name: Set up cargo cache
162160
uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6
161+
- run: sudo apt-get update && sudo apt-get install -y unixodbc-dev
163162
- name: Publish to crates.io
164163
run: cargo publish --token ${{ secrets.CRATES_IO_TOKEN }}

AGENTS.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
Core Concept: User writes .sql files, SQLPage executes queries, results mapped to handlebars UI components,
2+
HTML streamed to client
3+
4+
## Validation
5+
6+
### When working on rust code
7+
Mandatory formatting (rust): `cargo fmt --all`
8+
Mandatory linting: `cargo clippy --all-targets --all-features -- -D warnings`
9+
10+
### When working on css or js
11+
Frontend formatting: `npm run format`
12+
13+
More about testing: see [github actions](./.github/workflows/ci.yml).
14+
Project structure: see [contribution guide](./CONTRIBUTING.md)
15+
16+
NEVER reformat/lint/touch files unrelated to your task. Always run tests/lints/format before stopping when you changed code.
17+
18+
### Testing
19+
20+
```
21+
cargo test # tests with inmemory sqlite by default
22+
```
23+
24+
For other databases, see [docker testing setup](./docker-compose.yml)
25+
26+
```
27+
docker compose up -d mssql # or postgres or mysql
28+
DATABASE_URL='mssql://root:Password123!@localhost/sqlpage' cargo test # all dbms use the same user:pass and db name
29+
```
30+
31+
#### Project Conventions
32+
33+
- Components: defined in `./sqlpage/templates/*.handlebars`
34+
- Functions: `src/webserver/database/sqlpage_functions/functions.rs` registered with `make_function!`.
35+
- Components and functions are documented in [official website](./examples/official-site/sqlpage/migrations/); one migration per component and per function.
36+
- tables
37+
- `component(name,description,icon,introduced_in_version)` -- icon name from tabler icon
38+
- `parameter(top_level BOOLEAN, name, component REFERENCES component(name), description, description_md, type, optional BOOLEAN)` parameter types: BOOLEAN, COLOR, HTML, ICON, INTEGER, JSON, REAL, TEXT, TIMESTAMP, URL
39+
- `example(component REFERENCES component(name), description, properties JSON)`
40+
- [Configuration](./configuration.md): see [AppConfig](./src/app_config.rs)
41+
- Routing: file-based in `src/webserver/routing.rs`; not found handled via `src/default_404.sql`.
42+
- Follow patterns from similar modules before introducing new abstractions.
43+
- frontend: see [css](./sqlpage/sqlpage.css) and [js](./sqlpage/sqlpage.js)

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
# CHANGELOG.md
22

33
## v0.38.0
4+
- Added support for the Open Database Connectivity (ODBC) standard.
5+
- This makes SQLPage compatible with many new databases, including:
6+
- [*ClickHouse*](https://github.com/ClickHouse/clickhouse-odbc),
7+
- [*MongoDB*](https://www.mongodb.com/docs/atlas/data-federation/query/sql/drivers/odbc/connect),
8+
- [*DuckDB*](https://duckdb.org/docs/stable/clients/odbc/overview.html), and through it [many other data sources](https://duckdb.org/docs/stable/data/data_sources),
9+
- [*Oracle*](https://www.oracle.com/database/technologies/releasenote-odbc-ic.html),
10+
- [*Snowflake*](https://docs.snowflake.com/en/developer-guide/odbc/odbc),
11+
- [*BigQuery*](https://cloud.google.com/bigquery/docs/reference/odbc-jdbc-drivers),
12+
- [*IBM DB2*](https://www.ibm.com/support/pages/db2-odbc-cli-driver-download-and-installation-information),
13+
- [*Trino*](https://docs.starburst.io/clients/odbc/odbc-v2.html), and through it [many other data sources](https://trino.io/docs/current/connector.html)
414
- Added a new `sqlpage.hmac()` function for cryptographic HMAC (Hash-based Message Authentication Code) operations.
515
- Create and verify secure signatures for webhooks (Shopify, Stripe, GitHub, etc.)
616
- Generate tamper-proof tokens for API authentication

CONTRIBUTING.md

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,24 @@ cargo build --release
3737

3838
The resulting executable will be in `target/release/sqlpage`.
3939

40+
### ODBC build modes
41+
42+
SQLPage can either be built with an integrated odbc driver manager (static linking),
43+
or depend on having one already installed on the system where it is running (dynamic linking).
44+
45+
- Dynamic ODBC (default): `cargo build`
46+
- Static ODBC (Linux and MacOS only): `cargo build --features odbc-static`
47+
48+
Windows comes with ODBC pre-installed; SQLPage cannot statically link to the unixODBC driver manager on windows.
49+
4050
## Code Style and Linting
4151

4252
### Rust
53+
4354
- Use `cargo fmt` to format your Rust code
4455
- Run `cargo clippy` to catch common mistakes and improve code quality
4556
- All code must pass the following checks:
57+
4658
```bash
4759
cargo fmt --all -- --check
4860
cargo clippy
@@ -55,6 +67,7 @@ We use Biome for linting and formatting of the frontend code.
5567
```bash
5668
npx @biomejs/biome check .
5769
```
70+
5871
This will check the entire codebase (html, css, js).
5972

6073
## Testing
@@ -80,6 +93,7 @@ cargo test
8093
```
8194

8295
### End-to-End Tests
96+
8397
We use Playwright for end-to-end testing of dynamic frontend features.
8498
Tests are located in [`tests/end-to-end/`](./tests/end-to-end/). Key areas covered include:
8599

@@ -103,14 +117,15 @@ npm run test
103117
## Documentation
104118

105119
### Component Documentation
120+
106121
When adding new components, comprehensive documentation is required. Example from a component documentation:
107122

108123
```sql
109124
INSERT INTO component(name, icon, description, introduced_in_version) VALUES
110125
('component_name', 'icon_name', 'Description of the component', 'version');
111126

112127
-- Document all parameters
113-
INSERT INTO parameter(component, name, description, type, top_level, optional)
128+
INSERT INTO parameter(component, name, description, type, top_level, optional)
114129
VALUES ('component_name', 'param_name', 'param_description', 'TEXT|BOOLEAN|NUMBER|JSON|ICON|COLOR', false, true);
115130

116131
-- Include usage examples
@@ -127,6 +142,7 @@ If you are editing an existing component, edit the existing sql documentation fi
127142
If you are adding a new component, add a new sql file in the folder, and add the appropriate insert statements above.
128143

129144
### SQLPage Function Documentation
145+
130146
When adding new SQLPage functions, document them using a SQL migrations. Example structure:
131147

132148
```sql
@@ -168,6 +184,7 @@ VALUES (
168184
```
169185

170186
Key elements to include in function documentation:
187+
171188
- Clear description of the function's purpose
172189
- Version number where the function was introduced
173190
- Appropriate icon
@@ -179,11 +196,13 @@ Key elements to include in function documentation:
179196
## Pull Request Process
180197

181198
1. Create a new branch for your feature/fix:
199+
182200
```bash
183201
git checkout -b feature/your-feature-name
184202
```
185203

186204
2. Make your changes, ensuring:
205+
187206
- All tests pass
188207
- Code is properly formatted
189208
- New features are documented
@@ -199,11 +218,10 @@ git checkout -b feature/your-feature-name
199218
- Run frontend linting with Biome
200219
- Test against multiple databases (PostgreSQL, MySQL, MSSQL)
201220

202-
5. Wait for review and address any feedback
203-
204221
## Release Process
205222

206223
Releases are automated when pushing tags that match the pattern `v*` (e.g., `v1.0.0`). The CI pipeline will:
224+
207225
- Build and test the code
208226
- Create Docker images for multiple architectures
209227
- Push images to Docker Hub

0 commit comments

Comments
 (0)