Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Selecting database in a view adds it to the query #203

Open
azul opened this issue May 24, 2016 · 1 comment
Open

Selecting database in a view adds it to the query #203

azul opened this issue May 24, 2016 · 1 comment

Comments

@azul
Copy link
Contributor

azul commented May 24, 2016

The database method on views allows specifying the database to query from.

  User.by_login.database(User.tmp_database).key("bla").first

However the database parameter gets added to the query so it's also present in the url. So the couch logs for this query for me show:

GET /tmp_users/_design/User/_view/by_login?database=http%3A%2F%2Flocalhost%3A5984%2Ftmp_users&key=%22bla%22&limit=1&include_docs=true&reduce=false 200

I would expect the query to not contain the database:

GET /tmp_users/_design/User/_view/by_login?key=%22bla%22&limit=1&include_docs=true&reduce=false 200

The database parameter clutters the query and also leaks credentials in the couch logs.

@azul
Copy link
Contributor Author

azul commented May 24, 2016

I've looked into implementing a fix for this a bit. I see two options...
The hacky one... remove the database parameter from the query. This would have the ugly sideeffect of removing the parameter even if it was explicitly set.
The more correct one (?)... use something else than the query to store the database in. This is kind of complicated because of the nice way queries are build by chaining calls and creating new instances of the view. The initializer already has 4 parameters. The best way would probably be to fetch it from the parent like we currently do with name.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant