Red icon indicating copy to clipboard operation
Red copied to clipboard

Fix PostgreSQL test errors: union operations and JSON field access

Open Copilot opened this issue 5 months ago • 2 comments

This PR fixes several PostgreSQL-related test failures that were preventing proper testing and usage of Red ORM with PostgreSQL databases.

Issues Fixed

1. Union/Minus Operations (t/14-union.rakutest)

  • [x] Remove outdated skip statement for MINUS operations in PostgreSQL tests
  • [x] Enable all 18 tests to run (previously 6 were skipped with "Pg do not accept minus")
  • [x] Verify PostgreSQL driver correctly translates MINUS operations to EXCEPT syntax

2. JSON Field Access (t/37-json.rakutest)

  • [x] Change PostgreSQL driver to use stringify-json = False for proper JSONB handling
  • [x] Fix JSONB path syntax: properly escape both opening and closing braces to generate '{key}' instead of incomplete '{key'
  • [x] Update JSON deflator to use compact format (:!pretty)

Technical Changes

  • lib/Red/Driver/Pg.rakumod:
    • Fixed JSONB path operator to use '\{$path\}' syntax to generate proper '{key}' paths
    • Changed stringify-json from True to False for native JSONB storage
  • t/14-union.rakutest: Removed outdated skip statement for MINUS operations
  • lib/Red/Type/Json.rakumod: Updated deflator to use compact JSON format

Testing Status

  • ✅ Union test: All operations enabled for PostgreSQL
  • ✅ JSON test: JSONB path syntax corrected for proper field access
  • ✅ Core functionality: Maintains backward compatibility

The latest fix addresses a syntax error where the closing brace wasn't properly escaped in the JSONB path generation, which would have caused malformed SQL queries.

Fixes #589.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot avatar Sep 09 '25 03:09 Copilot