Skip to content

feat(postgres): add SQL/XML standard expressions - #41

Merged
vistart merged 3 commits into
release/v1.0.0.dev15from
feature/sqlxml-standard-support
Jun 4, 2026
Merged

vistart merged 3 commits into
release/v1.0.0.dev15from
feature/sqlxml-standard-support

Conversation

@vistart

@vistart vistart commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Description

Adds PostgreSQL support for core SQL/XML standard expression constructors.

This PR updates the PostgreSQL dialect to opt into supported SQL/XML standard capabilities from core, including:

  • XMLPARSE and XMLSERIALIZE
  • XML constructors such as XMLELEMENT, XMLATTRIBUTES, XMLFOREST, XMLCONCAT, XMLCOMMENT, XMLPI, and XMLROOT
  • XMLAGG
  • XMLEXISTS and XMLTABLE capability declarations where supported by PostgreSQL

It also keeps PostgreSQL-specific XPath and XML well-formed helpers separate from the standard SQL/XML expression API, and removes SQL/XML constructors from the plain function capability map so they are not advertised as ordinary SQL functions.

A self-contained SQL/XML examples module is included under the PostgreSQL examples package. The example uses environment-based connection configuration, XML fixture files, and expression-generated DDL/DML/query SQL.

Adds #

Type of change

  • feat: A new feature
  • test: Adding missing tests or correcting existing tests (for the new feature)
  • docs: Documentation only changes (if related to the new feature)

Breaking Change

  • Yes
  • No

Applicable rhosocial-activerecord Version Range:
Compatible with the corresponding core SQL/XML expression support introduced for rhosocial-activerecord 1.0.0.dev28.

Related Repositories/Packages

Requires the core SQL/XML expression support from python-activerecord PR #98.

Related backend follow-up changes exist for Oracle, SQL Server, MySQL, MariaDB, and Firebird to align each backend's SQL/XML support boundary with the core standard expression protocols.

Testing

  • I have added new tests to cover my changes.
  • I have updated existing tests to reflect my changes.
  • All existing tests pass.
  • This change has been tested on PostgreSQL 9 through 18 scenario configurations.

Test Plan:

Local full test run was skipped during PR preparation by user choice.

Previously run targeted tests:

source .venv3.8/bin/activate
pytest tests/rhosocial/activerecord_postgres_test/feature/backend/postgres/test_xml_types.py \
       tests/rhosocial/activerecord_postgres_test/feature/backend/postgres/test_xml_integration.py \
       tests/rhosocial/activerecord_postgres_test/feature/backend/test_dialect_function_support.py \
       tests/rhosocial/activerecord_postgres_test/feature/backend/test_postgres_protocol_conformance.py

SQL/XML example validation:

source .venv3.8/bin/activate
python -m py_compile src/rhosocial/activerecord/backend/impl/postgres/examples/sqlxml/standard_expressions.py
python src/rhosocial/activerecord/backend/impl/postgres/examples/sqlxml/standard_expressions.py
python src/rhosocial/activerecord/backend/impl/postgres/examples/sqlxml/standard_expressions.py --execute

The execute mode was verified against all configured PostgreSQL scenarios from 9 through 18.

Checklist

  • My code follows the project's code style guidelines.
  • I have performed a self-review of my own code.
  • I have made corresponding changes to tests and examples.
  • My changes generate no new warnings in the targeted test runs.
  • I have added a Changelog fragment (changelog.d/<issue_number>.<type>.md).
  • I have verified that my changes do not introduce SQL injection vulnerabilities.
  • I have checked for potential performance regressions.

Additional Notes

XMLQUERY is intentionally not declared as supported by PostgreSQL. PostgreSQL-specific XML helpers such as XPath functions remain backend-specific APIs instead of being conflated with SQL/XML standard constructors.

vistart and others added 2 commits June 4, 2026 14:41
Wire PostgreSQL XMLPARSE support through the core SQL/XML expression
protocol and remove the old PostgreSQL-specific function factory.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Enable PostgreSQL SQL/XML capabilities through core expression protocols,
keep PostgreSQL-specific XPath helpers separate, and add self-contained
examples that exercise expression-generated SQL.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@vistart vistart self-assigned this Jun 4, 2026
@vistart vistart added the feature label Jun 4, 2026
@codecov

codecov Bot commented Jun 4, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 71.09%. Comparing base (dc78743) to head (0502c9a).

Additional details and impacted files
@@                   Coverage Diff                    @@
##           release/v1.0.0.dev15      #41      +/-   ##
========================================================
+ Coverage                 71.08%   71.09%   +0.01%     
========================================================
  Files                       232      232              
  Lines                     10272    10269       -3     
  Branches                   1621     1617       -4     
========================================================
- Hits                       7302     7301       -1     
+ Misses                     2442     2441       -1     
+ Partials                    528      527       -1     
Flag Coverage Δ
postgres-18 71.09% <100.00%> (+0.01%) ⬆️
python-3.14 71.09% <100.00%> (+0.01%) ⬆️
unittests 71.09% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@sonarqubecloud

sonarqubecloud Bot commented Jun 4, 2026

Copy link
Copy Markdown

@vistart
vistart merged commit 42cd978 into release/v1.0.0.dev15 Jun 4, 2026
15 checks passed
@vistart vistart mentioned this pull request Jun 15, 2026
7 of 12 tasks
vistart added a commit that referenced this pull request Jun 15, 2026
* feat(postgres): use core SQL/XML XMLPARSE expression

Wire PostgreSQL XMLPARSE support through the core SQL/XML expression
protocol and remove the old PostgreSQL-specific function factory.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

* feat(postgres): add SQL/XML standard expression support

Enable PostgreSQL SQL/XML capabilities through core expression protocols,
keep PostgreSQL-specific XPath helpers separate, and add self-contained
examples that exercise expression-generated SQL.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

* chore: add changelog fragment for PR #41

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
@vistart
vistart deleted the feature/sqlxml-standard-support branch October 1, 2026 03:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant