Skip to content
Browse files

SERVER-23971 Clang-Format code

1 parent d4ac567 commit 6dcdd23dd37ef12c87e71cf59ef01cd82432efe0 @markbenvenuto markbenvenuto committed May 28, 2016
Showing with 3,944 additions and 5,231 deletions.
  1. +12 −13 jstests/aggregation/bugs/cond.js
  2. +2 −14 jstests/aggregation/bugs/firstlast.js
  3. +3 −11 jstests/aggregation/bugs/match.js
  4. +21 −22 jstests/aggregation/bugs/server10176.js
  5. +29 −29 jstests/aggregation/bugs/server11118.js
  6. +39 −39 jstests/aggregation/bugs/server11675.js
  7. +1 −4 jstests/aggregation/bugs/server12015.js
  8. +2 −2 jstests/aggregation/bugs/server14670.js
  9. +8 −38 jstests/aggregation/bugs/server17943.js
  10. +2 −6 jstests/aggregation/bugs/server18198.js
  11. +5 −2 jstests/aggregation/bugs/server18222.js
  12. +90 −84 jstests/aggregation/bugs/server19095.js
  13. +27 −82 jstests/aggregation/bugs/server20163.js
  14. +8 −8 jstests/aggregation/bugs/server20169.js
  15. +1 −4 jstests/aggregation/bugs/server21632.js
  16. +2 −3 jstests/aggregation/bugs/server22093.js
  17. +6 −6 jstests/aggregation/bugs/server22580.js
  18. +7 −9 jstests/aggregation/bugs/server3253.js
  19. +12 −4 jstests/aggregation/bugs/server4588.js
  20. +6 −6 jstests/aggregation/bugs/server5044.js
  21. +16 −14 jstests/aggregation/bugs/server6121.js
  22. +1 −3 jstests/aggregation/bugs/server6125.js
  23. +6 −30 jstests/aggregation/bugs/server6131.js
  24. +5 −3 jstests/aggregation/bugs/server6179.js
  25. +42 −44 jstests/aggregation/bugs/server6189.js
  26. +3 −2 jstests/aggregation/bugs/server6190.js
  27. +1 −1 jstests/aggregation/bugs/server6195.js
  28. +7 −7 jstests/aggregation/bugs/server6529.js
  29. +2 −6 jstests/aggregation/bugs/server6531.js
  30. +6 −6 jstests/aggregation/bugs/server6556.js
  31. +2 −10 jstests/aggregation/bugs/server7781.js
  32. +52 −57 jstests/aggregation/bugs/server9840.js
  33. +12 −13 jstests/aggregation/bugs/server9841.js
  34. +13 −13 jstests/aggregation/bugs/substr.js
  35. +3 −2 jstests/aggregation/bugs/upperlower.js
  36. +38 −41 jstests/aggregation/expressions/expression_mod.js
  37. +12 −34 jstests/aggregation/expressions/in.js
  38. +4 −12 jstests/aggregation/expressions/indexof_array.js
  39. +5 −15 jstests/aggregation/expressions/indexof_bytes.js
  40. +5 −15 jstests/aggregation/expressions/indexof_codepoints.js
  41. +41 −49 jstests/aggregation/expressions/reduce.js
  42. +6 −18 jstests/aggregation/expressions/split.js
  43. +2 −4 jstests/aggregation/expressions/switch.js
  44. +7 −21 jstests/aggregation/expressions/switch_errors.js
  45. +3 −8 jstests/aggregation/extras/mrabench.js
  46. +7 −1 jstests/aggregation/extras/testutils.js
  47. +2 −6 jstests/aggregation/extras/utils.js
  48. +1 −4 jstests/aggregation/mongos_slaveok.js
  49. +37 −41 jstests/aggregation/sources/graphLookup/airports.js
  50. +81 −67 jstests/aggregation/sources/graphLookup/basic.js
  51. +16 −24 jstests/aggregation/sources/graphLookup/error.js
  52. +33 −27 jstests/aggregation/sources/graphLookup/nested_objects.js
  53. +2 −1 jstests/aggregation/sources/graphLookup/sharded.js
  54. +14 −12 jstests/aggregation/sources/graphLookup/socialite.js
  55. +1 −3 jstests/aggregation/testSlave.js
  56. +26 −5 jstests/aggregation/testall.js
  57. +31 −52 jstests/aggregation/testshard1.js
  58. +3 −4 jstests/aggregation/unwind.js
  59. +1 −4 jstests/auth/access_control_with_unreachable_configs.js
  60. +3 −10 jstests/auth/arbiter.js
  61. +1 −3 jstests/auth/auth_options.js
  62. +1 −4 jstests/auth/auth_schema_upgrade.js
  63. +3 −7 jstests/auth/authz_modifications_access_control.js
  64. +99 −137 jstests/auth/basic_role_auth.js
  65. +1 −4 jstests/auth/clac_system_colls.js
  66. +2 −8 jstests/auth/commands_builtin_roles.js
  67. +3 −12 jstests/auth/commands_user_defined_roles.js
  68. +8 −9 jstests/auth/copyauth.js
  69. +1 −5 jstests/auth/copyauth_between_shards.js
  70. +9 −11 jstests/auth/indexSystemUsers.js
  71. +1 −2 jstests/auth/js_scope_leak.js
  72. +28 −86 jstests/auth/lib/commands_lib.js
  73. +4 −8 jstests/auth/localhostAuthBypass.js
  74. +2 −9 jstests/auth/log_user_basic.js
  75. +3 −12 jstests/auth/pseudo_commands.js
  76. +1 −6 jstests/auth/renameSystemCollections.js
  77. +7 −14 jstests/auth/repl.js
  78. +4 −4 jstests/auth/repl_auth.js
  79. +23 −34 jstests/auth/resource_pattern_matching.js
  80. +9 −13 jstests/auth/role_management_commands.js
  81. +2 −8 jstests/auth/role_management_commands_edge_cases.js
  82. +33 −35 jstests/auth/server-4892.js
  83. +10 −6 jstests/auth/show_log_auth.js
  84. +3 −9 jstests/auth/upgrade_noauth_to_keyfile.js
  85. +2 −7 jstests/auth/upgrade_noauth_to_keyfile_with_sharding.js
  86. +12 −15 jstests/auth/user_defined_roles.js
  87. +6 −7 jstests/auth/user_defined_roles_on_secondaries.js
  88. +12 −15 jstests/auth/user_management_commands.js
  89. +1 −4 jstests/concurrency/fsm_background_workloads/background_base.js
  90. +14 −15 jstests/concurrency/fsm_example_inheritance.js
  91. +2 −9 jstests/concurrency/fsm_libs/cluster.js
  92. +6 −9 jstests/concurrency/fsm_libs/composer.js
  93. +2 −9 jstests/concurrency/fsm_libs/fsm.js
  94. +28 −32 jstests/concurrency/fsm_libs/parse_config.js
  95. +13 −15 jstests/concurrency/fsm_libs/runner.js
  96. +8 −12 jstests/concurrency/fsm_libs/thread_mgr.js
  97. +16 −21 jstests/concurrency/fsm_libs/worker_thread.js
  98. +1 −5 jstests/concurrency/fsm_selftests.js
  99. +4 −5 jstests/concurrency/fsm_workload_modifiers/make_capped.js
  100. +7 −10 jstests/concurrency/fsm_workloads/agg_base.js
  101. +18 −21 jstests/concurrency/fsm_workloads/agg_graph_lookup.js
  102. +38 −40 jstests/concurrency/fsm_workloads/agg_group_external.js
  103. +21 −23 jstests/concurrency/fsm_workloads/agg_match.js
  104. +19 −22 jstests/concurrency/fsm_workloads/agg_sort.js
  105. +33 −37 jstests/concurrency/fsm_workloads/agg_sort_external.js
  106. +2 −8 jstests/concurrency/fsm_workloads/auth_create_role.js
  107. +2 −8 jstests/concurrency/fsm_workloads/auth_create_user.js
  108. +3 −15 jstests/concurrency/fsm_workloads/auth_drop_role.js
  109. +3 −15 jstests/concurrency/fsm_workloads/auth_drop_user.js
  110. +2 −6 jstests/concurrency/fsm_workloads/collmod.js
  111. +20 −24 jstests/concurrency/fsm_workloads/collmod_separate_collections.js
  112. +1 −6 jstests/concurrency/fsm_workloads/compact.js
  113. +18 −20 jstests/concurrency/fsm_workloads/compact_simultaneous_padding_bytes.js
  114. +3 −11 jstests/concurrency/fsm_workloads/convert_to_capped_collection.js
  115. +8 −10 jstests/concurrency/fsm_workloads/convert_to_capped_collection_index.js
  116. +3 −15 jstests/concurrency/fsm_workloads/count.js
  117. +19 −24 jstests/concurrency/fsm_workloads/count_indexed.js
  118. +33 −39 jstests/concurrency/fsm_workloads/count_limit_skip.js
  119. +6 −17 jstests/concurrency/fsm_workloads/create_capped_collection.js
  120. +39 −41 jstests/concurrency/fsm_workloads/create_capped_collection_maxdocs.js
  121. +2 −8 jstests/concurrency/fsm_workloads/create_collection.js
  122. +4 −6 jstests/concurrency/fsm_workloads/create_index_background.js
  123. +3 −13 jstests/concurrency/fsm_workloads/distinct.js
  124. +3 −15 jstests/concurrency/fsm_workloads/distinct_noindex.js
  125. +8 −13 jstests/concurrency/fsm_workloads/distinct_projection.js
  126. +3 −15 jstests/concurrency/fsm_workloads/drop_collection.js
  127. +1 −4 jstests/concurrency/fsm_workloads/drop_database.js
  128. +1 −5 jstests/concurrency/fsm_workloads/explain.js
  129. +32 −38 jstests/concurrency/fsm_workloads/explain_aggregate.js
  130. +46 −51 jstests/concurrency/fsm_workloads/explain_count.js
  131. +19 −23 jstests/concurrency/fsm_workloads/explain_distinct.js
  132. +50 −55 jstests/concurrency/fsm_workloads/explain_find.js
  133. +13 −17 jstests/concurrency/fsm_workloads/explain_group.js
  134. +30 −35 jstests/concurrency/fsm_workloads/explain_remove.js
  135. +54 −59 jstests/concurrency/fsm_workloads/explain_update.js
  136. +2 −8 jstests/concurrency/fsm_workloads/findAndModify_inc.js
  137. +58 −64 jstests/concurrency/fsm_workloads/findAndModify_mixed_queue_unindexed.js
  138. +4 −18 jstests/concurrency/fsm_workloads/findAndModify_remove.js
  139. +7 −23 jstests/concurrency/fsm_workloads/findAndModify_remove_queue.js
  140. +9 −10 jstests/concurrency/fsm_workloads/findAndModify_remove_queue_unindexed.js
  141. +5 −7 jstests/concurrency/fsm_workloads/findAndModify_update.js
  142. +9 −10 jstests/concurrency/fsm_workloads/findAndModify_update_collscan.js
  143. +5 −14 jstests/concurrency/fsm_workloads/findAndModify_update_grow.js
  144. +42 −53 jstests/concurrency/fsm_workloads/findAndModify_update_queue.js
  145. +9 −10 jstests/concurrency/fsm_workloads/findAndModify_update_queue_unindexed.js
  146. +14 −27 jstests/concurrency/fsm_workloads/findAndModify_upsert.js
  147. +4 −7 jstests/concurrency/fsm_workloads/findAndModify_upsert_collscan.js
  148. +3 −9 jstests/concurrency/fsm_workloads/group.js
  149. +19 −23 jstests/concurrency/fsm_workloads/group_cond.js
  150. +10 −11 jstests/concurrency/fsm_workloads/indexed_insert_1char.js
  151. +36 −38 jstests/concurrency/fsm_workloads/indexed_insert_2d.js
  152. +9 −10 jstests/concurrency/fsm_workloads/indexed_insert_2dsphere.js
  153. +1 −5 jstests/concurrency/fsm_workloads/indexed_insert_base.js
  154. +21 −23 jstests/concurrency/fsm_workloads/indexed_insert_compound.js
  155. +18 −20 jstests/concurrency/fsm_workloads/indexed_insert_eval.js
  156. +4 −5 jstests/concurrency/fsm_workloads/indexed_insert_eval_nolock.js
  157. +44 −45 jstests/concurrency/fsm_workloads/indexed_insert_heterogeneous.js
  158. +22 −25 jstests/concurrency/fsm_workloads/indexed_insert_large.js
  159. +9 −11 jstests/concurrency/fsm_workloads/indexed_insert_long_fieldname.js
  160. +12 −14 jstests/concurrency/fsm_workloads/indexed_insert_multikey.js
  161. +19 −21 jstests/concurrency/fsm_workloads/indexed_insert_ordered_bulk.js
  162. +1 −4 jstests/concurrency/fsm_workloads/indexed_insert_text.js
  163. +19 −22 jstests/concurrency/fsm_workloads/indexed_insert_text_multikey.js
  164. +1 −4 jstests/concurrency/fsm_workloads/indexed_insert_ttl.js
  165. +19 −21 jstests/concurrency/fsm_workloads/indexed_insert_unordered_bulk.js
  166. +22 −24 jstests/concurrency/fsm_workloads/indexed_insert_upsert.js
  167. +2 −7 jstests/concurrency/fsm_workloads/indexed_insert_where.js
  168. +1 −4 jstests/concurrency/fsm_workloads/list_indexes.js
  169. +1 −5 jstests/concurrency/fsm_workloads/map_reduce_drop.js
  170. +4 −18 jstests/concurrency/fsm_workloads/map_reduce_inline.js
  171. +31 −36 jstests/concurrency/fsm_workloads/map_reduce_merge.js
  172. +40 −42 jstests/concurrency/fsm_workloads/map_reduce_merge_nonatomic.js
  173. +35 −40 jstests/concurrency/fsm_workloads/map_reduce_reduce.js
  174. +26 −31 jstests/concurrency/fsm_workloads/map_reduce_reduce_nonatomic.js
  175. +40 −42 jstests/concurrency/fsm_workloads/map_reduce_replace.js
  176. +31 −33 jstests/concurrency/fsm_workloads/map_reduce_replace_nonexistent.js
  177. +3 −12 jstests/concurrency/fsm_workloads/plan_cache_drop_database.js
  178. +2 −9 jstests/concurrency/fsm_workloads/reindex.js
  179. +14 −16 jstests/concurrency/fsm_workloads/reindex_background.js
  180. +1 −4 jstests/concurrency/fsm_workloads/remove_and_bulk_insert.js
  181. +2 −11 jstests/concurrency/fsm_workloads/remove_multiple_documents.js
  182. +1 −3 jstests/concurrency/fsm_workloads/remove_single_document.js
  183. +22 −24 jstests/concurrency/fsm_workloads/remove_single_document_eval.js
  184. +4 −5 jstests/concurrency/fsm_workloads/remove_single_document_eval_nolock.js
  185. +25 −30 jstests/concurrency/fsm_workloads/remove_where.js
  186. +3 −12 jstests/concurrency/fsm_workloads/rename_capped_collection_chain.js
  187. +3 −12 jstests/concurrency/fsm_workloads/rename_capped_collection_dbname_chain.js
  188. +3 −12 jstests/concurrency/fsm_workloads/rename_capped_collection_dbname_droptarget.js
  189. +3 −12 jstests/concurrency/fsm_workloads/rename_capped_collection_droptarget.js
  190. +2 −8 jstests/concurrency/fsm_workloads/rename_collection_chain.js
  191. +2 −8 jstests/concurrency/fsm_workloads/rename_collection_dbname_chain.js
  192. +2 −8 jstests/concurrency/fsm_workloads/rename_collection_dbname_droptarget.js
  193. +2 −8 jstests/concurrency/fsm_workloads/rename_collection_droptarget.js
  194. +3 −11 jstests/concurrency/fsm_workloads/server_status.js
  195. +39 −49 jstests/concurrency/fsm_workloads/touch_base.js
  196. +6 −12 jstests/concurrency/fsm_workloads/touch_data.js
  197. +6 −12 jstests/concurrency/fsm_workloads/touch_index.js
  198. +11 −17 jstests/concurrency/fsm_workloads/touch_no_data_no_index.js
  199. +1 −4 jstests/concurrency/fsm_workloads/update_and_bulk_insert.js
  200. +1 −4 jstests/concurrency/fsm_workloads/update_array.js
  201. +2 −6 jstests/concurrency/fsm_workloads/update_check_index.js
  202. +3 −11 jstests/concurrency/fsm_workloads/update_inc.js
  203. +4 −12 jstests/concurrency/fsm_workloads/update_multifield.js
  204. +23 −25 jstests/concurrency/fsm_workloads/update_multifield_isolated_multiupdate.js
  205. +35 −37 jstests/concurrency/fsm_workloads/update_multifield_multiupdate.js
  206. +2 −8 jstests/concurrency/fsm_workloads/update_ordered_bulk_inc.js
  207. +3 −9 jstests/concurrency/fsm_workloads/update_rename.js
  208. +1 −3 jstests/concurrency/fsm_workloads/update_replace.js
  209. +3 −10 jstests/concurrency/fsm_workloads/update_simple.js
  210. +16 −18 jstests/concurrency/fsm_workloads/update_simple_eval.js
  211. +4 −5 jstests/concurrency/fsm_workloads/update_simple_eval_nolock.js
  212. +4 −7 jstests/concurrency/fsm_workloads/update_upsert_multi.js
  213. +35 −40 jstests/concurrency/fsm_workloads/update_where.js
  214. +27 −32 jstests/concurrency/fsm_workloads/upsert_where.js
  215. +1 −3 jstests/concurrency/fsm_workloads/yield.js
  216. +51 −55 jstests/concurrency/fsm_workloads/yield_and_hashed.js
  217. +49 −53 jstests/concurrency/fsm_workloads/yield_and_sorted.js
  218. +14 −16 jstests/concurrency/fsm_workloads/yield_fetch.js
  219. +56 −67 jstests/concurrency/fsm_workloads/yield_geo_near.js
  220. +66 −80 jstests/concurrency/fsm_workloads/yield_geo_near_dedup.js
  221. +20 −21 jstests/concurrency/fsm_workloads/yield_id_hack.js
  222. +34 −38 jstests/concurrency/fsm_workloads/yield_rooted_or.js
  223. +25 −29 jstests/concurrency/fsm_workloads/yield_sort.js
  224. +35 −40 jstests/concurrency/fsm_workloads/yield_sort_merge.js
  225. +34 −39 jstests/concurrency/fsm_workloads/yield_text.js
  226. +4 −6 jstests/core/apitest_db.js
  227. +1 −3 jstests/core/apitest_dbcollection.js
  228. +7 −8 jstests/core/apply_ops1.js
  229. +1 −3 jstests/core/array4.js
  230. +1 −3 jstests/core/array_match4.js
  231. +3 −4 jstests/core/arrayfind7.js
  232. +3 −9 jstests/core/arrayfind8.js
  233. +2 −3 jstests/core/basic3.js
  234. +2 −3 jstests/core/basic9.js
  235. +1 −6 jstests/core/batch_size.js
  236. +1 −4 jstests/core/big_object1.js
  237. +7 −8 jstests/core/bittest.js
  238. +1 −3 jstests/core/capped6.js
  239. +190 −197 jstests/core/collation_shell_helpers.js
  240. +1 −3 jstests/core/commands_that_do_not_write_do_not_accept_wc.js
  241. +2 −8 jstests/core/connection_status.js
  242. +30 −11 jstests/core/constructors.js
  243. +4 −6 jstests/core/convert_to_capped_nonexistant.js
  244. +2 −6 jstests/core/count11.js
  245. +5 −3 jstests/core/create_indexes.js
  246. +1 −3 jstests/core/crud_api.js
  247. +10 −12 jstests/core/currentop_predicate.js
  248. +2 −10 jstests/core/cursor5.js
  249. +2 −7 jstests/core/cursor6.js
  250. +23 −37 jstests/core/cursor7.js
  251. +5 −5 jstests/core/cursora.js
  252. +2 −6 jstests/core/datasize2.js
  253. +1 −3 jstests/core/date2.js
  254. +1 −3 jstests/core/depth_limit.js
  255. +1 −4 jstests/core/distinct_index1.js
  256. +2 −2 jstests/core/doc_validation_invalid_validators.js
  257. +1 −1 jstests/core/dropdb_race.js
  258. +10 −13 jstests/core/elemMatchProjection.js
  259. +3 −7 jstests/core/eval0.js
  260. +9 −10 jstests/core/eval_mr.js
  261. +6 −7 jstests/core/evalg.js
  262. +7 −9 jstests/core/exists4.js
  263. +2 −6 jstests/core/existsa.js
  264. +1 −4 jstests/core/explain_distinct.js
  265. +2 −2 jstests/core/explain_find.js
  266. +22 −43 jstests/core/explain_find_and_modify.js
  267. +6 −7 jstests/core/explain_multi_plan.js
  268. +5 −3 jstests/core/find4.js
  269. +8 −4 jstests/core/find_and_modify.js
  270. +140 −146 jstests/core/find_and_modify_server6865.js
  271. +8 −9 jstests/core/find_dedup.js
  272. +1 −4 jstests/core/find_getmore_bsonsize.js
  273. +3 −2 jstests/core/fts_blog.js
  274. +9 −6 jstests/core/fts_blogwild.js
  275. +3 −4 jstests/core/fts_diacritic_and_casesensitive.js
  276. +2 −4 jstests/core/fts_diacriticsensitive.js
  277. +32 −20 jstests/core/fts_index.js
  278. +6 −4 jstests/core/fts_phrase.js
  279. +15 −8 jstests/core/fts_projection.js
  280. +10 −4 jstests/core/geo10.js
  281. +1 −3 jstests/core/geo3.js
  282. +1 −3 jstests/core/geo9.js
  283. +1 −4 jstests/core/geo_2d_with_geojson_point.js
  284. +6 −6 jstests/core/geo_array2.js
  285. +6 −26 jstests/core/geo_big_polygon.js
  286. +7 −24 jstests/core/geo_big_polygon2.js
  287. +10 −24 jstests/core/geo_big_polygon3.js
  288. +64 −70 jstests/core/geo_borders.js
  289. +8 −8 jstests/core/geo_box1.js
  290. +8 −8 jstests/core/geo_box1_noindex.js
  291. +2 −7 jstests/core/geo_center_sphere1.js
  292. +6 −6 jstests/core/geo_center_sphere2.js
  293. +8 −8 jstests/core/geo_circle1.js
  294. +8 −8 jstests/core/geo_circle1_noindex.js
  295. +1 −4 jstests/core/geo_distinct.js
  296. +2 −3 jstests/core/geo_fiddly_box.js
  297. +4 −8 jstests/core/geo_group.js
  298. +4 −5 jstests/core/geo_haystack1.js
  299. +4 −5 jstests/core/geo_haystack2.js
  300. +1 −4 jstests/core/geo_invalid_polygon.js
Sorry, we could not display the entire diff because too many files (1,523) changed.
View
25 jstests/aggregation/bugs/cond.js
@@ -68,16 +68,15 @@ t.save({noonSense: 'pm', mealCombined: 'yes'});
t.save({noonSense: 'pm', mealCombined: 'no'});
assert.eq(['breakfast', 'brunch', 'linner', 'dinner'],
t.aggregate({
- $project: {
- a: {
- $cond: [
- {$eq: ['$noonSense', 'am']},
- {$cond: [{$eq: ['$mealCombined', 'yes']}, 'brunch', 'breakfast']},
- {$cond: [{$eq: ['$mealCombined', 'yes']}, 'linner', 'dinner']}
- ]
- }
- }
- })
- .map(function(x) {
- return x.a;
- }));
+ $project: {
+ a: {
+ $cond: [
+ {$eq: ['$noonSense', 'am']},
+ {$cond: [{$eq: ['$mealCombined', 'yes']}, 'brunch', 'breakfast']},
+ {$cond: [{$eq: ['$mealCombined', 'yes']}, 'linner', 'dinner']}
+ ]
+ }
+ }
+ }).map(function(x) {
+ return x.a;
+ }));
View
16 jstests/aggregation/bugs/firstlast.js
@@ -104,17 +104,5 @@ assertFirstLast([1, 2], [6], [], '$b.c');
t.drop();
t.save({a: 1, b: 1});
t.save({a: 1, b: 2});
-assertFirstLast(1,
- 0,
- [],
- {
-$mod:
- ['$b', 2]
- });
-assertFirstLast(0,
- 1,
- [],
- {
-$mod:
- [{$add: ['$b', 1]}, 2]
- });
+assertFirstLast(1, 0, [], {$mod: ['$b', 2]});
+assertFirstLast(0, 1, [], {$mod: [{$add: ['$b', 1]}, 2]});
View
14 jstests/aggregation/bugs/match.js
@@ -13,9 +13,7 @@ identityProjection = {
/** Assert that an aggregation generated the expected error. */
function assertError(expectedCode, matchSpec) {
- matchStage = {
- $match: matchSpec
- };
+ matchStage = {$match: matchSpec};
// Check where matching is folded in to DocumentSourceCursor.
assertErrorCode(t, [matchStage], expectedCode);
// Check where matching is not folded in to DocumentSourceCursor.
@@ -41,9 +39,7 @@ function assertResults(expectedResults, matchSpec) {
if (expectedResults) {
assertEqualResultsUnordered(expectedResults, findResults);
}
- matchStage = {
- $match: matchSpec
- };
+ matchStage = {$match: matchSpec};
// Check where matching is folded in to DocumentSourceCursor.
assertEqualResultsUnordered(findResults, t.aggregate(matchStage).toArray());
// Check where matching is not folded in to DocumentSourceCursor.
@@ -176,11 +172,7 @@ function checkMatchResults(indexed) {
// $and
assertResults([{_id: 1, a: 2}], {$and: [{a: 2}, {_id: 1}]});
- assertResults([],
- {
- $and:
- [{a: 1}, {_id: 1}]
- });
+ assertResults([], {$and: [{a: 1}, {_id: 1}]});
assertResults([{_id: 1, a: 2}, {_id: 2, a: 3}],
{$and: [{$or: [{_id: 1}, {a: 3}]}, {$or: [{_id: 2}, {a: 2}]}]});
View
43 jstests/aggregation/bugs/server10176.js
@@ -33,28 +33,27 @@ load('jstests/aggregation/extras/utils.js');
// valid use of $abs: numbers become positive, null/undefined/nonexistent become null
var results = coll.aggregate([{$project: {a: {$abs: "$a"}}}]).toArray();
- assert.eq(results,
- [
- {_id: 0, a: 5},
- {_id: 1, a: 5},
- {_id: 2, a: 5.5},
- {_id: 3, a: 5.5},
- {_id: 4, a: 5},
- {_id: 5, a: 5},
- {_id: 6, a: NumberLong("5")},
- {_id: 7, a: NumberLong("5")},
- {_id: 8, a: 0},
- {_id: 9, a: 0},
- {_id: 10, a: 0},
- {_id: 11, a: NumberLong(Math.pow(2, 31))},
- {_id: 12, a: Math.pow(2, 31)},
- {_id: 13, a: NumberLong("1152921504606846977")},
- {_id: 14, a: NumberLong("1152921504606846977")},
- {_id: 15, a: null},
- {_id: 16, a: null},
- {_id: 17, a: NaN},
- {_id: 18, a: null},
- ]);
+ assert.eq(results, [
+ {_id: 0, a: 5},
+ {_id: 1, a: 5},
+ {_id: 2, a: 5.5},
+ {_id: 3, a: 5.5},
+ {_id: 4, a: 5},
+ {_id: 5, a: 5},
+ {_id: 6, a: NumberLong("5")},
+ {_id: 7, a: NumberLong("5")},
+ {_id: 8, a: 0},
+ {_id: 9, a: 0},
+ {_id: 10, a: 0},
+ {_id: 11, a: NumberLong(Math.pow(2, 31))},
+ {_id: 12, a: Math.pow(2, 31)},
+ {_id: 13, a: NumberLong("1152921504606846977")},
+ {_id: 14, a: NumberLong("1152921504606846977")},
+ {_id: 15, a: null},
+ {_id: 16, a: null},
+ {_id: 17, a: NaN},
+ {_id: 18, a: null},
+ ]);
// Invalid
// using $abs on string
View
58 jstests/aggregation/bugs/server11118.js
@@ -9,9 +9,13 @@ function testFormat(date, formatStr, expectedStr) {
db.dates.drop();
db.dates.insert({date: date});
- var res = db.dates.aggregate([{
- $project: {_id: 0, formatted: {$dateToString: {format: formatStr, date: "$date"}}}
- }]).toArray();
+ var res =
+ db.dates
+ .aggregate([{
+ $project:
+ {_id: 0, formatted: {$dateToString: {format: formatStr, date: "$date"}}}
+ }])
+ .toArray();
assert.eq(res[0].formatted, expectedStr);
}
@@ -36,18 +40,16 @@ function testDateValueError(dateVal, errCode) {
var now = ISODate();
// Use all modifiers we can test with js provided function
-testFormat(now,
- "%%-%Y-%m-%d-%H-%M-%S-%L",
- [
- "%",
- now.getUTCFullYear().zeroPad(4),
- (now.getUTCMonth() + 1).zeroPad(2),
- now.getUTCDate().zeroPad(2),
- now.getUTCHours().zeroPad(2),
- now.getUTCMinutes().zeroPad(2),
- now.getUTCSeconds().zeroPad(2),
- now.getUTCMilliseconds().zeroPad(3)
- ].join("-"));
+testFormat(now, "%%-%Y-%m-%d-%H-%M-%S-%L", [
+ "%",
+ now.getUTCFullYear().zeroPad(4),
+ (now.getUTCMonth() + 1).zeroPad(2),
+ now.getUTCDate().zeroPad(2),
+ now.getUTCHours().zeroPad(2),
+ now.getUTCMinutes().zeroPad(2),
+ now.getUTCSeconds().zeroPad(2),
+ now.getUTCMilliseconds().zeroPad(3)
+].join("-"));
// Padding tests
var padme = ISODate("2001-02-03T04:05:06.007Z");
@@ -62,20 +64,18 @@ testFormat(padme, "%S", padme.getUTCSeconds().zeroPad(2));
testFormat(padme, "%L", padme.getUTCMilliseconds().zeroPad(3));
// no space and multiple characters between modifiers
-testFormat(now,
- "%d%d***%d***%d**%d*%d",
- [
- now.getUTCDate().zeroPad(2),
- now.getUTCDate().zeroPad(2),
- "***",
- now.getUTCDate().zeroPad(2),
- "***",
- now.getUTCDate().zeroPad(2),
- "**",
- now.getUTCDate().zeroPad(2),
- "*",
- now.getUTCDate().zeroPad(2)
- ].join(""));
+testFormat(now, "%d%d***%d***%d**%d*%d", [
+ now.getUTCDate().zeroPad(2),
+ now.getUTCDate().zeroPad(2),
+ "***",
+ now.getUTCDate().zeroPad(2),
+ "***",
+ now.getUTCDate().zeroPad(2),
+ "**",
+ now.getUTCDate().zeroPad(2),
+ "*",
+ now.getUTCDate().zeroPad(2)
+].join(""));
// JS doesn't have equivalents of these format specifiers
testFormat(ISODate('1999-01-02 03:04:05.006Z'), "%U-%w-%j", "00-7-002");
View
78 jstests/aggregation/bugs/server11675.js
@@ -88,57 +88,57 @@ var server11675 = function() {
return obj;
});
var res = t.aggregate([
- {$match: {$text: {$search: 'apple banana'}}},
- {$sort: {textScore: {$meta: 'textScore'}}}
- ]).toArray();
+ {$match: {$text: {$search: 'apple banana'}}},
+ {$sort: {textScore: {$meta: 'textScore'}}}
+ ]).toArray();
assert.eq(res, findRes);
// Make sure {$meta: 'textScore'} can be used as a sub-expression
var res = t.aggregate([
- {$match: {_id: 1, $text: {$search: 'apple'}}},
- {
- $project: {
- words: 1,
- score: {$meta: 'textScore'},
- wordsTimesScore: {$multiply: ['$words', {$meta: 'textScore'}]}
- }
- }
- ]).toArray();
+ {$match: {_id: 1, $text: {$search: 'apple'}}},
+ {
+ $project: {
+ words: 1,
+ score: {$meta: 'textScore'},
+ wordsTimesScore: {$multiply: ['$words', {$meta: 'textScore'}]}
+ }
+ }
+ ]).toArray();
assert.eq(res[0].wordsTimesScore, res[0].words * res[0].score, tojson(res));
// And can be used in $group
var res = t.aggregate([
- {$match: {_id: 1, $text: {$search: 'apple banana'}}},
- {$group: {_id: {$meta: 'textScore'}, score: {$first: {$meta: 'textScore'}}}}
- ]).toArray();
+ {$match: {_id: 1, $text: {$search: 'apple banana'}}},
+ {$group: {_id: {$meta: 'textScore'}, score: {$first: {$meta: 'textScore'}}}}
+ ]).toArray();
assert.eq(res[0]._id, res[0].score, tojson(res));
// Make sure metadata crosses shard -> merger boundary
var res = t.aggregate([
- {$match: {_id: 1, $text: {$search: 'apple'}}},
- {$project: {scoreOnShard: {$meta: 'textScore'}}},
- {$limit: 1} // force a split. later stages run on merger
- ,
- {$project: {scoreOnShard: 1, scoreOnMerger: {$meta: 'textScore'}}}
- ]).toArray();
+ {$match: {_id: 1, $text: {$search: 'apple'}}},
+ {$project: {scoreOnShard: {$meta: 'textScore'}}},
+ {$limit: 1} // force a split. later stages run on merger
+ ,
+ {$project: {scoreOnShard: 1, scoreOnMerger: {$meta: 'textScore'}}}
+ ]).toArray();
assert.eq(res[0].scoreOnMerger, res[0].scoreOnShard);
var score = res[0].scoreOnMerger; // save for later tests
// Make sure metadata crosses shard -> merger boundary even if not used on shard
var res = t.aggregate([
- {$match: {_id: 1, $text: {$search: 'apple'}}},
- {$limit: 1} // force a split. later stages run on merger
- ,
- {$project: {scoreOnShard: 1, scoreOnMerger: {$meta: 'textScore'}}}
- ]).toArray();
+ {$match: {_id: 1, $text: {$search: 'apple'}}},
+ {$limit: 1} // force a split. later stages run on merger
+ ,
+ {$project: {scoreOnShard: 1, scoreOnMerger: {$meta: 'textScore'}}}
+ ]).toArray();
assert.eq(res[0].scoreOnMerger, score);
// Make sure metadata works if first $project doesn't use it.
var res = t.aggregate([
- {$match: {_id: 1, $text: {$search: 'apple'}}},
- {$project: {_id: 1}},
- {$project: {_id: 1, score: {$meta: 'textScore'}}}
- ]).toArray();
+ {$match: {_id: 1, $text: {$search: 'apple'}}},
+ {$project: {_id: 1}},
+ {$project: {_id: 1, score: {$meta: 'textScore'}}}
+ ]).toArray();
assert.eq(res[0].score, score);
// Make sure the metadata is 'missing()' when it doesn't exist because it was never created
@@ -147,20 +147,20 @@ var server11675 = function() {
// Make sure the metadata is 'missing()' when it doesn't exist because the document changed
var res = t.aggregate([
- {$match: {_id: 1, $text: {$search: 'apple banana'}}},
- {$group: {_id: 1, score: {$first: {$meta: 'textScore'}}}},
- {$project: {_id: 1, scoreAgain: {$meta: 'textScore'}}},
- ]).toArray();
+ {$match: {_id: 1, $text: {$search: 'apple banana'}}},
+ {$group: {_id: 1, score: {$first: {$meta: 'textScore'}}}},
+ {$project: {_id: 1, scoreAgain: {$meta: 'textScore'}}},
+ ]).toArray();
assert(!("scoreAgain" in res[0]));
// Make sure metadata works after a $unwind
t.insert({_id: 5, text: 'mango', words: [1, 2, 3]});
var res = t.aggregate([
- {$match: {$text: {$search: 'mango'}}},
- {$project: {score: {$meta: "textScore"}, _id: 1, words: 1}},
- {$unwind: '$words'},
- {$project: {scoreAgain: {$meta: "textScore"}, score: 1}}
- ]).toArray();
+ {$match: {$text: {$search: 'mango'}}},
+ {$project: {score: {$meta: "textScore"}, _id: 1, words: 1}},
+ {$unwind: '$words'},
+ {$project: {scoreAgain: {$meta: "textScore"}, score: 1}}
+ ]).toArray();
assert.eq(res[0].scoreAgain, res[0].score);
// Error checking
View
5 jstests/aggregation/bugs/server12015.js
@@ -12,10 +12,7 @@ load("jstests/aggregation/extras/utils.js"); // For orderedArrayEq.
"use strict";
var coll = db.server12015;
coll.drop();
- var indexSpec = {
- a: 1,
- b: 1
- };
+ var indexSpec = {a: 1, b: 1};
assert.writeOK(coll.insert({_id: 0, a: 0, b: 0}));
assert.writeOK(coll.insert({_id: 1, a: 0, b: 1}));
View
4 jstests/aggregation/bugs/server14670.js
@@ -12,12 +12,12 @@ load("jstests/aggregation/extras/utils.js"); // For assertErrorCode.
coll.insert({});
assertErrorCode(coll,
- [{$project: {strLen: {$strLenBytes: 1}}}],
+ [{$project: {strLen: {$strLenBytes: 1}}}],
34473,
"$strLenBytes requires a string argument.");
assertErrorCode(coll,
- [{$project: {strLen: {$strLenCP: 1}}}],
+ [{$project: {strLen: {$strLenCP: 1}}}],
34471,
"$strLenCP requires a string argument.");
}());
View
46 jstests/aggregation/bugs/server17943.js
@@ -18,11 +18,7 @@ load('jstests/aggregation/extras/utils.js');
assert.writeOK(coll.insert({_id: 6}));
// Create filter to only accept odd numbers.
- filterDoc = {
- input: '$a',
- as: 'x',
- cond: {$eq: [1, {$mod: ['$$x', 2]}]}
- };
+ filterDoc = {input: '$a', as: 'x', cond: {$eq: [1, {$mod: ['$$x', 2]}]}};
var expectedResults = [
{_id: 0, b: [1, 3, 5]},
{_id: 1, b: []},
@@ -45,57 +41,31 @@ load('jstests/aggregation/extras/utils.js');
assertErrorCode(coll, [{$project: {b: {$filter: filterDoc}}}], 28646);
// Extra field(s).
- filterDoc = {
- input: '$a',
- as: 'x',
- cond: true,
- extra: 1
- };
+ filterDoc = {input: '$a', as: 'x', cond: true, extra: 1};
assertErrorCode(coll, [{$project: {b: {$filter: filterDoc}}}], 28647);
// Missing 'input'.
- filterDoc = {
- as: 'x',
- cond: true
- };
+ filterDoc = {as: 'x', cond: true};
assertErrorCode(coll, [{$project: {b: {$filter: filterDoc}}}], 28648);
// Missing 'as'.
- filterDoc = {
- input: '$a',
- cond: true
- };
+ filterDoc = {input: '$a', cond: true};
assertErrorCode(coll, [{$project: {b: {$filter: filterDoc}}}], 28649);
// Missing 'cond'.
- filterDoc = {
- input: '$a',
- as: 'x'
- };
+ filterDoc = {input: '$a', as: 'x'};
assertErrorCode(coll, [{$project: {b: {$filter: filterDoc}}}], 28650);
// 'as' is not a valid variable name.
- filterDoc = {
- input: '$a',
- as: '$x',
- cond: true
- };
+ filterDoc = {input: '$a', as: '$x', cond: true};
assertErrorCode(coll, [{$project: {b: {$filter: filterDoc}}}], 16867);
// 'input' is not an array.
- filterDoc = {
- input: 'string',
- as: 'x',
- cond: true
- };
+ filterDoc = {input: 'string', as: 'x', cond: true};
assertErrorCode(coll, [{$project: {b: {$filter: filterDoc}}}], 28651);
coll.drop();
assert.writeOK(coll.insert({a: 'string'}));
- filterDoc = {
- input: '$a',
- as: 'x',
- cond: true
- };
+ filterDoc = {input: '$a', as: 'x', cond: true};
assertErrorCode(coll, [{$project: {b: {$filter: filterDoc}}}], 28651);
}());
View
8 jstests/aggregation/bugs/server18198.js
@@ -16,14 +16,10 @@
},
runCommand: function(db, cmd, opts) {
commandsRan.push({db: db, cmd: cmd, opts: opts});
- return {
- ok: 1.0
- };
+ return {ok: 1.0};
},
getReadPref: function() {
- return {
- mode: "secondaryPreferred"
- };
+ return {mode: "secondaryPreferred"};
},
getReadPrefMode: function() {
return "secondaryPreferred";
View
7 jstests/aggregation/bugs/server18222.js
@@ -20,8 +20,11 @@
assert.writeOK(coll.insert({_id: 10, x: ['0']}));
// Project field is_array to represent whether the field x was an array.
- var results =
- coll.aggregate([{$sort: {_id: 1}}, {$project: {isArray: {$isArray: '$x'}}}, ]).toArray();
+ var results = coll.aggregate([
+ {$sort: {_id: 1}},
+ {$project: {isArray: {$isArray: '$x'}}},
+ ])
+ .toArray();
var expectedResults = [
{_id: 0, isArray: false},
{_id: 1, isArray: false},
View
174 jstests/aggregation/bugs/server19095.js
@@ -55,37 +55,33 @@ load("jstests/aggregation/extras/utils.js");
{_id: 1, a: null, "same": [{_id: 1, b: null}, {_id: 2}]},
{_id: 2, "same": [{_id: 1, b: null}, {_id: 2}]}
];
- testPipeline([{
- $lookup: {localField: "nonexistent", foreignField: "b", from: "from", as: "same"}
- }],
- expectedResults,
- coll);
+ testPipeline(
+ [{$lookup: {localField: "nonexistent", foreignField: "b", from: "from", as: "same"}}],
+ expectedResults,
+ coll);
// If foreignField is nonexistent, it is treated as if it is null.
expectedResults = [
{_id: 0, a: 1, "same": []},
{_id: 1, a: null, "same": [{_id: 0, b: 1}, {_id: 1, b: null}, {_id: 2}]},
{_id: 2, "same": [{_id: 0, b: 1}, {_id: 1, b: null}, {_id: 2}]}
];
- testPipeline([{
- $lookup: {localField: "a", foreignField: "nonexistent", from: "from", as: "same"}
- }],
- expectedResults,
- coll);
+ testPipeline(
+ [{$lookup: {localField: "a", foreignField: "nonexistent", from: "from", as: "same"}}],
+ expectedResults,
+ coll);
// If there are no matches or the from coll doesn't exist, the result is an empty array.
expectedResults =
[{_id: 0, a: 1, "same": []}, {_id: 1, a: null, "same": []}, {_id: 2, "same": []}];
- testPipeline([{
- $lookup: {localField: "_id", foreignField: "nonexistent", from: "from", as: "same"}
- }],
- expectedResults,
- coll);
- testPipeline([{
- $lookup: {localField: "a", foreignField: "b", from: "nonexistent", as: "same"}
- }],
- expectedResults,
- coll);
+ testPipeline(
+ [{$lookup: {localField: "_id", foreignField: "nonexistent", from: "from", as: "same"}}],
+ expectedResults,
+ coll);
+ testPipeline(
+ [{$lookup: {localField: "a", foreignField: "b", from: "nonexistent", as: "same"}}],
+ expectedResults,
+ coll);
// If field name specified by "as" already exists, it is overwritten.
expectedResults = [
@@ -106,13 +102,14 @@ load("jstests/aggregation/extras/utils.js");
},
{_id: 2, "c": [{_id: 1, b: null}, {_id: 2}], "d": [{_id: 1, b: null}, {_id: 2}]}
];
- testPipeline([
- {$lookup: {localField: "a", foreignField: "b", from: "from", as: "c"}},
- {$project: {"a": 1, "c": 1}},
- {$lookup: {localField: "a", foreignField: "b", from: "from", as: "d"}}
- ],
- expectedResults,
- coll);
+ testPipeline(
+ [
+ {$lookup: {localField: "a", foreignField: "b", from: "from", as: "c"}},
+ {$project: {"a": 1, "c": 1}},
+ {$lookup: {localField: "a", foreignField: "b", from: "from", as: "d"}}
+ ],
+ expectedResults,
+ coll);
//
// Coalescing with $unwind.
@@ -126,12 +123,13 @@ load("jstests/aggregation/extras/utils.js");
{_id: 2, same: {_id: 1, b: null}},
{_id: 2, same: {_id: 2}}
];
- testPipeline([
- {$lookup: {localField: "a", foreignField: "b", from: "from", as: "same"}},
- {$unwind: {path: "$same"}}
- ],
- expectedResults,
- coll);
+ testPipeline(
+ [
+ {$lookup: {localField: "a", foreignField: "b", from: "from", as: "same"}},
+ {$unwind: {path: "$same"}}
+ ],
+ expectedResults,
+ coll);
// An $unwind on the "as" field, with includeArrayIndex.
expectedResults = [
@@ -141,39 +139,51 @@ load("jstests/aggregation/extras/utils.js");
{_id: 2, same: {_id: 1, b: null}, index: NumberLong(0)},
{_id: 2, same: {_id: 2}, index: NumberLong(1)},
];
- testPipeline([
- {$lookup: {localField: "a", foreignField: "b", from: "from", as: "same"}},
- {$unwind: {path: "$same", includeArrayIndex: "index"}}
- ],
- expectedResults,
- coll);
+ testPipeline(
+ [
+ {$lookup: {localField: "a", foreignField: "b", from: "from", as: "same"}},
+ {$unwind: {path: "$same", includeArrayIndex: "index"}}
+ ],
+ expectedResults,
+ coll);
// Normal $unwind with no matching documents.
expectedResults = [];
- testPipeline([
- {$lookup: {localField: "_id", foreignField: "nonexistent", from: "from", as: "same"}},
- {$unwind: {path: "$same"}}
- ],
- expectedResults,
- coll);
+ testPipeline(
+ [
+ {$lookup: {localField: "_id", foreignField: "nonexistent", from: "from", as: "same"}},
+ {$unwind: {path: "$same"}}
+ ],
+ expectedResults,
+ coll);
// $unwind with preserveNullAndEmptyArray with no matching documents.
- expectedResults = [{_id: 0, a: 1}, {_id: 1, a: null}, {_id: 2}, ];
- testPipeline([
- {$lookup: {localField: "_id", foreignField: "nonexistent", from: "from", as: "same"}},
- {$unwind: {path: "$same", preserveNullAndEmptyArrays: true}}
- ],
- expectedResults,
- coll);
+ expectedResults = [
+ {_id: 0, a: 1},
+ {_id: 1, a: null},
+ {_id: 2},
+ ];
+ testPipeline(
+ [
+ {$lookup: {localField: "_id", foreignField: "nonexistent", from: "from", as: "same"}},
+ {$unwind: {path: "$same", preserveNullAndEmptyArrays: true}}
+ ],
+ expectedResults,
+ coll);
// $unwind with preserveNullAndEmptyArray, some with matching documents, some without.
- expectedResults = [{_id: 0, a: 1}, {_id: 1, a: null, same: {_id: 0, b: 1}}, {_id: 2}, ];
- testPipeline([
- {$lookup: {localField: "_id", foreignField: "b", from: "from", as: "same"}},
- {$unwind: {path: "$same", preserveNullAndEmptyArrays: true}}
- ],
- expectedResults,
- coll);
+ expectedResults = [
+ {_id: 0, a: 1},
+ {_id: 1, a: null, same: {_id: 0, b: 1}},
+ {_id: 2},
+ ];
+ testPipeline(
+ [
+ {$lookup: {localField: "_id", foreignField: "b", from: "from", as: "same"}},
+ {$unwind: {path: "$same", preserveNullAndEmptyArrays: true}}
+ ],
+ expectedResults,
+ coll);
// $unwind with preserveNullAndEmptyArray and includeArrayIndex, some with matching
// documents, some without.
@@ -182,15 +192,16 @@ load("jstests/aggregation/extras/utils.js");
{_id: 1, a: null, same: {_id: 0, b: 1}, index: NumberLong(0)},
{_id: 2, index: null},
];
- testPipeline([
- {$lookup: {localField: "_id", foreignField: "b", from: "from", as: "same"}},
- {
- $unwind:
- {path: "$same", preserveNullAndEmptyArrays: true, includeArrayIndex: "index"}
- }
- ],
- expectedResults,
- coll);
+ testPipeline(
+ [
+ {$lookup: {localField: "_id", foreignField: "b", from: "from", as: "same"}},
+ {
+ $unwind:
+ {path: "$same", preserveNullAndEmptyArrays: true, includeArrayIndex: "index"}
+ }
+ ],
+ expectedResults,
+ coll);
//
// Dependencies.
@@ -203,12 +214,13 @@ load("jstests/aggregation/extras/utils.js");
{_id: 1, "same": [{_id: 1, b: null}, {_id: 2}]},
{_id: 2, "same": [{_id: 1, b: null}, {_id: 2}]}
];
- testPipeline([
- {$lookup: {localField: "a", foreignField: "b", from: "from", as: "same"}},
- {$project: {"same": 1}}
- ],
- expectedResults,
- coll);
+ testPipeline(
+ [
+ {$lookup: {localField: "a", foreignField: "b", from: "from", as: "same"}},
+ {$project: {"same": 1}}
+ ],
+ expectedResults,
+ coll);
//
// Dotted field paths.
@@ -277,12 +289,7 @@ load("jstests/aggregation/extras/utils.js");
}
];
expectedResults = [
- {
- _id: 0,
- a: {b: 1},
- same: {documents: {_id: 0, target: 1}},
- c: {d: {e: NumberLong(0)}}
- },
+ {_id: 0, a: {b: 1}, same: {documents: {_id: 0, target: 1}}, c: {d: {e: NumberLong(0)}}},
{_id: 1, same: {}, c: {d: {e: null}}},
];
testPipeline(pipeline, expectedResults, coll);
@@ -401,9 +408,8 @@ load("jstests/aggregation/extras/utils.js");
// An error is thrown if the from collection is sharded.
assert(sharded.adminCommand({shardCollection: "test.from", key: {_id: 1}}));
- assertErrorCode(
- sharded.getDB('test').lookUp,
- [{$lookup: {localField: "a", foreignField: "b", from: "from", as: "same"}}],
- 28769);
+ assertErrorCode(sharded.getDB('test').lookUp,
+ [{$lookup: {localField: "a", foreignField: "b", from: "from", as: "same"}}],
+ 28769);
sharded.stop();
}());
View
109 jstests/aggregation/bugs/server20163.js
@@ -12,182 +12,127 @@ load("jstests/aggregation/extras/utils.js"); // For assertErrorCode.
var zipObj = 3;
assertErrorCode(coll,
- [{$project: {zipped: {$zip: zipObj}}}],
+ [{$project: {zipped: {$zip: zipObj}}}],
34460,
"$zip requires an object" + " as an argument.");
- zipObj = {
- inputs: []
- };
+ zipObj = {inputs: []};
assertErrorCode(coll,
- [{$project: {zipped: {$zip: zipObj}}}],
+ [{$project: {zipped: {$zip: zipObj}}}],
34465,
"$zip requires at least" + " one input array");
- zipObj = {
- inputs: {"a": "b"}
- };
+ zipObj = {inputs: {"a": "b"}};
assertErrorCode(coll, [{$project: {zipped: {$zip: zipObj}}}], 34461, "inputs is not an array");
- zipObj = {
- inputs: ["$a"],
- defaults: ["A"]
- };
+ zipObj = {inputs: ["$a"], defaults: ["A"]};
assertErrorCode(coll,
- [{$project: {zipped: {$zip: zipObj}}}],
+ [{$project: {zipped: {$zip: zipObj}}}],
34466,
"cannot specify defaults" + " unless useLongestLength is true.");
- zipObj = {
- inputs: ["$a"],
- defaults: ["A", "B"],
- useLongestLength: true
- };
+ zipObj = {inputs: ["$a"], defaults: ["A", "B"], useLongestLength: true};
assertErrorCode(coll,
- [{$project: {zipped: {$zip: zipObj}}}],
+ [{$project: {zipped: {$zip: zipObj}}}],
34467,
"inputs and defaults" + " must be the same length.");
- zipObj = {
- inputs: ["$a"],
- defaults: {"a": "b"}
- };
+ zipObj = {inputs: ["$a"], defaults: {"a": "b"}};
assertErrorCode(
coll, [{$project: {zipped: {$zip: zipObj}}}], 34462, "defaults is not an" + " array");
- zipObj = {
- inputs: ["$a"],
- defaults: ["A"],
- useLongestLength: 1
- };
+ zipObj = {inputs: ["$a"], defaults: ["A"], useLongestLength: 1};
assertErrorCode(
coll, [{$project: {zipped: {$zip: zipObj}}}], 34463, "useLongestLength is not" + " a bool");
- zipObj = {
- inputs: ["$a", "$b"],
- defaults: ["A"],
- notAField: 1
- };
+ zipObj = {inputs: ["$a", "$b"], defaults: ["A"], notAField: 1};
assertErrorCode(coll, [{$project: {zipped: {$zip: zipObj}}}], 34464, "unknown argument");
- zipObj = {
- inputs: ["A", "B"]
- };
+ zipObj = {inputs: ["A", "B"]};
assertErrorCode(coll,
- [{$project: {zipped: {$zip: zipObj}}}],
+ [{$project: {zipped: {$zip: zipObj}}}],
34468,
"an element of inputs" + " was not an array.");
- zipObj = {
- inputs: [[1, 2, 3], ["A", "B", "C"]]
- };
+ zipObj = {inputs: [[1, 2, 3], ["A", "B", "C"]]};
var res = coll.aggregate([{$project: {zipped: {$zip: zipObj}}}]);
var output = res.toArray();
assert.eq(1, output.length);
assert.eq(output[0].zipped, [[1, "A"], [2, "B"], [3, "C"]]);
- zipObj = {
- inputs: [[1, 2, 3], null]
- };
+ zipObj = {inputs: [[1, 2, 3], null]};
res = coll.aggregate([{$project: {zipped: {$zip: zipObj}}}]);
output = res.toArray();
assert.eq(1, output.length);
assert.eq(output[0].zipped, null);
- zipObj = {
- inputs: [null, [1, 2, 3]]
- };
+ zipObj = {inputs: [null, [1, 2, 3]]};
res = coll.aggregate([{$project: {zipped: {$zip: zipObj}}}]);
output = res.toArray();
assert.eq(1, output.length);
assert.eq(output[0].zipped, null);
- zipObj = {
- inputs: ["$missing", [1, 2, 3]]
- };
+ zipObj = {inputs: ["$missing", [1, 2, 3]]};
res = coll.aggregate([{$project: {zipped: {$zip: zipObj}}}]);
output = res.toArray();
assert.eq(1, output.length);
assert.eq(output[0].zipped, null);
- zipObj = {
- inputs: [undefined, [1, 2, 3]]
- };
+ zipObj = {inputs: [undefined, [1, 2, 3]]};
res = coll.aggregate([{$project: {zipped: {$zip: zipObj}}}]);
output = res.toArray();
assert.eq(1, output.length);
assert.eq(output[0].zipped, null);
- zipObj = {
- inputs: [[1, 2, 3], ["A", "B"]]
- };
+ zipObj = {inputs: [[1, 2, 3], ["A", "B"]]};
res = coll.aggregate([{$project: {zipped: {$zip: zipObj}}}]);
output = res.toArray();
assert.eq(1, output.length);
assert.eq(output[0].zipped, [[1, "A"], [2, "B"]]);
- zipObj = {
- inputs: [["A", "B"], [1, 2, 3]]
- };
+ zipObj = {inputs: [["A", "B"], [1, 2, 3]]};
res = coll.aggregate([{$project: {zipped: {$zip: zipObj}}}]);
output = res.toArray();
assert.eq(1, output.length);
assert.eq(output[0].zipped, [["A", 1], ["B", 2]]);
- zipObj = {
- inputs: [[], []]
- };
+ zipObj = {inputs: [[], []]};
res = coll.aggregate([{$project: {zipped: {$zip: zipObj}}}]);
output = res.toArray();
assert.eq(1, output.length);
assert.eq(output[0].zipped, []);
- zipObj = {
- inputs: [["$short"], ["$long"]]
- };
+ zipObj = {inputs: [["$short"], ["$long"]]};
res = coll.aggregate([{$project: {zipped: {$zip: zipObj}}}]);
output = res.toArray();
assert.eq(1, output.length);
assert.eq(output[0].zipped, [[['x', 'y'], [1, 2, 3]]]);
- zipObj = {
- inputs: ["$short", "$long"]
- };
+ zipObj = {inputs: ["$short", "$long"]};
res = coll.aggregate([{$project: {zipped: {$zip: zipObj}}}]);
output = res.toArray();
assert.eq(1, output.length);
assert.eq(output[0].zipped, [['x', 1], ['y', 2]]);
- zipObj = {
- inputs: [["$long"]]
- };
+ zipObj = {inputs: [["$long"]]};
res = coll.aggregate([{$project: {zipped: {$zip: zipObj}}}]);
output = res.toArray();
assert.eq(1, output.length);
assert.eq(output[0].zipped, [[[1, 2, 3]]]);
- zipObj = {
- inputs: [[1, 2, 3], ['a', 'b', 'c'], ['c', 'b', 'a']]
- };
+ zipObj = {inputs: [[1, 2, 3], ['a', 'b', 'c'], ['c', 'b', 'a']]};
res = coll.aggregate([{$project: {zipped: {$zip: zipObj}}}]);
output = res.toArray();
assert.eq(1, output.length);
assert.eq(output[0].zipped, [[1, 'a', 'c'], [2, 'b', 'b'], [3, 'c', 'a']]);
- zipObj = {
- inputs: [[1, 2, 3], ["A", "B"]],
- defaults: ["C", "D"],
- useLongestLength: true
- };
+ zipObj = {inputs: [[1, 2, 3], ["A", "B"]], defaults: ["C", "D"], useLongestLength: true};
res = coll.aggregate([{$project: {zipped: {$zip: zipObj}}}]);
output = res.toArray();
assert.eq(1, output.length);
assert.eq(output[0].zipped, [[1, "A"], [2, "B"], [3, "D"]]);
- zipObj = {
- inputs: [[1, 2, 3], ["A", "B"]],
- useLongestLength: true
- };
+ zipObj = {inputs: [[1, 2, 3], ["A", "B"]], useLongestLength: true};
res = coll.aggregate([{$project: {zipped: {$zip: zipObj}}}]);
output = res.toArray();
assert.eq(1, output.length);
View
16 jstests/aggregation/bugs/server20169.js
@@ -13,49 +13,49 @@ load("jstests/aggregation/extras/utils.js"); // For assertErrorCode.
var rangeObj = [1];
assertErrorCode(coll,
- [{$project: {range: {$range: rangeObj}}}],
+ [{$project: {range: {$range: rangeObj}}}],
28667,
"range requires two" + " or three arguments");
rangeObj = ["a", 1];
assertErrorCode(coll,
- [{$project: {range: {$range: rangeObj}}}],
+ [{$project: {range: {$range: rangeObj}}}],
34443,
"range requires a" + " numeric starting value");
rangeObj = [1.1, 1];
assertErrorCode(coll,
- [{$project: {range: {$range: rangeObj}}}],
+ [{$project: {range: {$range: rangeObj}}}],
34444,
"range requires an" + " integral starting value");
rangeObj = [1, "a"];
assertErrorCode(coll,
- [{$project: {range: {$range: rangeObj}}}],
+ [{$project: {range: {$range: rangeObj}}}],
34445,
"range requires a" + " numeric ending value");
rangeObj = [1, 1.1];
assertErrorCode(coll,
- [{$project: {range: {$range: rangeObj}}}],
+ [{$project: {range: {$range: rangeObj}}}],
34446,
"range requires an" + " integral ending value");
rangeObj = [1, 3, "a"];
assertErrorCode(coll,
- [{$project: {range: {$range: rangeObj}}}],
+ [{$project: {range: {$range: rangeObj}}}],
34447,
"range requires a" + " numeric step value");
rangeObj = [1, 3, 1.1];
assertErrorCode(coll,
- [{$project: {range: {$range: rangeObj}}}],
+ [{$project: {range: {$range: rangeObj}}}],
34448,
"range requires an" + " integral step value");
rangeObj = [1, 3, 0];
assertErrorCode(coll,
- [{$project: {range: {$range: rangeObj}}}],
+ [{$project: {range: {$range: rangeObj}}}],
34449,
"range requires a" + " non-zero step value");
}());
View
5 jstests/aggregation/bugs/server21632.js
@@ -35,10 +35,7 @@
// If there is only one document, we should get that document.
var paddingStr = "abcdefghijklmnopqrstuvwxyz";
- var firstDoc = {
- _id: 0,
- paddingStr: paddingStr
- };
+ var firstDoc = {_id: 0, paddingStr: paddingStr};
assert.writeOK(coll.insert(firstDoc));
assert.eq([firstDoc], coll.aggregate([{$sample: {size: 1}}]).toArray());
assert.eq([firstDoc], coll.aggregate([{$sample: {size: 10}}]).toArray());
View
5 jstests/aggregation/bugs/server22093.js
@@ -22,9 +22,8 @@ load('jstests/libs/analyze_plan.js');
assert.eq(simpleGroup.length, 1);
assert.eq(simpleGroup[0]["count"], 15);
- var explained =
- coll.explain()
- .aggregate([{$match: {foo: {$gt: 0}}}, {$group: {_id: null, count: {$sum: 1}}}]);
+ var explained = coll.explain().aggregate(
+ [{$match: {foo: {$gt: 0}}}, {$group: {_id: null, count: {$sum: 1}}}]);
assert(planHasStage(explained.stages[0].$cursor.queryPlanner.winningPlan, "COUNT_SCAN"));
View
12 jstests/aggregation/bugs/server22580.js
@@ -12,32 +12,32 @@ load("jstests/aggregation/extras/utils.js"); // For assertErrorCode.
coll.insert({});
assertErrorCode(coll,
- [{$project: {substr: {$substrCP: ["abc", 0, "a"]}}}],
+ [{$project: {substr: {$substrCP: ["abc", 0, "a"]}}}],
34452,
"$substrCP" + " does not accept non-numeric types as a length.");
assertErrorCode(coll,
- [{$project: {substr: {$substrCP: ["abc", 0, NaN]}}}],
+ [{$project: {substr: {$substrCP: ["abc", 0, NaN]}}}],
34453,
"$substrCP" + " does not accept non-integers as a length.");
assertErrorCode(coll,
- [{$project: {substr: {$substrCP: ["abc", "abc", 3]}}}],
+ [{$project: {substr: {$substrCP: ["abc", "abc", 3]}}}],
34450,
"$substrCP does not accept non-numeric types as a starting index.");
assertErrorCode(coll,
- [{$project: {substr: {$substrCP: ["abc", 2.2, 3]}}}],
+ [{$project: {substr: {$substrCP: ["abc", 2.2, 3]}}}],
34451,
"$substrCP" + " does not accept non-integers as a starting index.");
assertErrorCode(coll,
- [{$project: {substr: {$substrCP: ["abc", -1, 3]}}}],
+ [{$project: {substr: {$substrCP: ["abc", -1, 3]}}}],
34455,
"$substrCP " + "does not accept negative integers as inputs.");
assertErrorCode(coll,
- [{$project: {substr: {$substrCP: ["abc", 1, -3]}}}],
+ [{$project: {substr: {$substrCP: ["abc", 1, -3]}}}],
34454,
"$substrCP " + "does not accept negative integers as inputs.");
}());
View
16 jstests/aggregation/bugs/server3253.js
@@ -58,15 +58,15 @@ assert.eq([], listCollections(/tmp\.agg_out/));
// basic test
test(input,
- [{$project: {a: {$add: ['$_id', '$_id']}}}],
+ [{$project: {a: {$add: ['$_id', '$_id']}}}],
[{_id: 1, a: 2}, {_id: 2, a: 4}, {_id: 3, a: 6}]);
// test with indexes
assert.eq(output.getIndexes().length, 1);
output.ensureIndex({a: 1});
assert.eq(output.getIndexes().length, 2);
test(input,
- [{$project: {a: {$multiply: ['$_id', '$_id']}}}],
+ [{$project: {a: {$multiply: ['$_id', '$_id']}}}],
[{_id: 1, a: 1}, {_id: 2, a: 4}, {_id: 3, a: 9}]);
// test with empty result set and make sure old result is gone, but indexes remain
@@ -81,13 +81,11 @@ test(input, [{$project: {b: "$_id"}}], [{_id: 1, b: 1}, {_id: 2, b: 2}, {_id: 3,
// test with full text index
output.ensureIndex({c: "text"});
assert.eq(output.getIndexes().length, 4);
-test(input,
- [{$project: {c: {$concat: ["hello there ", "_id"]}}}],
- [
- {_id: 1, c: "hello there _id"},
- {_id: 2, c: "hello there _id"},
- {_id: 3, c: "hello there _id"}
- ]);
+test(input, [{$project: {c: {$concat: ["hello there ", "_id"]}}}], [
+ {_id: 1, c: "hello there _id"},
+ {_id: 2, c: "hello there _id"},
+ {_id: 3, c: "hello there _id"}
+]);
// test with capped collection
cappedOutput.drop();
View
16 jstests/aggregation/bugs/server4588.js
@@ -13,7 +13,12 @@
// Without includeArrayIndex.
var actualResults = coll.aggregate([{$unwind: {path: "$x"}}]).toArray();
- var expectedResults = [{_id: 3, x: 1}, {_id: 3, x: 2}, {_id: 3, x: 3}, {_id: 4, x: 5}, ];
+ var expectedResults = [
+ {_id: 3, x: 1},
+ {_id: 3, x: 2},
+ {_id: 3, x: 3},
+ {_id: 4, x: 5},
+ ];
assert.eq(expectedResults, actualResults, "Incorrect results for normal $unwind");
// With includeArrayIndex, index inserted into a new field.
@@ -28,9 +33,12 @@
// With both includeArrayIndex and preserveNullAndEmptyArrays.
// TODO: update this test when SERVER-20168 is resolved.
- actualResults = coll.aggregate([{
- $unwind: {path: "$x", includeArrayIndex: "index", preserveNullAndEmptyArrays: true}
- }]).toArray();
+ actualResults =
+ coll.aggregate([{
+ $unwind:
+ {path: "$x", includeArrayIndex: "index", preserveNullAndEmptyArrays: true}
+ }])
+ .toArray();
expectedResults = [
{_id: 0, index: null},
{_id: 1, x: null, index: null},
View
12 jstests/aggregation/bugs/server5044.js
@@ -10,12 +10,12 @@ function test(data, popExpected, sampExpected) {
assert.writeOK(t.insert({num: data[i]}));
var res = t.aggregate({
- $group: {
- _id: 1,
- pop: {$stdDevPop: '$num'},
- samp: {$stdDevSamp: '$num'},
- }
- }).next();
+ $group: {
+ _id: 1,
+ pop: {$stdDevPop: '$num'},
+ samp: {$stdDevSamp: '$num'},
+ }
+ }).next();
if (popExpected === null) {
assert.isnull(res.pop);
View
30 jstests/aggregation/bugs/server6121.js
@@ -22,20 +22,22 @@ db.s6121.drop();
db.s6121.save({date: new Timestamp(1341337661, 1)});
db.s6121.save({date: new Date(1341337661000)});
// Aggregate checking various combinations of the constant and the field
-var s6121 = db.s6121.aggregate({
- $project: {
- _id: 0,
- dayOfMonth: {$dayOfMonth: '$date'},
- dayOfWeek: {$dayOfWeek: '$date'},
- dayOfYear: {$dayOfYear: '$date'},
- hour: {$hour: '$date'},
- minute: {$minute: '$date'},
- month: {$month: '$date'},
- second: {$second: '$date'},
- week: {$week: '$date'},
- year: {$year: '$date'}
- }
-}).toArray();
+var s6121 = db.s6121
+ .aggregate({
+ $project: {
+ _id: 0,
+ dayOfMonth: {$dayOfMonth: '$date'},
+ dayOfWeek: {$dayOfWeek: '$date'},
+ dayOfYear: {$dayOfYear: '$date'},
+ hour: {$hour: '$date'},
+ minute: {$minute: '$date'},
+ month: {$month: '$date'},
+ second: {$second: '$date'},
+ week: {$week: '$date'},
+ year: {$year: '$date'}
+ }
+ })
+ .toArray();
// Assert the two entries are equal
assert.eq(s6121[0], s6121[1], 's6121 failed');
View
4 jstests/aggregation/bugs/server6125.js
@@ -10,9 +10,7 @@
// to make results array nested (problem 2)
function nestArray(nstArray) {
for (x = 0; x < nstArray.length; x++) {
- nstArray[x].a = {
- b: nstArray[x].a
- };
+ nstArray[x].a = {b: nstArray[x].a};
}
}
View
36 jstests/aggregation/bugs/server6131.js
@@ -11,11 +11,7 @@ t.drop();
// An empty array document is dropped.
t.save({_id: 0, a: 1, b: [], c: 2});
-assertAggregationResults([],
- {
-$unwind:
- '$b'
- });
+assertAggregationResults([], {$unwind: '$b'});
// Values from a nonempty array in another document are unwound.
t.save({_id: 1, b: [4, 5]});
@@ -29,48 +25,28 @@ t.drop();
// A nested empty array document is dropped.
t.save({_id: 0, a: 1, b: {x: 10, y: [], z: 20}, c: 2});
-assertAggregationResults([],
- {
-$unwind:
- '$b.y'
- });
+assertAggregationResults([], {$unwind: '$b.y'});
t.drop();
// A null value document is dropped.
t.save({_id: 0, a: 1, b: null, c: 2});
-assertAggregationResults([],
- {
-$unwind:
- '$b'
- });
+assertAggregationResults([], {$unwind: '$b'});
t.drop();
// A missing value causes the document to be dropped.
t.save({_id: 0, a: 1, c: 2});
-assertAggregationResults([],
- {
-$unwind:
- '$b'
- });
+assertAggregationResults([], {$unwind: '$b'});
t.drop();
// A missing value in an existing nested object causes the document to be dropped.
t.save({_id: 0, a: 1, b: {d: 4}, c: 2});
-assertAggregationResults([],
- {
-$unwind:
- '$b.y'
- });
+assertAggregationResults([], {$unwind: '$b.y'});
t.drop();
// A missing value in a missing nested object causes the document to be dropped.
t.save({_id: 0, a: 1, b: 10, c: 2});
-assertAggregationResults([],
- {
-$unwind:
- '$b.y'
- });
+assertAggregationResults([], {$unwind: '$b.y'});
View
8 jstests/aggregation/bugs/server6179.js
@@ -28,9 +28,11 @@
{movechunk: "test.data", find: {_id: 50}, to: s.getOther(s.getPrimaryShard("test")).name});
// Check that we get results rather than an error
- var result = d.data.aggregate({$group: {_id: '$_id', i: {$first: '$i'}}},
- {$group: {_id: '$i', avg_id: {$avg: '$_id'}}},
- {$sort: {_id: 1}}).toArray();
+ var result = d.data
+ .aggregate({$group: {_id: '$_id', i: {$first: '$i'}}},
+ {$group: {_id: '$i', avg_id: {$avg: '$_id'}}},
+ {$sort: {_id: 1}})
+ .toArray();
expected = [
{"_id": 0, "avg_id": 45},
{"_id": 1, "avg_id": 46},
View
86 jstests/aggregation/bugs/server6189.js
@@ -11,36 +11,35 @@ function test(date, testSynthetics) {
: 'ISODate("%Y-%m-%dT%H:%M:%S.%LZ")';
// Can't use aggregate helper or assertErrorCode because we need to handle multiple error types
- var res = c.runCommand('aggregate',
- {
- pipeline: [{
- $project: {
- _id: 0,
- year: {$year: '$date'},
- month: {$month: '$date'},
- dayOfMonth: {$dayOfMonth: '$date'},
- hour: {$hour: '$date'},
- minute: {$minute: '$date'},
- second: {$second: '$date'}
-
- // server-6666
- ,
- millisecond: {$millisecond: '$date'}
-
- // server-9289
- ,
- millisecondPlusTen: {$millisecond: {$add: ['$date', 10]}}
-
- // $substr will call coerceToString
- ,
- string: {$substr: ['$date', 0, 1000]}
-
- // server-11118
- ,
- format: {$dateToString: {format: ISOfmt, date: '$date'}}
- }
- }]