sqlc icon indicating copy to clipboard operation
sqlc copied to clipboard

Fix Type Inference for Array Comparisons in SQL Queries

Open cmkqwerty opened this issue 1 year ago • 0 comments

Description In array comparisons made using ANY/SOME/ALL operators, the auto-generated Go code has incorrect type declarations.

Related Issue

#3083

Changes

  • The QueryValue struct accepts an extra field. This QueryText field is of string type and contains the SQL query running in context.
  • isUsedWithArrayComparison(), a method belonging to the QueryValue struct, has been implemented. In the running SQL query, it checks whether any of the ANY/SOME/ALL operators are used for the current field and returns bool. In this way, we do not encapsulate it with pr.Array() and we can convert the slice type argument into single data.

If desired, I am more than willing to add comprehensive tests to cover the modified functionality. Please let me know if this is something you'd like to include, and I'll be happy to work on it.

cmkqwerty avatar Dec 26 '23 17:12 cmkqwerty