PageRenderTime 79ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/activerecord/test/cases/calculations_test.rb

https://bitbucket.org/rrmartins/rails
Ruby | 583 lines | 466 code | 108 blank | 9 comment | 14 complexity | 40d86e8ad2f745b3cfa52b6ff03aef0d MD5 | raw file
  1. require "cases/helper"
  2. require 'models/club'
  3. require 'models/company'
  4. require "models/contract"
  5. require 'models/edge'
  6. require 'models/organization'
  7. require 'models/possession'
  8. require 'models/topic'
  9. require 'models/minivan'
  10. require 'models/speedometer'
  11. Company.has_many :accounts
  12. class NumericData < ActiveRecord::Base
  13. self.table_name = 'numeric_data'
  14. end
  15. class CalculationsTest < ActiveRecord::TestCase
  16. fixtures :companies, :accounts, :topics
  17. def test_should_sum_field
  18. assert_equal 318, Account.sum(:credit_limit)
  19. end
  20. def test_should_average_field
  21. value = Account.average(:credit_limit)
  22. assert_equal 53.0, value
  23. end
  24. def test_should_return_decimal_average_of_integer_field
  25. value = Account.average(:id)
  26. assert_equal 3.5, value
  27. end
  28. def test_should_return_integer_average_if_db_returns_such
  29. Account.connection.stubs :select_value => 3
  30. value = Account.average(:id)
  31. assert_equal 3, value
  32. end
  33. def test_should_return_nil_as_average
  34. assert_nil NumericData.average(:bank_balance)
  35. end
  36. def test_type_cast_calculated_value_should_convert_db_averages_of_fixnum_class_to_decimal
  37. assert_equal 0, NumericData.all.send(:type_cast_calculated_value, 0, nil, 'avg')
  38. assert_equal 53.0, NumericData.all.send(:type_cast_calculated_value, 53, nil, 'avg')
  39. end
  40. def test_should_get_maximum_of_field
  41. assert_equal 60, Account.maximum(:credit_limit)
  42. end
  43. def test_should_get_maximum_of_field_with_include
  44. assert_equal 55, Account.where("companies.name != 'Summit'").references(:companies).includes(:firm).maximum(:credit_limit)
  45. end
  46. def test_should_get_minimum_of_field
  47. assert_equal 50, Account.minimum(:credit_limit)
  48. end
  49. def test_should_group_by_field
  50. c = Account.group(:firm_id).sum(:credit_limit)
  51. [1,6,2].each do |firm_id|
  52. assert c.keys.include?(firm_id), "Group #{c.inspect} does not contain firm_id #{firm_id}"
  53. end
  54. end
  55. def test_should_group_by_arel_attribute
  56. c = Account.group(Account.arel_table[:firm_id]).sum(:credit_limit)
  57. [1,6,2].each do |firm_id|
  58. assert c.keys.include?(firm_id), "Group #{c.inspect} does not contain firm_id #{firm_id}"
  59. end
  60. end
  61. def test_should_group_by_multiple_fields
  62. c = Account.group('firm_id', :credit_limit).count(:all)
  63. [ [nil, 50], [1, 50], [6, 50], [6, 55], [9, 53], [2, 60] ].each { |firm_and_limit| assert c.keys.include?(firm_and_limit) }
  64. end
  65. def test_should_group_by_multiple_fields_having_functions
  66. c = Topic.group(:author_name, 'COALESCE(type, title)').count(:all)
  67. assert_equal 1, c[["Carl", "The Third Topic of the day"]]
  68. assert_equal 1, c[["Mary", "Reply"]]
  69. assert_equal 1, c[["David", "The First Topic"]]
  70. assert_equal 1, c[["Carl", "Reply"]]
  71. end
  72. def test_should_group_by_summed_field
  73. c = Account.group(:firm_id).sum(:credit_limit)
  74. assert_equal 50, c[1]
  75. assert_equal 105, c[6]
  76. assert_equal 60, c[2]
  77. end
  78. def test_should_order_by_grouped_field
  79. c = Account.all.merge!(:group => :firm_id, :order => "firm_id").sum(:credit_limit)
  80. assert_equal [1, 2, 6, 9], c.keys.compact
  81. end
  82. def test_should_order_by_calculation
  83. c = Account.all.merge!(:group => :firm_id, :order => "sum_credit_limit desc, firm_id").sum(:credit_limit)
  84. assert_equal [105, 60, 53, 50, 50], c.keys.collect { |k| c[k] }
  85. assert_equal [6, 2, 9, 1], c.keys.compact
  86. end
  87. def test_should_limit_calculation
  88. c = Account.all.merge!(:where => "firm_id IS NOT NULL",
  89. :group => :firm_id, :order => "firm_id", :limit => 2).sum(:credit_limit)
  90. assert_equal [1, 2], c.keys.compact
  91. end
  92. def test_should_limit_calculation_with_offset
  93. c = Account.all.merge!(:where => "firm_id IS NOT NULL", :group => :firm_id,
  94. :order => "firm_id", :limit => 2, :offset => 1).sum(:credit_limit)
  95. assert_equal [2, 6], c.keys.compact
  96. end
  97. def test_limit_should_apply_before_count
  98. accounts = Account.limit(3).where('firm_id IS NOT NULL')
  99. assert_equal 3, accounts.count(:firm_id)
  100. assert_equal 3, accounts.select(:firm_id).count
  101. end
  102. def test_count_should_shortcut_with_limit_zero
  103. accounts = Account.limit(0)
  104. assert_no_queries { assert_equal 0, accounts.count }
  105. end
  106. def test_limit_is_kept
  107. return if current_adapter?(:OracleAdapter)
  108. queries = assert_sql { Account.limit(1).count }
  109. assert_equal 1, queries.length
  110. assert_match(/LIMIT/, queries.first)
  111. end
  112. def test_offset_is_kept
  113. return if current_adapter?(:OracleAdapter)
  114. queries = assert_sql { Account.offset(1).count }
  115. assert_equal 1, queries.length
  116. assert_match(/OFFSET/, queries.first)
  117. end
  118. def test_limit_with_offset_is_kept
  119. return if current_adapter?(:OracleAdapter)
  120. queries = assert_sql { Account.limit(1).offset(1).count }
  121. assert_equal 1, queries.length
  122. assert_match(/LIMIT/, queries.first)
  123. assert_match(/OFFSET/, queries.first)
  124. end
  125. def test_no_limit_no_offset
  126. queries = assert_sql { Account.count }
  127. assert_equal 1, queries.length
  128. assert_no_match(/LIMIT/, queries.first)
  129. assert_no_match(/OFFSET/, queries.first)
  130. end
  131. def test_should_group_by_summed_field_having_condition
  132. c = Account.all.merge!(:group => :firm_id,
  133. :having => 'sum(credit_limit) > 50').sum(:credit_limit)
  134. assert_nil c[1]
  135. assert_equal 105, c[6]
  136. assert_equal 60, c[2]
  137. end
  138. def test_should_group_by_summed_field_having_condition_from_select
  139. c = Account.select("MIN(credit_limit) AS min_credit_limit").group(:firm_id).having("MIN(credit_limit) > 50").sum(:credit_limit)
  140. assert_nil c[1]
  141. assert_equal 60, c[2]
  142. assert_equal 53, c[9]
  143. end
  144. def test_should_group_by_summed_association
  145. c = Account.group(:firm).sum(:credit_limit)
  146. assert_equal 50, c[companies(:first_firm)]
  147. assert_equal 105, c[companies(:rails_core)]
  148. assert_equal 60, c[companies(:first_client)]
  149. end
  150. def test_should_sum_field_with_conditions
  151. assert_equal 105, Account.where('firm_id = 6').sum(:credit_limit)
  152. end
  153. def test_should_return_zero_if_sum_conditions_return_nothing
  154. assert_equal 0, Account.where('1 = 2').sum(:credit_limit)
  155. assert_equal 0, companies(:rails_core).companies.where('1 = 2').sum(:id)
  156. end
  157. def test_sum_should_return_valid_values_for_decimals
  158. NumericData.create(:bank_balance => 19.83)
  159. assert_equal 19.83, NumericData.sum(:bank_balance)
  160. end
  161. def test_should_group_by_summed_field_with_conditions
  162. c = Account.all.merge!(:where => 'firm_id > 1',
  163. :group => :firm_id).sum(:credit_limit)
  164. assert_nil c[1]
  165. assert_equal 105, c[6]
  166. assert_equal 60, c[2]
  167. end
  168. def test_should_group_by_summed_field_with_conditions_and_having
  169. c = Account.all.merge!(:where => 'firm_id > 1',
  170. :group => :firm_id,
  171. :having => 'sum(credit_limit) > 60').sum(:credit_limit)
  172. assert_nil c[1]
  173. assert_equal 105, c[6]
  174. assert_nil c[2]
  175. end
  176. def test_should_group_by_fields_with_table_alias
  177. c = Account.group('accounts.firm_id').sum(:credit_limit)
  178. assert_equal 50, c[1]
  179. assert_equal 105, c[6]
  180. assert_equal 60, c[2]
  181. end
  182. def test_should_calculate_with_invalid_field
  183. assert_equal 6, Account.calculate(:count, '*')
  184. assert_equal 6, Account.calculate(:count, :all)
  185. end
  186. def test_should_calculate_grouped_with_invalid_field
  187. c = Account.group('accounts.firm_id').count(:all)
  188. assert_equal 1, c[1]
  189. assert_equal 2, c[6]
  190. assert_equal 1, c[2]
  191. end
  192. def test_should_calculate_grouped_association_with_invalid_field
  193. c = Account.group(:firm).count(:all)
  194. assert_equal 1, c[companies(:first_firm)]
  195. assert_equal 2, c[companies(:rails_core)]
  196. assert_equal 1, c[companies(:first_client)]
  197. end
  198. def test_should_group_by_association_with_non_numeric_foreign_key
  199. Speedometer.create! id: 'ABC'
  200. Minivan.create! id: 'OMG', speedometer_id: 'ABC'
  201. c = Minivan.group(:speedometer).count(:all)
  202. first_key = c.keys.first
  203. assert_equal Speedometer, first_key.class
  204. assert_equal 1, c[first_key]
  205. end
  206. def test_should_calculate_grouped_association_with_foreign_key_option
  207. Account.belongs_to :another_firm, :class_name => 'Firm', :foreign_key => 'firm_id'
  208. c = Account.group(:another_firm).count(:all)
  209. assert_equal 1, c[companies(:first_firm)]
  210. assert_equal 2, c[companies(:rails_core)]
  211. assert_equal 1, c[companies(:first_client)]
  212. end
  213. def test_should_calculate_grouped_by_function
  214. c = Company.group("UPPER(#{QUOTED_TYPE})").count(:all)
  215. assert_equal 2, c[nil]
  216. assert_equal 1, c['DEPENDENTFIRM']
  217. assert_equal 4, c['CLIENT']
  218. assert_equal 2, c['FIRM']
  219. end
  220. def test_should_calculate_grouped_by_function_with_table_alias
  221. c = Company.group("UPPER(companies.#{QUOTED_TYPE})").count(:all)
  222. assert_equal 2, c[nil]
  223. assert_equal 1, c['DEPENDENTFIRM']
  224. assert_equal 4, c['CLIENT']
  225. assert_equal 2, c['FIRM']
  226. end
  227. def test_should_not_overshadow_enumerable_sum
  228. assert_equal 6, [1, 2, 3].sum(&:abs)
  229. end
  230. def test_should_sum_scoped_field
  231. assert_equal 15, companies(:rails_core).companies.sum(:id)
  232. end
  233. def test_should_sum_scoped_field_with_from
  234. assert_equal Club.count, Organization.clubs.count
  235. end
  236. def test_should_sum_scoped_field_with_conditions
  237. assert_equal 8, companies(:rails_core).companies.where('id > 7').sum(:id)
  238. end
  239. def test_should_group_by_scoped_field
  240. c = companies(:rails_core).companies.group(:name).sum(:id)
  241. assert_equal 7, c['Leetsoft']
  242. assert_equal 8, c['Jadedpixel']
  243. end
  244. def test_should_group_by_summed_field_through_association_and_having
  245. c = companies(:rails_core).companies.group(:name).having('sum(id) > 7').sum(:id)
  246. assert_nil c['Leetsoft']
  247. assert_equal 8, c['Jadedpixel']
  248. end
  249. def test_should_count_selected_field_with_include
  250. assert_equal 6, Account.includes(:firm).count(:distinct => true)
  251. assert_equal 4, Account.includes(:firm).select(:credit_limit).count(:distinct => true)
  252. end
  253. def test_should_not_perform_joined_include_by_default
  254. assert_equal Account.count, Account.includes(:firm).count
  255. queries = assert_sql { Account.includes(:firm).count }
  256. assert_no_match(/join/i, queries.last)
  257. end
  258. def test_should_perform_joined_include_when_referencing_included_tables
  259. joined_count = Account.includes(:firm).where(:companies => {:name => '37signals'}).count
  260. assert_equal 1, joined_count
  261. end
  262. def test_should_count_scoped_select
  263. Account.update_all("credit_limit = NULL")
  264. assert_equal 0, Account.all.merge!(:select => "credit_limit").count
  265. end
  266. def test_should_count_scoped_select_with_options
  267. Account.update_all("credit_limit = NULL")
  268. Account.last.update_columns('credit_limit' => 49)
  269. Account.first.update_columns('credit_limit' => 51)
  270. assert_equal 1, Account.all.merge!(:select => "credit_limit").where('credit_limit >= 50').count
  271. end
  272. def test_should_count_manual_select_with_include
  273. assert_equal 6, Account.all.merge!(:select => "DISTINCT accounts.id", :includes => :firm).count
  274. end
  275. def test_count_with_column_parameter
  276. assert_equal 5, Account.count(:firm_id)
  277. end
  278. def test_count_with_column_and_options_parameter
  279. assert_equal 2, Account.where("credit_limit = 50 AND firm_id IS NOT NULL").count(:firm_id)
  280. end
  281. def test_should_count_field_in_joined_table
  282. assert_equal 5, Account.joins(:firm).count('companies.id')
  283. assert_equal 4, Account.joins(:firm).count('companies.id', :distinct => true)
  284. end
  285. def test_should_count_field_in_joined_table_with_group_by
  286. c = Account.all.merge!(:group => 'accounts.firm_id', :joins => :firm).count('companies.id')
  287. [1,6,2,9].each { |firm_id| assert c.keys.include?(firm_id) }
  288. end
  289. def test_count_with_no_parameters_isnt_deprecated
  290. assert_not_deprecated { Account.count }
  291. end
  292. def test_count_with_too_many_parameters_raises
  293. assert_raise(ArgumentError) { Account.count(1, 2, 3) }
  294. end
  295. def test_should_sum_expression
  296. # Oracle adapter returns floating point value 636.0 after SUM
  297. if current_adapter?(:OracleAdapter)
  298. assert_equal 636, Account.sum("2 * credit_limit")
  299. else
  300. assert_equal 636, Account.sum("2 * credit_limit").to_i
  301. end
  302. end
  303. def test_sum_expression_returns_zero_when_no_records_to_sum
  304. assert_equal 0, Account.where('1 = 2').sum("2 * credit_limit")
  305. end
  306. def test_count_with_from_option
  307. assert_equal Company.count(:all), Company.from('companies').count(:all)
  308. assert_equal Account.where("credit_limit = 50").count(:all),
  309. Account.from('accounts').where("credit_limit = 50").count(:all)
  310. assert_equal Company.where(:type => "Firm").count(:type),
  311. Company.where(:type => "Firm").from('companies').count(:type)
  312. end
  313. def test_count_with_block_acts_as_array
  314. accounts = Account.where('id > 0')
  315. assert_equal Account.count, accounts.count { true }
  316. assert_equal 0, accounts.count { false }
  317. assert_equal Account.where('credit_limit > 50').size, accounts.count { |account| account.credit_limit > 50 }
  318. assert_equal Account.count, Account.count { true }
  319. assert_equal 0, Account.count { false }
  320. end
  321. def test_sum_with_block_acts_as_array
  322. accounts = Account.where('id > 0')
  323. assert_equal Account.sum(:credit_limit), accounts.sum { |account| account.credit_limit }
  324. assert_equal Account.sum(:credit_limit) + Account.count, accounts.sum{ |account| account.credit_limit + 1 }
  325. assert_equal 0, accounts.sum { |account| 0 }
  326. end
  327. def test_sum_with_from_option
  328. assert_equal Account.sum(:credit_limit), Account.from('accounts').sum(:credit_limit)
  329. assert_equal Account.where("credit_limit > 50").sum(:credit_limit),
  330. Account.where("credit_limit > 50").from('accounts').sum(:credit_limit)
  331. end
  332. def test_sum_array_compatibility
  333. assert_equal Account.sum(:credit_limit), Account.sum(&:credit_limit)
  334. end
  335. def test_average_with_from_option
  336. assert_equal Account.average(:credit_limit), Account.from('accounts').average(:credit_limit)
  337. assert_equal Account.where("credit_limit > 50").average(:credit_limit),
  338. Account.where("credit_limit > 50").from('accounts').average(:credit_limit)
  339. end
  340. def test_minimum_with_from_option
  341. assert_equal Account.minimum(:credit_limit), Account.from('accounts').minimum(:credit_limit)
  342. assert_equal Account.where("credit_limit > 50").minimum(:credit_limit),
  343. Account.where("credit_limit > 50").from('accounts').minimum(:credit_limit)
  344. end
  345. def test_maximum_with_from_option
  346. assert_equal Account.maximum(:credit_limit), Account.from('accounts').maximum(:credit_limit)
  347. assert_equal Account.where("credit_limit > 50").maximum(:credit_limit),
  348. Account.where("credit_limit > 50").from('accounts').maximum(:credit_limit)
  349. end
  350. def test_maximum_with_not_auto_table_name_prefix_if_column_included
  351. Company.create!(:name => "test", :contracts => [Contract.new(:developer_id => 7)])
  352. # TODO: Investigate why PG isn't being typecast
  353. if current_adapter?(:PostgreSQLAdapter) || current_adapter?(:MysqlAdapter)
  354. assert_equal "7", Company.includes(:contracts).maximum(:developer_id)
  355. else
  356. assert_equal 7, Company.includes(:contracts).maximum(:developer_id)
  357. end
  358. end
  359. def test_minimum_with_not_auto_table_name_prefix_if_column_included
  360. Company.create!(:name => "test", :contracts => [Contract.new(:developer_id => 7)])
  361. # TODO: Investigate why PG isn't being typecast
  362. if current_adapter?(:PostgreSQLAdapter) || current_adapter?(:MysqlAdapter)
  363. assert_equal "7", Company.includes(:contracts).minimum(:developer_id)
  364. else
  365. assert_equal 7, Company.includes(:contracts).minimum(:developer_id)
  366. end
  367. end
  368. def test_sum_with_not_auto_table_name_prefix_if_column_included
  369. Company.create!(:name => "test", :contracts => [Contract.new(:developer_id => 7)])
  370. # TODO: Investigate why PG isn't being typecast
  371. if current_adapter?(:MysqlAdapter) || current_adapter?(:PostgreSQLAdapter)
  372. assert_equal "7", Company.includes(:contracts).sum(:developer_id)
  373. else
  374. assert_equal 7, Company.includes(:contracts).sum(:developer_id)
  375. end
  376. end
  377. def test_from_option_with_specified_index
  378. if Edge.connection.adapter_name == 'MySQL' or Edge.connection.adapter_name == 'Mysql2'
  379. assert_equal Edge.count(:all), Edge.from('edges USE INDEX(unique_edge_index)').count(:all)
  380. assert_equal Edge.where('sink_id < 5').count(:all),
  381. Edge.from('edges USE INDEX(unique_edge_index)').where('sink_id < 5').count(:all)
  382. end
  383. end
  384. def test_from_option_with_table_different_than_class
  385. assert_equal Account.count(:all), Company.from('accounts').count(:all)
  386. end
  387. def test_distinct_is_honored_when_used_with_count_operation_after_group
  388. # Count the number of authors for approved topics
  389. approved_topics_count = Topic.group(:approved).count(:author_name)[true]
  390. assert_equal approved_topics_count, 3
  391. # Count the number of distinct authors for approved Topics
  392. distinct_authors_for_approved_count = Topic.group(:approved).count(:author_name, :distinct => true)[true]
  393. assert_equal distinct_authors_for_approved_count, 2
  394. end
  395. def test_pluck
  396. assert_equal [1,2,3,4], Topic.order(:id).pluck(:id)
  397. end
  398. def test_pluck_type_cast
  399. topic = topics(:first)
  400. relation = Topic.where(:id => topic.id)
  401. assert_equal [ topic.approved ], relation.pluck(:approved)
  402. assert_equal [ topic.last_read ], relation.pluck(:last_read)
  403. assert_equal [ topic.written_on ], relation.pluck(:written_on)
  404. end
  405. def test_pluck_and_uniq
  406. assert_equal [50, 53, 55, 60], Account.order(:credit_limit).uniq.pluck(:credit_limit)
  407. end
  408. def test_pluck_in_relation
  409. company = Company.first
  410. contract = company.contracts.create!
  411. assert_equal [contract.id], company.contracts.pluck(:id)
  412. end
  413. def test_pluck_with_serialization
  414. t = Topic.create!(:content => { :foo => :bar })
  415. assert_equal [{:foo => :bar}], Topic.where(:id => t.id).pluck(:content)
  416. end
  417. def test_pluck_with_qualified_column_name
  418. assert_equal [1,2,3,4], Topic.order(:id).pluck("topics.id")
  419. end
  420. def test_pluck_auto_table_name_prefix
  421. c = Company.create!(:name => "test", :contracts => [Contract.new])
  422. assert_equal [c.id], Company.joins(:contracts).pluck(:id)
  423. end
  424. def test_pluck_if_table_included
  425. c = Company.create!(:name => "test", :contracts => [Contract.new(:developer_id => 7)])
  426. assert_equal [c.id], Company.includes(:contracts).where("contracts.id" => c.contracts.first).pluck(:id)
  427. end
  428. def test_pluck_not_auto_table_name_prefix_if_column_joined
  429. Company.create!(:name => "test", :contracts => [Contract.new(:developer_id => 7)])
  430. assert_equal [7], Company.joins(:contracts).pluck(:developer_id)
  431. end
  432. def test_pluck_with_selection_clause
  433. assert_equal [50, 53, 55, 60], Account.pluck('DISTINCT credit_limit').sort
  434. assert_equal [50, 53, 55, 60], Account.pluck('DISTINCT accounts.credit_limit').sort
  435. assert_equal [50, 53, 55, 60], Account.pluck('DISTINCT(credit_limit)').sort
  436. # MySQL returns "SUM(DISTINCT(credit_limit))" as the column name unless
  437. # an alias is provided. Without the alias, the column cannot be found
  438. # and properly typecast.
  439. assert_equal [50 + 53 + 55 + 60], Account.pluck('SUM(DISTINCT(credit_limit)) as credit_limit')
  440. end
  441. def test_plucks_with_ids
  442. assert_equal Company.all.map(&:id).sort, Company.ids.sort
  443. end
  444. def test_pluck_not_auto_table_name_prefix_if_column_included
  445. Company.create!(:name => "test", :contracts => [Contract.new(:developer_id => 7)])
  446. ids = Company.includes(:contracts).pluck(:developer_id)
  447. assert_equal Company.count, ids.length
  448. assert_equal [7], ids.compact
  449. end
  450. def test_pluck_multiple_columns
  451. assert_equal [
  452. [1, "The First Topic"], [2, "The Second Topic of the day"],
  453. [3, "The Third Topic of the day"], [4, "The Fourth Topic of the day"]
  454. ], Topic.order(:id).pluck(:id, :title)
  455. assert_equal [
  456. [1, "The First Topic", "David"], [2, "The Second Topic of the day", "Mary"],
  457. [3, "The Third Topic of the day", "Carl"], [4, "The Fourth Topic of the day", "Carl"]
  458. ], Topic.order(:id).pluck(:id, :title, :author_name)
  459. end
  460. def test_pluck_with_multiple_columns_and_selection_clause
  461. assert_equal [[1, 50], [2, 50], [3, 50], [4, 60], [5, 55], [6, 53]],
  462. Account.pluck('id, credit_limit')
  463. end
  464. def test_pluck_with_multiple_columns_and_includes
  465. Company.create!(:name => "test", :contracts => [Contract.new(:developer_id => 7)])
  466. companies_and_developers = Company.order('companies.id').includes(:contracts).pluck(:name, :developer_id)
  467. assert_equal Company.count, companies_and_developers.length
  468. assert_equal ["37signals", nil], companies_and_developers.first
  469. assert_equal ["test", 7], companies_and_developers.last
  470. end
  471. def test_pluck_with_reserved_words
  472. Possession.create!(:where => "Over There")
  473. assert_equal ["Over There"], Possession.pluck(:where)
  474. end
  475. end