nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: delvedor/find-my-way
Pull request #68 (2018-03-03 10:07:20)

Fix unsupported methods
Fixed bug found in https://github.com/fastify/fastify/pull/823 and https://github.com/fastify/fastify/issues/824.


Patch:
diff --git a/index.js b/index.js
index c346976..5aa2ab5 100644
--- a/index.js
+++ b/index.js
@@ -261,7 +261,7 @@ Router.prototype.off = function off (method, path) {
 
 Router.prototype.lookup = function lookup (req, res) {
   var handle = this.find(req.method, sanitizeUrl(req.url))
-  if (handle === null) return this._defaultRoute(req, res)
+  if (handle == null) return this._defaultRoute(req, res)
   return handle.handler(req, res, handle.params, handle.store)
 }
 
@@ -287,7 +287,7 @@ Router.prototype.find = function find (method, path) {
     // found the route
     if (pathLen === 0 || path === prefix) {
       var handle = currentNode.handlers[method]
-      if (handle !== null) {
+      if (handle != null) {
         var paramsObj = {}
         if (handle.paramsLength > 0) {
           var paramNames = handle.params
@@ -498,7 +498,7 @@ function getWildcardNode (node, method, path, len) {
     return null
   }
   var handle = node.handlers[method]
-  if (handle !== null) {
+  if (handle != null) {
     return {
       handler: handle.handler,
       params: { '*': decoded },


Test patch:
diff --git a/test/methods.test.js b/test/methods.test.js
index 404790c..512f333 100644
--- a/test/methods.test.js
+++ b/test/methods.test.js
@@ -663,3 +663,51 @@ test('params does not keep the object reference', t => {
   findMyWay.lookup({ method: 'GET', url: '/test/hello' }, null)
   findMyWay.lookup({ method: 'GET', url: '/test/world' }, null)
 })
+
+test('Unsupported method (static)', t => {
+  t.plan(1)
+  const findMyWay = FindMyWay({
+    defaultRoute: (req, res) => {
+      t.pass('Everything ok')
+    }
+  })
+
+  findMyWay.on('GET', '/', (req, res, params) => {
+    t.fail('We should not be here')
+  })
+
+  findMyWay.lookup({ method: 'PROPFIND', url: '/' }, null)
+})
+
+test('Unsupported method (wildcard)', t => {
+  t.plan(1)
+  const findMyWay = FindMyWay({
+    defaultRoute: (req, res) => {
+      t.pass('Everything ok')
+    }
+  })
+
+  findMyWay.on('GET', '*', (req, res, params) => {
+    t.fail('We should not be here')
+  })
+
+  findMyWay.lookup({ method: 'PROPFIND', url: '/hello/world' }, null)
+})
+
+test('Unsupported method (static find)', t => {
+  t.plan(1)
+  const findMyWay = FindMyWay()
+
+  findMyWay.on('GET', '/', () => {})
+
+  t.deepEqual(findMyWay.find('PROPFIND', '/'), null)
+})
+
+test('Unsupported method (wildcard find)', t => {
+  t.plan(1)
+  const findMyWay = FindMyWay()
+
+  findMyWay.on('GET', '*', () => {})
+
+  t.deepEqual(findMyWay.find('PROPFIND', '/hello/world'), null)
+})
Repository: delvedor/find-my-way
Pull request #74 (2018-03-21 05:05:53)

Fix lookups of unsupported methods
Currently, looking up an unsupported is throwing an error because the method isn't in the `handlers` object, so trying to get a handler from the `handlers` object will return `undefined` (and currently only `null` is being handled).


Patch:
diff --git a/index.js b/index.js
index 214dc50..988380d 100644
--- a/index.js
+++ b/index.js
@@ -290,7 +290,7 @@ Router.prototype.find = function find (method, path) {
     // found the route
     if (pathLen === 0 || path === prefix) {
       var handle = currentNode.handlers[method]
-      if (handle !== null) {
+      if (handle !== null && handle !== undefined) {
         var paramsObj = {}
         if (handle.paramsLength > 0) {
           var paramNames = handle.params
@@ -455,7 +455,7 @@ function getWildcardNode (node, method, path, len) {
   var decoded = fastDecode(path.slice(-len))
   if (decoded === null) return null
   var handle = node.handlers[method]
-  if (handle !== null) {
+  if (handle !== null && handle !== undefined) {
     return {
       handler: handle.handler,
       params: { '*': decoded },


Test patch:
diff --git a/test/methods.test.js b/test/methods.test.js
index 6fe3ee8..6b444ce 100644
--- a/test/methods.test.js
+++ b/test/methods.test.js
@@ -676,7 +676,7 @@ test('Unsupported method (static)', t => {
     t.fail('We should not be here')
   })
 
-  findMyWay.lookup({ method: 'PROPFIND', url: '/' }, null)
+  findMyWay.lookup({ method: 'TROLL', url: '/' }, null)
 })
 
 test('Unsupported method (wildcard)', t => {
@@ -691,7 +691,7 @@ test('Unsupported method (wildcard)', t => {
     t.fail('We should not be here')
   })
 
-  findMyWay.lookup({ method: 'PROPFIND', url: '/hello/world' }, null)
+  findMyWay.lookup({ method: 'TROLL', url: '/hello/world' }, null)
 })
 
 test('Unsupported method (static find)', t => {
@@ -700,7 +700,7 @@ test('Unsupported method (static find)', t => {
 
   findMyWay.on('GET', '/', () => {})
 
-  t.deepEqual(findMyWay.find('PROPFIND', '/'), null)
+  t.deepEqual(findMyWay.find('TROLL', '/'), null)
 })
 
 test('Unsupported method (wildcard find)', t => {
@@ -709,7 +709,7 @@ test('Unsupported method (wildcard find)', t => {
 
   findMyWay.on('GET', '*', () => {})
 
-  t.deepEqual(findMyWay.find('PROPFIND', '/hello/world'), null)
+  t.deepEqual(findMyWay.find('TROLL', '/hello/world'), null)
 })
 
 test('register all known HTTP methods', t => {
Repository: delvedor/find-my-way
Pull request #91 (2018-09-07 16:48:40)

Prevent TypeError: m.toLowerCase is not a function
Never forget this, if you use for..in

coveralls: 
[![Coverage Status](https://coveralls.io/builds/18885107/badge)](https://coveralls.io/builds/18885107)

Coverage decreased (-0.1%) to 97.245% when pulling **e87a833f5ec9d21b734171535521f1bce021001f on TheNoim:master** into **50899e7f0235f0e100f718401b2e961ca3e04b19 on delvedor:master**.

coveralls: 
[![Coverage Status](https://coveralls.io/builds/18885107/badge)](https://coveralls.io/builds/18885107)

Coverage decreased (-0.1%) to 97.245% when pulling **e87a833f5ec9d21b734171535521f1bce021001f on TheNoim:master** into **50899e7f0235f0e100f718401b2e961ca3e04b19 on delvedor:master**.

coveralls: 
[![Coverage Status](https://coveralls.io/builds/18885107/badge)](https://coveralls.io/builds/18885107)

Coverage decreased (-0.1%) to 97.245% when pulling **e87a833f5ec9d21b734171535521f1bce021001f on TheNoim:master** into **50899e7f0235f0e100f718401b2e961ca3e04b19 on delvedor:master**.

coveralls: 
[![Coverage Status](https://coveralls.io/builds/18885107/badge)](https://coveralls.io/builds/18885107)

Coverage decreased (-0.1%) to 97.245% when pulling **e87a833f5ec9d21b734171535521f1bce021001f on TheNoim:master** into **50899e7f0235f0e100f718401b2e961ca3e04b19 on delvedor:master**.

TheNoim: this escalated quickly
TheNoim: Added a test @mcollina 

Patch:
diff --git a/index.js b/index.js
index 4d9f506..ec43401 100644
--- a/index.js
+++ b/index.js
@@ -482,6 +482,7 @@ Router.prototype.prettyPrint = function () {
 }
 
 for (var i in http.METHODS) {
+  if (!http.METHODS.hasOwnProperty(i)) continue
   const m = http.METHODS[i]
   const methodName = m.toLowerCase()
 


Test patch:
diff --git a/test/for-in-loop.test.js b/test/for-in-loop.test.js
new file mode 100644
index 0000000..a6f9762
--- /dev/null
+++ b/test/for-in-loop.test.js
@@ -0,0 +1,12 @@
+/* eslint-disable */
+'use strict'
+
+const t = require('tap')
+const test = t.test
+
+test('should not throw', t => {
+  t.plan(1)
+  // Something could extend the Array prototype
+  Array.prototype.test = null
+  t.doesNotThrow(require('../'))
+})
Repository: delvedor/find-my-way
Pull request #92 (2018-09-07 18:20:08)

Update readme for explaining better the route order
as titled

coveralls: 
[![Coverage Status](https://coveralls.io/builds/18886587/badge)](https://coveralls.io/builds/18886587)

Coverage remained the same at 97.372% when pulling **142f836a0fe16e7cc37c1ca3db3b6272182822e8 on allevo:update-readme-route-order** into **50899e7f0235f0e100f718401b2e961ca3e04b19 on delvedor:master**.


Patch:
diff --git a/README.md b/README.md
index cf45bb5..3a00b0d 100644
--- a/README.md
+++ b/README.md
@@ -168,14 +168,26 @@ Having a route with multiple parameters may affect negatively the performance, s
 
 <a name="match-order"></a>
 ##### Match order
-The routes are matched in the following order:
-```
-static
-parametric
-wildcards
-parametric(regex)
-multi parametric(regex)
-```
+
+The routing algorithm matches one chunk at a time (where the chunk is a string between two slashes),
+this means that it cannot know if a route is static or dynamic until it finishes to match the URL.
+
+The chunks are matched in the following order:
+
+1. static
+1. parametric
+1. wildcards
+1. parametric(regex)
+1. multi parametric(regex)
+
+So if you declare the following routes
+
+- `/:userId/foo/bar`
+- `/33/:a(^.*$)/:b`
+
+and the URL of the incoming request is /33/foo/bar,
+the second route will be matched because the first chunk (33) matches the static chunk.
+If the URL would have been /32/foo/bar, the first route would have been matched.
 
 <a name="supported-methods"></a>
 ##### Supported methods
diff --git a/index.js b/index.js
index 4d9f506..ec43401 100644
--- a/index.js
+++ b/index.js
@@ -482,6 +482,7 @@ Router.prototype.prettyPrint = function () {
 }
 
 for (var i in http.METHODS) {
+  if (!http.METHODS.hasOwnProperty(i)) continue
   const m = http.METHODS[i]
   const methodName = m.toLowerCase()
 
diff --git a/package.json b/package.json
index f1e4bf7..fa47f72 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
   "name": "find-my-way",
-  "version": "1.15.1",
+  "version": "1.15.2",
   "description": "Crazy fast http radix based router",
   "main": "index.js",
   "scripts": {


Test patch:
diff --git a/test/for-in-loop.test.js b/test/for-in-loop.test.js
new file mode 100644
index 0000000..cabe969
--- /dev/null
+++ b/test/for-in-loop.test.js
@@ -0,0 +1,11 @@
+'use strict'
+
+/* eslint no-extend-native: off */
+
+const t = require('tap')
+
+// Something could extend the Array prototype
+Array.prototype.test = null
+t.doesNotThrow(() => {
+  require('../')
+})
Repository: delvedor/find-my-way
Pull request #184 (2021-03-17 23:39:11)

fix prettyPrint undefined method
Related to [fastify/2938](https://github.com/fastify/fastify/issues/2938)

Caused by not setting method property when splitting node

airhorns: Whoops, thanks @AyoubElk ! 

Patch:
diff --git a/node.js b/node.js
index d8f9e48..adc5281 100644
--- a/node.js
+++ b/node.js
@@ -120,6 +120,7 @@ Node.prototype.split = function (length) {
       prefix: this.prefix.slice(length),
       children: this.children,
       kind: this.kind,
+      method: this.method,
       handlers: this.handlers.slice(0),
       regex: this.regex,
       constrainer: this.constrainer,


Test patch:
diff --git a/test/issue-182.test.js b/test/issue-182.test.js
new file mode 100644
index 0000000..869f9e7
--- /dev/null
+++ b/test/issue-182.test.js
@@ -0,0 +1,19 @@
+'use strict'
+
+const t = require('tap')
+const test = t.test
+const FindMyWay = require('..')
+
+test('Set method property when splitting node', t => {
+  t.plan(1)
+  const findMyWay = FindMyWay()
+
+  function handler (req, res, params) {
+    t.pass()
+  }
+
+  findMyWay.on('GET', '/health-a/health', handler)
+  findMyWay.on('GET', '/health-b/health', handler)
+
+  t.notMatch(findMyWay.prettyPrint(), /undefined/)
+})
Repository: delvedor/find-my-way
Pull request #344 (2024-01-16 11:28:56)

Update contraint check to throw with 32 handlers
Fixes:
- #343 

mcollina: @ivan-tymoshenko can you take a look?

Patch:
diff --git a/lib/handler-storage.js b/lib/handler-storage.js
index 783507e..12cd046 100644
--- a/lib/handler-storage.js
+++ b/lib/handler-storage.js
@@ -47,8 +47,8 @@ class HandlerStorage {
     }
 
     const isMergedTree = constraintsNames.includes(httpMethodStrategy.name)
-    if (!isMergedTree && this.handlers.length >= 32) {
-      throw new Error('find-my-way supports a maximum of 32 route handlers per node when there are constraints, limit reached')
+    if (!isMergedTree && this.handlers.length >= 31) {
+      throw new Error('find-my-way supports a maximum of 31 route handlers per node when there are constraints, limit reached')
     }
 
     this.handlers.push(handlerObject)


Test patch:
diff --git a/test/constraint.host.test.js b/test/constraint.host.test.js
index a8e4f28..5033ed4 100644
--- a/test/constraint.host.test.js
+++ b/test/constraint.host.test.js
@@ -74,3 +74,32 @@ test('A route supports multiple host constraints (lookup)', t => {
     headers: { host: 'bar.fancy.ca' }
   })
 })
+
+test('A route supports up to 31 host constraints', (t) => {
+  t.plan(1)
+
+  const findMyWay = FindMyWay()
+
+  for (let i = 0; i < 31; i++) {
+    const host = `h${i.toString().padStart(2, '0')}`
+    findMyWay.on('GET', '/', { constraints: { host } }, alpha)
+  }
+
+  t.equal(findMyWay.find('GET', '/', { host: 'h01' }).handler, alpha)
+})
+
+test('A route throws when constraint limit exceeded', (t) => {
+  t.plan(1)
+
+  const findMyWay = FindMyWay()
+
+  for (let i = 0; i < 31; i++) {
+    const host = `h${i.toString().padStart(2, '0')}`
+    findMyWay.on('GET', '/', { constraints: { host } }, alpha)
+  }
+
+  t.throws(
+    () => findMyWay.on('GET', '/', { constraints: { host: 'h31' } }, beta),
+    'find-my-way supports a maximum of 31 route handlers per node when there are constraints, limit reached'
+  )
+})
Repository: drivendataorg/cloudpathlib
Pull request #122 (2021-02-15 18:19:36)

[Staged] Append filename to destination if source is file
Staged version of #121 by @genziano on the main repo so we can run full test suite, including live tests with credentials.

github-actions[bot]: <!-- NETLIFY DEPLOY COMMENT GENERATED BY ACTIONS_NETLIFY -->
🚀 Deployed on https://deploy-preview-122--gallant-agnesi-5f7bb3.netlify.app
codecov[bot]: # [Codecov](https://codecov.io/gh/drivendataorg/cloudpathlib/pull/122?src=pr&el=h1) Report
> Merging [#122](https://codecov.io/gh/drivendataorg/cloudpathlib/pull/122?src=pr&el=desc) (96dd4d6) into [master](https://codecov.io/gh/drivendataorg/cloudpathlib/commit/bd5d026e559a0cfa0389b11b9b470e24f1066d0f?el=desc) (bd5d026) will **increase** coverage by `0.0%`.
> The diff coverage is `100.0%`.

```diff
@@          Coverage Diff           @@
##           master    #122   +/-   ##
======================================
  Coverage    91.5%   91.6%           
======================================
  Files          18      18           
  Lines        1034    1036    +2     
======================================
+ Hits          947     949    +2     
  Misses         87      87           
```


| [Impacted Files](https://codecov.io/gh/drivendataorg/cloudpathlib/pull/122?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [cloudpathlib/cloudpath.py](https://codecov.io/gh/drivendataorg/cloudpathlib/pull/122/diff?src=pr&el=tree#diff-Y2xvdWRwYXRobGliL2Nsb3VkcGF0aC5weQ==) | `90.2% <100.0%> (+<0.1%)` | :arrow_up: |


Patch:
diff --git a/cloudpathlib/cloudpath.py b/cloudpathlib/cloudpath.py
index 8e5b970..4fff608 100644
--- a/cloudpathlib/cloudpath.py
+++ b/cloudpathlib/cloudpath.py
@@ -576,6 +576,8 @@ class CloudPath(metaclass=CloudPathMeta):
     def download_to(self, destination: Union[str, os.PathLike]):
         destination = Path(destination)
         if self.is_file():
+            if destination.is_dir():
+                destination = destination / self.name
             self.client._download_file(self, destination)
         else:
             destination.mkdir(exist_ok=True)


Test patch:
diff --git a/tests/test_cloudpath_file_io.py b/tests/test_cloudpath_file_io.py
index 792efbc..944f8cc 100644
--- a/tests/test_cloudpath_file_io.py
+++ b/tests/test_cloudpath_file_io.py
@@ -96,6 +96,14 @@ def test_file_read_writes(rig, tmp_path):
     assert cloud_rel_paths == dled_rel_paths
 
 
+def test_cloud_path_download_to(rig, tmp_path):
+    p = rig.create_cloud_path("dir_0/file0_0.txt")
+    dl_dir = tmp_path
+    assert not (dl_dir / p.name).exists()
+    p.download_to(dl_dir)
+    assert (dl_dir / p.name).is_file()
+
+
 def test_fspath(rig):
     p = rig.create_cloud_path("dir_0")
     assert os.fspath(p) == p.fspath
Repository: VirtusLab/git-machete
Pull request #1278 (2024-07-03 14:03:17)

Fix parsing multiline entries in git config


Patch:
diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md
index 43f8b4a..f858029 100644
--- a/RELEASE_NOTES.md
+++ b/RELEASE_NOTES.md
@@ -2,6 +2,8 @@
 
 ## New in git-machete 3.26.2
 
+- fixed: parsing of multiline git config keys (reported by @saveman71)
+
 ## New in git-machete 3.26.1
 
 - fixed: readability of autogenerated PR/MR descriptions
diff --git a/docs/man/git-machete.1 b/docs/man/git-machete.1
index 7bdb2f5..e680113 100644
--- a/docs/man/git-machete.1
+++ b/docs/man/git-machete.1
@@ -27,7 +27,7 @@ level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
 .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
 .in \\n[rst2man-indent\\n[rst2man-indent-level]]u
 ..
-.TH "GIT-MACHETE" "1" "Jul 01, 2024" "" "git-machete"
+.TH "GIT-MACHETE" "1" "Jul 03, 2024" "" "git-machete"
 .SH NAME
 git-machete \- git-machete 3.26.2
 .sp
diff --git a/git_machete/git_operations.py b/git_machete/git_operations.py
index ec6f81b..ac1c811 100644
--- a/git_machete/git_operations.py
+++ b/git_machete/git_operations.py
@@ -303,13 +303,15 @@ class GitContext:
     def __ensure_config_loaded(self) -> None:
         if self.__config_cached is None:
             self.__config_cached = {}
-            for config_line in utils.get_non_empty_lines(self._popen_git("config", "--list").stdout):
-                k_v = config_line.split("=", 1)
-                if len(k_v) == 2:
-                    k, v = k_v
-                    self.__config_cached[k.lower()] = v
+            git_config_stdout = self._popen_git("config", "--list", "--null").stdout
+            for config_entry in filter(None, git_config_stdout.split("\0")):
+                # Apparently, even on Windows, this command uses just \n (and not \r\n) to separate config key from value.
+                key_and_value_lines = config_entry.split('\n', 1)
+                if len(key_and_value_lines) == 2:
+                    key, value_lines = key_and_value_lines
+                    self.__config_cached[key.lower()] = value_lines
                 else:
-                    raise UnexpectedMacheteException(f"Cannot parse config line: {config_line}.")
+                    raise UnexpectedMacheteException(f"Cannot parse config entry: {config_entry}.")
 
     def get_config_attr_or_none(self, key: str) -> Optional[str]:
         self.__ensure_config_loaded()


Test patch:
diff --git a/tests/test_git_operations.py b/tests/test_git_operations.py
index cbe266c..6dbed21 100644
--- a/tests/test_git_operations.py
+++ b/tests/test_git_operations.py
@@ -164,3 +164,8 @@ class TestGitOperations(BaseTest):
 
         assert git.is_equivalent_tree_reachable(equivalent_to=feature, reachable_from=master) is False
         assert git.is_equivalent_patch_reachable(equivalent_to=feature, reachable_from=master) is False
+
+    def test_git_config_with_newlines(self) -> None:
+        self.repo_sandbox.write_to_file(".git/config", '[foo]\n  bar = "hello\\nworld"')
+        git = GitContext()
+        assert git.get_config_attr_or_none("foo.bar") == "hello\nworld"
Repository: knex/knex
Pull request #5166 (2022-05-08 16:52:54)

Refresh materialized view concurrently for PostgreSQL
PostgreSQL has a support to refresh the materialized view concurrently: [Documentation](https://www.postgresql.org/docs/current/sql-refreshmaterializedview.html)

This PR adds an optional boolean argument to the `refreshMaterializedView` method to refresh the view concurrently for PostgreSQL

OlivierCavadenti: Hi, thanks for the pr, can you update the documentation ? https://github.com/knex/documentation
coveralls: 
[![Coverage Status](https://coveralls.io/builds/48929212/badge)](https://coveralls.io/builds/48929212)

Coverage increased (+0.002%) to 92.282% when pulling **1ea6cd5fc29c59452223293722d1de995de953f0 on skwee357:master** into **3eec52ea252eea84f418c30f833f9c8b29249402 on knex:master**.

skwee357: Hey @OlivierCavadenti thanks, I've added it https://github.com/knex/documentation/pull/402

Patch:
diff --git a/lib/dialects/postgres/schema/pg-compiler.js b/lib/dialects/postgres/schema/pg-compiler.js
index e34cfa46..d164ce84 100644
--- a/lib/dialects/postgres/schema/pg-compiler.js
+++ b/lib/dialects/postgres/schema/pg-compiler.js
@@ -118,9 +118,9 @@ class SchemaCompiler_PG extends SchemaCompiler {
     );
   }
 
-  refreshMaterializedView(viewName) {
+  refreshMaterializedView(viewName, concurrently = false) {
     this.pushQuery({
-      sql: `refresh materialized view ${this.formatter.wrap(viewName)}`,
+      sql: `refresh materialized view${concurrently ? " concurrently" : ""} ${this.formatter.wrap(viewName)}`,
     });
   }
 
diff --git a/types/index.d.ts b/types/index.d.ts
index e26c1d66..1c999f53 100644
--- a/types/index.d.ts
+++ b/types/index.d.ts
@@ -1983,7 +1983,7 @@ export declare namespace Knex {
       viewName: string,
       callback: (viewBuilder: ViewBuilder) => any
     ): SchemaBuilder;
-    refreshMaterializedView(viewName: string): SchemaBuilder;
+    refreshMaterializedView(viewName: string, concurrently?: boolean): SchemaBuilder;
     dropView(viewName: string): SchemaBuilder;
     dropViewIfExists(viewName: string): SchemaBuilder;
     dropMaterializedView(viewName: string): SchemaBuilder;


Test patch:
diff --git a/test/unit/schema-builder/postgres.js b/test/unit/schema-builder/postgres.js
index 2361781c..46a0c915 100644
--- a/test/unit/schema-builder/postgres.js
+++ b/test/unit/schema-builder/postgres.js
@@ -445,6 +445,18 @@ describe('PostgreSQL SchemaBuilder', function () {
         'refresh materialized view "view_to_refresh"'
       );
     });
+
+
+    it('refresh view concurrently', function () {
+      tableSql = client
+        .schemaBuilder()
+        .refreshMaterializedView('view_to_refresh', true)
+        .toSQL();
+      equal(1, tableSql.length);
+      expect(tableSql[0].sql).to.equal(
+        'refresh materialized view concurrently "view_to_refresh"'
+      );
+    });
   });
 
   it('drop table with schema', function () {
Repository: koajs/koa
Pull request #443 (2015-05-21 19:30:12)

return same object from request.query
Before this change, calling request.query when there was no querystring
resulted in a new object created and returned each time. If the resulting
object was ever changed, accessing request.query would not reflect it and
cause weird bugs.

tj: SGTM, I think we have `this.querystring` returning `''` by default now so we could probably just remove the condition

Patch:
diff --git a/lib/request.js b/lib/request.js
index f8d75e4..cb7dcda 100644
--- a/lib/request.js
+++ b/lib/request.js
@@ -131,8 +131,6 @@ module.exports = {
 
   get query() {
     var str = this.querystring;
-    if (!str) return {};
-
     var c = this._querycache = this._querycache || {};
     return c[str] || (c[str] = qs.parse(str));
   },


Test patch:
diff --git a/test/request/query.js b/test/request/query.js
index b6669be..99a74ee 100644
--- a/test/request/query.js
+++ b/test/request/query.js
@@ -7,6 +7,13 @@ describe('ctx.query', function(){
       var ctx = context({ url: '/' });
       ctx.query.should.eql({});
     })
+
+    it('should return the same object each time it\'s accessed', function(done) {
+      var ctx = context({ url: '/' });
+      ctx.query.a = '2';
+      ctx.query.a.should.equal('2');
+      done();
+    });
   })
 
   it('should return a parsed query-string', function(){