sqlc icon indicating copy to clipboard operation
sqlc copied to clipboard

Override Function Not Working Properly for pg_type.numeric with Row Type Result

Open DarkHeros09 opened this issue 8 months ago • 0 comments

I am experiencing an issue with the override function in SQLC. I am attempting to override pg_type.numeric to decimal.Decimal. This override works correctly for most queries. However, when I perform a SELECT query that joins multiple tables resulting in a Row type, the override does not function as expected.

Expected Behavior:

The pg_type.numeric should be overridden to decimal.Decimal in all query results, including those that return a Row type.

Actual Behavior:

The override works for standard queries but fails when the SELECT query joins multiple tables and returns a Row type. In these cases, the pg_type.numeric is not overridden to decimal.Decimal.

Steps to Reproduce:

  1. Define an override for pg_type.numeric to decimal.Decimal.
  2. Execute a SELECT query that joins multiple tables resulting in a Row type.
  3. Observe that the override does not apply to the pg_type.numeric fields in the Row type result.

Additional Observation:

If I override by column and type, the override works, but I get an error when I run the query:

ERROR: invalid input syntax for type numeric: "" (SQLSTATE 22P02)

Additional Context:

The override functions correctly for queries that do not involve joining multiple tables. It seems to be specific to when the result is a Row type due to multiple table joins.

Thank you for your attention to this issue. Please let me know if you need any further information or clarification.

Please refer to the provided Playground Link to see the code and reproduce the issue.

Relevant log output

No response

Database schema

No response

SQL queries

No response

Configuration

No response

Playground URL

https://play.sqlc.dev/p/56e7f9637ae1448a51e6067c722bf11a13c1cde9407f6d2fd8d5ffef7e2590ee

What operating system are you using?

Windows

What database engines are you using?

PostgreSQL

What type of code are you generating?

Go

DarkHeros09 avatar Jun 22 '24 22:06 DarkHeros09