Skip to content

Port SQLPage to sqlx 0.9 driver crates#1292

Draft
lovasoa wants to merge 9 commits into
mainfrom
sqlx-newapi
Draft

Port SQLPage to sqlx 0.9 driver crates#1292
lovasoa wants to merge 9 commits into
mainfrom
sqlx-newapi

Conversation

@lovasoa
Copy link
Copy Markdown
Collaborator

@lovasoa lovasoa commented May 31, 2026

Port SQLPage to sqlx 0.9 with external SQL Server and ODBC drivers

Summary

This draft PR ports SQLPage away from the sqlx-oldapi compatibility crate and onto the current sqlx crate. SQL Server and ODBC support move to the external sqlx-sqlserver and sqlx-odbc crates.

The important API change is that sqlx::Any in sqlx 0.9 no longer preserves the driver-specific row/type information SQLPage needs for JSON conversion, CSV import, DB-backed files, and backend-specific behavior. The implementation therefore replaces SQLPage's central AnyPool usage with a small SQLPage-owned backend enum and dispatches to native sqlx pool/connection types.

Checklist

  • Switch dependencies from sqlx-oldapi to sqlx 0.9, sqlx-sqlserver, and sqlx-odbc.
  • Replace sqlx::any::AnyKind with a SQLPage-owned backend kind enum.
  • Replace AnyPool and PoolConnection<Any> with SQLPage-owned pool and connection enums.
  • Rewrite database URL/connection-string parsing, including password override behavior.
  • Preserve SQLite custom setup: extensions, NOCASE collation, and Unicode upper/lower support where supported by the new API.
  • Preserve ODBC custom setup: direct connection strings, batch size, unbounded column size, and DBMS-name detection.
  • Rewrite query execution so parameters are bound through native backend query types.
  • Preserve SQLite response streaming: statement execution now forwards a boxed per-statement stream and does not collect result sets into memory before yielding rows to the renderer/browser.
  • Rewrite row-to-JSON conversion for native backend row types instead of AnyRow.
  • Preserve PostgreSQL advanced type handling without routing through Any.
  • Preserve ODBC decimal/numeric JSON shape by dispatching from column metadata and decoding DECIMAL/NUMERIC text-buffer values as JSON numbers instead of strings, including Oracle ODBC's leading-dot decimal formatting.
  • Recheck SQL Server advanced type support in the external sqlx-sqlserver crate and use the new 0.0.3 typed decoders for decimal/money, date/time, datetimeoffset, and uniqueidentifier values. No upstream issue needed.
  • Recheck SQL Server text decoding behavior in sqlx-sqlserver; opened upstream issue Decode SQL Server VARCHAR using column collation/codepage instead of UTF-8 lovasoa/sqlx-sqlserver#1 for non-UTF-8 VARCHAR decoding. SQLPage's MSSQL CSV fixture uses NVARCHAR literals and character-code construction for Unicode/quoted text until that is fixed upstream.
  • Fix the SQL Server advanced forms example survey page to use T-SQL JSON parsing and string concatenation.
  • Fix MySQL-backed example SQL for MySQL string concatenation and reserved table names.
  • Update CSV import, keeping PostgreSQL COPY and using normal inserts for other backends.
  • Update DB-backed filesystem query execution.
  • Update migrations, including a clear error for ODBC user migrations because sqlx-odbc does not implement migration support.
  • Update telemetry pool metrics for the new pool enum.
  • Update placeholder parsing/tests to use the SQLPage backend kind.
  • Enable vendored OpenSSL for sqlx-sqlserver/native-tls and install full Perl in the Docker builder so cross-compiled images can build OpenSSL from source.
  • Add examples-folder smoke coverage so every top-level example is either entry-page rendered locally or explicitly classified as requiring an external service stack.
  • Add opt-in Postgres/MySQL example smoke coverage for examples that require those backends.
  • Run example smoke coverage against local SQLite-compatible, Postgres, and MySQL examples.
  • Run cargo fmt --all.
  • Run cargo clippy --all-targets --all-features -- -D warnings.
  • Run cargo test.

Validation

  • cargo check
  • cargo fmt --all
  • cargo test sql_to_json
  • cargo test --test examples
  • SQLPAGE_TEST_EXAMPLES_POSTGRES_ADMIN_URL='postgres://root:Password123!@127.0.0.1/postgres' SQLPAGE_TEST_EXAMPLES_MYSQL_ADMIN_URL='mysql://root:Password123!@127.0.0.1/mysql' cargo test --test examples
  • DATABASE_URL='mysql://root:Password123!@127.0.0.1/sqlpage' cargo test transactions::test_transaction_error
  • DATABASE_URL='mysql://root:Password123!@127.0.0.1/sqlpage' cargo test sql_test_files::run_all_sql_test_files
  • cargo clippy --all-targets --all-features -- -D warnings
  • cargo test
  • docker build --platform linux/amd64 --build-arg TARGETARCH=amd64 --build-arg BUILDARCH=amd64 --build-arg CARGO_PROFILE=dev --target minimal . progressed past vendored OpenSSL configuration and project compilation after installing full Perl; the final mv failed because Cargo's built-in dev profile writes to debug/ while the Docker scripts expect the named profile directory used by superoptimized.
  • Attempted SQL Server Docker validation with docker compose up -d mssql, but the local arm64/QEMU environment cannot start the amd64 SQL Server image (Invalid mapping of address ... reserved address space). The SQL Server example SQL was still reviewed and corrected to T-SQL.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant