Skip to content

Conversation

@jtv
Copy link
Owner

@jtv jtv commented Dec 21, 2025

When I wrote that function, a nullable pointer was still a reasonable way to represent an optional integer. Nowadays we have std::optional<int>. Just a shame that we can't give the new function the same name.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR modernizes the pqxx::connection::port() API by introducing a new port_number() method that returns std::optional<int> instead of a nullable C-style string pointer. The old port() method is deprecated but remains functional for backward compatibility.

  • Adds new port_number() method returning std::optional<int>
  • Deprecates the existing port() method that returns char const *
  • Updates tests to use the new API while maintaining compatibility testing

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

File Description
include/pqxx/connection.hxx Marks port() as deprecated and declares new port_number() method with std::optional<int> return type
src/connection.cxx Implements port_number() to parse port string and return optional integer
test/test_connection.cxx Tests both deprecated and new APIs for closed connection scenario
test/test21.cxx Wraps deprecated port() usage with ignore-deprecated pragmas

@jtv jtv marked this pull request as ready for review December 21, 2025 22:05
@jtv jtv merged commit 54413a7 into start-8 Dec 21, 2025
45 checks passed
@jtv jtv deleted the new-port branch December 21, 2025 22:06
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