同样的代码在不同的版本里被解析出来的结果为啥不一致呢,同一个数据库,代码都一样,rails 行为不一样。 controller
def index
@user = get_user
@role = get_user_role
@locations = Location.all.map { |l| l[:locationid] }
params[:location] = session[:location] if !session[:location].nil?
unless params[:location].nil?
@locations = [Location.where({:name => OSUtils.get_location_name(params[:location])}).first.locationid]
end
@topologies = Topology.find(:all,
:conditions => ["status != ? AND testbed_id IN (?) AND location_id IN (?)",
'TERMINATED', Testbed.where(:tb_type => "OSEXEC").all.map {|t| t.tbid}, @locations ])
end
log in rails 4.2.5
Started GET "/topologies" for 10.103.201.205 at 2016-03-14 15:09:30 +0800
Processing by TopologiesController#index as HTML
Location Load (333.7ms) SELECT "location".* FROM "location"
Location Load (332.6ms) SELECT "location".* FROM "location" WHERE "location"."name" = $1 ORDER BY "location"."locationid" ASC LIMIT 1 [["name", "Shanghai"]]
Testbed Load (672.7ms) SELECT "testbed".* FROM "testbed" WHERE "testbed"."tb_type" = $1 [["tb_type", "OSEXEC"]]
Completed 404 Not Found in 1682ms (ActiveRecord: 1672.6ms)
ActiveRecord::RecordNotFound (Couldn't find all Topologies with 'topology_id': (all, {:conditions=>["status != ? AND testbed_id IN (?) AND location_id IN (?)", "TERMINATED", [283, 356, 279, 280, 336, 282, 281, 286, 285, 358, 295, 288, 332, 327, 264, 247, 337, 313, 287, 335, 341, 284, 339, 338, 352, 350, 351, 340, 246, 244, 242, 245, 243, 241, 324, 348, 357, 319, 364, 297, 333, 342, 349, 362, 355, 359, 311, 345, 300, 251, 322, 346, 249, 302, 274, 248, 303, 344, 250, 343, 254, 289, 328, 294, 293, 252, 329, 292, 347, 363, 299, 305, 235, 325, 360, 315, 321, 310, 318, 361, 290, 255, 232, 323, 291, 326, 265, 301, 253, 261, 304, 259, 296, 260, 257, 267, 266, 256, 298, 258, 236, 272, 231, 314, 307, 233, 312, 239, 276, 273, 238, 316, 237, 308, 309, 230, 275, 317, 234, 320, 334], [3]]}) (found 0 results, but was looking for 2)):
app/controllers/topologies_controller.rb:38:in `index'
log in rails 3.2.2
Location Load (0.4ms) SELECT "location".* FROM "location"
Location Load (0.9ms) SELECT "location".* FROM "location" WHERE "location"."name" = 'Shanghai' LIMIT 1
Testbed Load (1.3ms) SELECT "testbed".* FROM "testbed" WHERE "testbed"."tb_type" = 'OSEXEC'
Topology Load (15.3ms) SELECT "topologies".* FROM "topologies" WHERE (status != 'TERMINATED' AND testbed_id IN (283,356,279,280,336,282,281,286,285,358,295,288,332,327,264,247,337,313,287,335,341,284,339,338,352,350,351,340,246,244,242,245,243,241,324,348,357,319,364,297,333,342,349,362,355,359,311,345,300,251,322,346,249,302,274,248,303,344,250,343,254,289,328,294,293,252,329,292,347,363,299,305,235,325,360,315,321,310,318,361,290,255,232,323,291,326,265,301,253,261,304,259,296,260,257,267,266,256,298,258,236,272,231,314,307,233,312,239,276,273,238,316,237,308,309,230,275,317,234,320,334) AND location_id IN (3))
看了下 3.2 的 log 才是想要的解析行为。这里 4.2.5log 解析出来的结果不对,百思不得其解啊。这是为啥?