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

Models with external relations do not compile #232

Closed
alex-min opened this issue Feb 28, 2019 · 2 comments
Closed

Models with external relations do not compile #232

alex-min opened this issue Feb 28, 2019 · 2 comments

Comments

@alex-min
Copy link

alex-min commented Feb 28, 2019

Hello,

I try to use Crecto from Amber with the basic default and it does not seem to work for foreign keys

I've reduced it to this:

require "pg"
require "crecto"

class User < Crecto::Model
  schema "users" do
    field :email, String
    field :hashed_password, String
  end
end

class Post < Crecto::Model
  schema "posts" do
    field :name, String
    belongs_to :user, User
  end
end

module Repo
  extend Crecto::Repo

  config do |c|
    c.adapter = Crecto::Adapters::Postgres

    c.uri = "postgres://postgres:@localhost:5432/abcdef_development"
  end
end

Repo.all Post

which produce this error:

no overload matches 'Proc(Crecto::Model, (Int16 | Int32 | Int64 | Int8 | String | Nil))#call' with type (Array(Bool | Float32 | Float64 | Int16 | Int32 | Int64 | Int8 | JSON::Any | String | Time | Nil) | Array(Int16 | Int32 | Int64 |Int8 | String | Nil) | Array(Int32) | Array(Int64) | Array(String) | Bool | Float32 | Float64 | Int16 | Int32 | Int64 | Int8 | JSON::Any | String | Time | Nil)
Overloads are:
 - Proc(T, R)#call(*args : *T)

Full traceback here: https://gist.github.com/alex-min/f29091438c15d76405d636355cf2b4e9 (because it's very long).

Is it because of #231 ? Because I'm on 0.27.2. I've tried to fix it in the crecto code but I can't make it work.

@alex-min alex-min changed the title belongs_to does not compile Models with external relations do not compile Feb 28, 2019
@fridgerator
Copy link
Member

Yes thats the same error I see when trying to run the specs on crystal 0.27.2

@fridgerator
Copy link
Member

Crecto is working with the latest crystal

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants