Skip to content

Implement dynamic CrateDB server version detection in PDOConnection #154

@coderabbitai

Description

@coderabbitai

Context

Currently, PDOConnection::getServerVersion() returns a hardcoded version string "5.0.0" (see src/Crate/DBAL/Driver/PDOCrate/PDOConnection.php).

This hardcoded approach was discussed in PR #122 (comment thread: #122 (comment)).

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

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions