Skip to content

Dialect specific types not handled on insert if field is aliased #4431

Closed

Description

@madtrick

Summary

Dialect specific types (like for example geometry on PG) are not parsed/handled on INSERTS if they belong to a model attribute which is aliased (i.e. the attribute name is different to the db column name).

expected behaviour

After saving an entry the attribute with type geometry would contain a GeoJSON object

broken behaviour

After saving an entry the attribute with type geometry does not contain a GeoJSON object but the raw geometry value.

Details

This happens because the map that holds the dialect specific attributes in the model [1] uses as keys the alias (not the db column names) but the key used to check if a column in the response rows is dialect specific [2] has the value of the db column.

I created a test that reproduces this behaviour master...madtrick:fix/transform-aliased-fields

[1] https://github.com/sequelize/sequelize/blob/master/lib/dialects/postgres/query.js#L311
[2] https://github.com/sequelize/sequelize/blob/master/lib/dialects/postgres/query.js#L319

Activity

  1. added a commit that references this issue on Sep 9, 2015
    31da456
  2. janmeier commented on Sep 9, 2015

    @janmeier
    Member

    I've added the test in 31da456, which is part of #4186

  3. madtrick commented on Sep 10, 2015

    @madtrick
    Author

    @jamelt 👍

  4. self-assigned this
    on Sep 16, 2015
  5. added
    type: bug
    on Sep 16, 2015
  6. added 2 commits that reference this issue on Nov 9, 2015
    d67889f
    785ff33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

type: bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions