开发者

PostgreSQL activerecord weirdness for .maximum

I have an ActiveRecord before_save method throwing an odd error:

class MyThing < ActiveRecord::Base
  before_save :dostuff

  def dostuff
    p self.class.maximum(:mycolumn)
  end
end

When I was using SQLite this worked perfectly, now—with postgresql—I get the error:

PGError: ERROR: current transaction is aborted, commands ignored until end of transaction block : SHOW max_identifier_length

The .maximum method works outside that dostuff method, so I guess I'm just asking too much at once? Is there anothe开发者_如何学Cr way to get the maximum value of an integer column that will work inside a before_save?


The errormessage is about the max_identifier_length, the maximum length of an objectname (table, column, etc.). It has nothing to do with the SQL-function MAX(). Looks like you're using an invalid name, a name greater than 63 characters.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜