paulelliott / fabrication

This project has moved to GitLab! Please check there for the latest updates.
https://gitlab.com/fabrication-gem/fabrication
MIT License
998 stars 97 forks source link

ActiveRecord view backed model with custom primary key #310

Open 2009 opened 6 years ago

2009 commented 6 years ago

First a bit of context, I have a fabricator for an ActiveRecord model that is backed by a materialized view which has both an id column and pk column (my custom primary key column).

I run into the issue where setting the pk or id results in both fields being set to the same string value, so my id column ends up with a string value when it should be an integer.

       Column        |            Type             | Collation | Nullable | Default | Storage  | Stats target | Description
---------------------+-----------------------------+-----------+----------+---------+----------+--------------+-------------
 pk                  | text                        |           |          |         | extended |              |
 id                  | integer                     |           |          |         | plain    |              |

Ultimately I want to be able to test I get the right data back when I perform a sql join on id column of the materialized view.

paulelliott commented 6 years ago

@2009 Can you post the content of the fabricator in question?