2017-01-13 16:22 GMT+01:00 Jeremy Evans <jeremyeva...@gmail.com>:

> Are you running the current version of Sequel?  I remember fixing an issue
> like this sometime in the past.  The line number you give doesn't really
> make sense to cause the issue in the current code.  If you are running the
> current version, please post a minimal self contained example showing the
> problem, and a full backtrace, and I should be able to debug.
>

Here it is:
-------------------------------------------------------------------->8
require 'sqlite3'
require 'sequel'

DB = Sequel.connect('sqlite://companies')

DB.create_table :companies do
  primary_key :id
  String :name
end
DB[:companies].insert(name: 'Acme')

DB.create_table :positions do
  primary_key :id
  String :name
  foreign_key :company_id, :companies
end
DB[:positions].insert(name: 'CEO', company_id: DB[:companies].first[:id])
DB[:positions].insert(name: 'CTO', company_id: DB[:companies].first[:id])

class Company < Sequel::Model
  one_to_many :positions

  def validate
    super
    errors.add(:bla) if positions.size > 2
  end
end

class Position < Sequel::Model
  many_to_one :company
end

c = Company.first
c.freeze
---------------------------------------------------------------------->8

Greets.

-- 
David

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sequel-talk+unsubscr...@googlegroups.com.
To post to this group, send email to sequel-talk@googlegroups.com.
Visit this group at https://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.

Reply via email to