Skip to content

has_many_polymorphs fails with Postgres DB and columns with capitalized letters #12

@pr0zac

Description

@pr0zac

I've been creating a rails project using has_many_polymorphs to create associations between models. Some of these models store data in columns directly related to keys in incoming/outgoing plists. This has resulted in some of the columns having capitalized names. Unfortunately, postgres automatically lowercases all characters in passed column names unless they are correctly double quoted. In its current form, has_many_polymorphs does not correctly handle this case. The error looks similar to this:

CollectionsMember Load (0.0ms) PGError: ERROR: column devices.udid does not exist
LINE 1: ...S t0_r2, collections_members.updated_at AS t0_r5, devices.Udid...

I have managed to force things to work correctly by adding quotes around column names in base.rb, function instantiate_with_polymorphic_checks, and in class_methods.rb, function build_table_aliases, though this is likely just a stop gap, as I haven't tested its effects on any other databases, and not fit for actual integration.

This issue likely effects a lot more people than just me, as this seems like a pretty common use case, and can hopefully be addressed quickly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions