Skip to content

Commit 8a7910f

Browse files
authored
Merge pull request #1029 from sqlpage/cursor/statically-link-unixodbc-and-update-configurations-df86
Statically link unixodbc and update configurations
2 parents d8c7ec5 + 2c7cb90 commit 8a7910f

File tree

26 files changed

+500
-94
lines changed

26 files changed

+500
-94
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 --all-features
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 --all-features
8474
env:
8575
DATABASE_URL: ${{ matrix.db_url }}
8676
RUST_BACKTRACE: 1

.github/workflows/release.yml

Lines changed: 4 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

AGENTS.md

Lines changed: 7 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,17 @@ HTML streamed to client
33

44
## Validation
55

6+
### When working on rust code
67
Mandatory formatting (rust): `cargo fmt --all`
7-
88
Mandatory linting: `cargo clippy --all-targets --all-features -- -D warnings`
99

10+
### When working on css or js
1011
Frontend formatting: `npm run format`
1112

1213
More about testing: see [github actions](./.github/workflows/ci.yml).
1314
Project structure: see [contribution guide](./CONTRIBUTING.md)
1415

15-
Don’t reformat unrelated files. Always run tests/lints/format before stopping when you changed code.
16+
NEVER reformat/lint/touch files unrelated to your task. Always run tests/lints/format before stopping when you changed code.
1617

1718
### Testing
1819

@@ -32,33 +33,10 @@ DATABASE_URL='mssql://root:Password123!@localhost/sqlpage' cargo test # all dbms
3233
- Components: defined in `./sqlpage/templates/*.handlebars`
3334
- Functions: `src/webserver/database/sqlpage_functions/functions.rs` registered with `make_function!`.
3435
- Components and functions are documented in [official website](./examples/official-site/sqlpage/migrations/); one migration per component and per function.
35-
- ```sql
36-
CREATE TABLE component(
37-
name TEXT PRIMARY KEY,
38-
description TEXT NOT NULL,
39-
icon TEXT, -- icon name from tabler icon
40-
introduced_in_version TEXT
41-
);
42-
43-
CREATE TABLE parameter_type(name TEXT PRIMARY KEY);
44-
INSERT INTO parameter_type(name) VALUES ('BOOLEAN'), ('COLOR'), ('HTML'), ('ICON'), ('INTEGER'), ('JSON'), ('REAL'), ('TEXT'), ('TIMESTAMP'), ('URL');
45-
46-
CREATE TABLE parameter(
47-
top_level BOOLEAN DEFAULT FALSE,
48-
name TEXT,
49-
component TEXT REFERENCES component(name) ON DELETE CASCADE,
50-
description TEXT,
51-
description_md TEXT,
52-
type TEXT REFERENCES parameter_type(name) ON DELETE CASCADE,
53-
optional BOOLEAN DEFAULT FALSE,
54-
);
55-
56-
CREATE TABLE example(
57-
component TEXT REFERENCES component(name) ON DELETE CASCADE,
58-
description TEXT,
59-
properties JSON,
60-
);
61-
```
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)`
6240
- [Configuration](./configuration.md): see [AppConfig](./src/app_config.rs)
6341
- Routing: file-based in `src/webserver/routing.rs`; not found handled via `src/default_404.sql`.
6442
- Follow patterns from similar modules before introducing new abstractions.

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

Cargo.lock

Lines changed: 24 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)