Blog (bug)

@fredwu 14 years ago | 1 min read | no comments
It was confirmed that DataMapper is incorrectly setting table names in SQL JOINs. So for instance, the following code would generate an SQL error: type.jobs.all(:"country.name".like => "%#{params[:location]}%") There is a workaround, however the workaround requires manual looping of the dataset thus produces N+1 queries. type.jobs.all.reject do |job| ! job.country.name.downcase.include?(params[:location].downcase) end But at least it works. ;)
@fredwu 14 years ago | 1 min read | no comments
It has been confirmed by DataMapper’s core developer Martin Gamsjaeger (snusnu) that it is a bug. In short, created_[at|on] can be manually overridden, but updated_[at|on] cannot. The workaround is simple, do it in two steps, for example: job = Job.create( title: "Web Developer", created_at: Time.now - 2 ) job.update!(updated_at: Time.now - 1) Please check the bug ticket to see when it’s getting fixed.