Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Model.create not setting values on parent polymorphic model #34

Closed
Blacksmoke16 opened this issue Sep 2, 2018 · 0 comments
Closed

Model.create not setting values on parent polymorphic model #34

Blacksmoke16 opened this issue Sep 2, 2018 · 0 comments
Labels

Comments

@Blacksmoke16
Copy link
Contributor

module EveToolsApi::Models
  abstract class Contract
    include Clear::Model
    self.table = "contracts"

    column contract_id : Int32, primary: true

    polymorphic EveToolsApi::Models::Courier, EveToolsApi::Models::ItemExchange, through: "type"
  end
end
module EveToolsApi::Models
  class Courier < EveToolsApi::Models::Contract
    column reward : Int32
  end
end
module EveToolsApi::Models
  class ItemExchange < EveToolsApi::Models::Contract
    column price : Int32
  end
end

ItemExchange.create({contract_id: 3, price: 123})

pg      | 2018-09-02 22:53:53.905 UTC [3486] ERROR:  null value in column "contract_id" violates not-null constraint
pg      | 2018-09-02 22:53:53.905 UTC [3486] DETAIL:  Failing row contains (null, EveToolsApi::Models::ItemExchange, 0, 123).
pg      | 2018-09-02 22:53:53.905 UTC [3486] STATEMENT:  INSERT INTO "contracts" ("type", "price") VALUES ('EveToolsApi::Models::ItemExchange', 123) RETURNING *
api2    | Error catched, last request was:
api2    | INSERT INTO "contracts" ("type", "price") VALUES ('EveToolsApi::Models::ItemExchange', 123) RETURNING *
@anykeyh anykeyh added the bug label Sep 3, 2018
@anykeyh anykeyh closed this as completed in 30465b5 Sep 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants