Ruby `除了';:不支持的情况除外(Sequel::InvalidOperation)
我在尝试运行sinatra应用程序时遇到错误。我试着用谷歌搜索,结果什么也没找到。如果你们能提供任何关于如何修复它或我做错了什么的建议,这将是非常有帮助的 出错代码的一部分Ruby `除了';:不支持的情况除外(Sequel::InvalidOperation),ruby,sinatra,Ruby,Sinatra,我在尝试运行sinatra应用程序时遇到错误。我试着用谷歌搜索,结果什么也没找到。如果你们能提供任何关于如何修复它或我做错了什么的建议,这将是非常有帮助的 出错代码的一部分 def logTownDeltas!(newDate) deltas = [] oldTowns = @db[:towns].filter { data_timestamp < newDate } currentTowns = @db[:towns].except
def logTownDeltas!(newDate)
deltas = []
oldTowns = @db[:towns].filter { data_timestamp < newDate }
currentTowns = @db[:towns].except(oldTowns)
destroyedTownIDs = oldTowns.select(:town_id).except(currentTowns.select(:town_id)).collect { |d| d[:town_id] }
createdTownIDs = currentTowns.select(:town_id).except(oldTowns.select(:town_id)).collect { |c| c[:town_id] }
alteredTowns = Hash.new
currentTowns.each { |town|
}
试试这个:
def logTownDeltas!(newDate)
deltas = []
currentTowns = @db[:towns].filter { data_timestamp >= newDate }
destroyedTownIDs = @db[:towns].select(:town_id).filter { data_timestamp < newDate }.collect { |d| d[:town_id] }
createdTownIDs = @db[:towns].select(:town_id).filter { data_timestamp >= newDate }.collect { |c| c[:town_id] }
alteredTowns = Hash.new
currentTowns.each { |town|
}
def logTownDeltas!(新日期)
三角洲=[]
currentTowns=@db[:towns]。筛选器{data\u timestamp>=newDate}
destroyedTownIDs=@db[:towns]。选择(:town_id)。筛选{data_timestamp=newDate}。收集{c | c[:town_id]}
alteredTowns=Hash.new
currentTowns.each{|镇|
}
我使用的是MySql数据库MySql除了语法外不支持其他语法。看到了吗?是的,我看到了,在我现在发布了这篇文章之后,我正试图找出当我将它改为开始获取C:/Ruby22/lib/ruby/gems/2.2.0/gems/sequel-4.29.0/lib/sequel/adapters/mysql时,我将得到什么来代替except。rb:175:'query':mysql::Error:Subquery返回超过1行(sequel::DatabaseError)非常感谢您的帮助我遇到了一个问题我的下一行代码在找到destroyedTownIDs和createdTownIDs后它输入数据库仅destroyedTownIDs有0 pop,然后执行createdTownIDs但现在它为前一天数据库中的每个城镇创建0 pop数据。我把输入数据的代码放在上面的数据库中
destroyedTownIDs.each { |d|
t = oldTowns.filter(:town_id => d).first
@db[:town_deltas].insert(
:happened_at => newDate,
:town_id => d,
:owner_id => t[:owner_id],
:name => t[:name],
:population => 0,
:is_capital => 0,
:is_alliance_capital => 0)
}
createdTownIDs.each { |c|
t = currentTowns.filter(:town_id => c).first
@db[:town_deltas].insert(
:happened_at => newDate,
:town_id => c,
:owner_id => t[:owner_id],
:name => t[:name],
:population => t[:population],
:is_capital => t[:is_capital],
:is_alliance_capital => t[:is_alliance_capital])
}
def logTownDeltas!(newDate)
deltas = []
currentTowns = @db[:towns].filter { data_timestamp >= newDate }
destroyedTownIDs = @db[:towns].select(:town_id).filter { data_timestamp < newDate }.collect { |d| d[:town_id] }
createdTownIDs = @db[:towns].select(:town_id).filter { data_timestamp >= newDate }.collect { |c| c[:town_id] }
alteredTowns = Hash.new
currentTowns.each { |town|
}