Skip to content

Swift type generation emits invalid string literals for quoted database names #1126

Description

@hsusul

Bug

PostgreSQL identifiers and enum labels can contain double quotes, backslashes, and control characters. The Swift type generator currently interpolates enum raw values and CodingKeys raw values directly into quoted Swift literals. For example, a value containing a double quote terminates the literal early, and swiftc -parse rejects the generated source.

Reproduction

Generate Swift types for an enum label or column name containing a double quote and pipe the result to swiftc -parse -. The parser reports an unterminated string literal and invalid declarations.

Expected behavior

Generated Swift string literals should escape database-provided values while preserving the original raw enum label or coding key. Ordinary values should retain their current output.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions