Implement dynamic CrateDB server version detection in PDOConnection
- Dominant language
- PHP
- Stars
- 16
- Forks
- 10
- PR merge metrics
- No merged PRs in 30d
Description
## Context
Currently, `PDOConnection::getServerVersion()` returns a hardcoded version string `"5.0.0"` (see [src/Crate/DBAL/Driver/PDOCrate/PDOConnection.php](https://github.com/crate/crate-dbal/blob/amo/doctrine3/src/Crate/DBAL/Driver/PDOCrate/PDOConnection.php#L53-L58)).
This hardcoded approach was discussed in PR #122 (comment thread: https://github.com/crate/crate-dbal/pull/122#discussion_r2543894980).
## Problem
The hardcoded version assumes all CrateDB deployments are running a modern version (>= 4.0.0), which causes `Driver::createDatabasePlatformForVersion()` to always select `CratePlatform4()`. This may cause issues if the actual server is running an older CrateDB version that requires a different platform implementation.
## Proposed Solution
Implement dynamic version detection by querying the CrateDB server. CrateDB supports:
- `SELECT version();` - returns CrateDB version string
- `SELECT version FROM sys.nodes;` - returns version per node
The version can be retrieved via the existing `query()` or `exec()` methods in PDOConnection.
## Discussion Summary
From PR #122 discussion:
- @amotl initially changed the hardcoded version from "6.0.0" to "5.0.0" as a more conservative choice
- @seut expressed concern about hardcoding this value and requested proper version detection, at least as a followup
- The pragmatic approach for now is to assume modern CrateDB versions by default
## References
- PR: #122
- Comment thread: https://github.com/crate/crate-dbal/pull/122#discussion_r2543894980
- Requested by: @amotl
- Reviewed by: @seut
## Acceptance Criteria
- [ ] `getServerVersion()` queries the actual CrateDB server for its version
- [ ] Proper error handling if version detection fails
- [ ] Consider caching the version to avoid repeated queries
- [ ] Update documentation to reflect minimum supported CrateDB version
Contributor guide
Research direction
Start in src/Crate/DBAL/Driver/PDOCrate/PDOConnection.php, focusing on getServerVersion() and the existing query() or exec() methods. Check how Driver::createDatabasePlatformForVersion() consumes the result. Done means the actual CrateDB version is detected with error handling, repeated lookups are considered, and documentation reflects the minimum supported version.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- database
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100