{"action":"created","issue":{"url":"https://api.github.com/repos/elixir-lang/ecto/issues/573","labels_url":"https://api.github.com/repos/elixir-lang/ecto/issues/573/labels{/name}","comments_url":"https://api.github.com/repos/elixir-lang/ecto/issues/573/comments","events_url":"https://api.github.com/repos/elixir-lang/ecto/issues/573/events","html_url":"https://github.com/elixir-lang/ecto/issues/573","id":71868843,"number":573,"title":"Ecto.Repo.one ignores the \"where\" from an Ecto.Query","user":{"login":"jeznet","id":35540,"avatar_url":"https://avatars.githubusercontent.com/u/35540?v=3","gravatar_id":"","url":"https://api.github.com/users/jeznet","html_url":"https://github.com/jeznet","followers_url":"https://api.github.com/users/jeznet/followers","following_url":"https://api.github.com/users/jeznet/following{/other_user}","gists_url":"https://api.github.com/users/jeznet/gists{/gist_id}","starred_url":"https://api.github.com/users/jeznet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jeznet/subscriptions","organizations_url":"https://api.github.com/users/jeznet/orgs","repos_url":"https://api.github.com/users/jeznet/repos","events_url":"https://api.github.com/users/jeznet/events{/privacy}","received_events_url":"https://api.github.com/users/jeznet/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-04-29T13:00:29Z","updated_at":"2015-04-29T13:21:52Z","closed_at":null,"body":"For a test case like this:\r\n```\r\ndefmodule MyApp.CommentTest do\r\n  use ExUnit.Case, async: false\r\n\r\n  test \"insert, get\" do\r\n    comment = %MyApp.Comment{\r\n      web_content_id: 10,\r\n      content: \"test\",\r\n      published_at: {{2015, 04, 28}, {08, 25, 58, 0}},\r\n    }\r\n    assert %MyApp.Comment{} = Repo.insert(comment)\r\n\r\n    comment = %MyApp.Comment{\r\n      web_content_id: 11,\r\n      content: \"some test\",\r\n      published_at: {{2015, 04, 28}, {08, 25, 59, 0}},\r\n    }\r\n    assert %MyApp.Comment{} = Repo.insert(comment)\r\n\r\n    q = from c in MyApp.Comment,\r\n      where: c.content == \"test\"\r\n    comment = Repo.one!(q)\r\n    assert %MyApp.Comment{ web_content_id: 10 } = comment\r\n  end\r\nend\r\n```\r\nrunning `mix test` gives:\r\n```\r\n  1) test insert, get, update, delete (Ehnix.CommentTest)\r\n     test/my_app/models/comment_test.exs:6\r\n     ** (Ecto.MultipleResultsError) expected at most one result but got 2 in query:\r\n     \r\n     from c in Ehnix.Comment\r\n     \r\n     stacktrace:\r\n       (ecto) lib/ecto/repo/queryable.ex:46: Ecto.Repo.Queryable.one/4\r\n       test/ehnix/models/comment2_test.exs:28\r\n```\r\nThe where clause seems to disappear...\r\n\r\nAfter changing the query to:\r\n```\r\n    q = from c in MyApp.Comment,\r\n      where: c.content == \"not  existing text\r\n```\r\nit gets:\r\n```\r\n     ** (Ecto.NoResultsError) expected at least one result but got none in query:\r\n     \r\n     from c in Ehnix.Comment,\r\n       where: c.content == \"non existing text\"\r\n```\r\nso the where part appears.\r\n\r\nStrangely this code works for me in IEx.\r\n\r\nVersions:\r\n```\r\n$ cat mix.lock | grep ecto\r\n  \"ecto\": {:hex, :ecto, \"0.10.2\"},\r\n$ elixir -v\r\nElixir 1.0.4\r\n$ psql --version\r\npsql (PostgreSQL) 9.3.6\r\n```"},"comment":{"url":"https://api.github.com/repos/elixir-lang/ecto/issues/comments/97423424","html_url":"https://github.com/elixir-lang/ecto/issues/573#issuecomment-97423424","issue_url":"https://api.github.com/repos/elixir-lang/ecto/issues/573","id":97423424,"user":{"login":"josevalim","id":9582,"avatar_url":"https://avatars.githubusercontent.com/u/9582?v=3","gravatar_id":"","url":"https://api.github.com/users/josevalim","html_url":"https://github.com/josevalim","followers_url":"https://api.github.com/users/josevalim/followers","following_url":"https://api.github.com/users/josevalim/following{/other_user}","gists_url":"https://api.github.com/users/josevalim/gists{/gist_id}","starred_url":"https://api.github.com/users/josevalim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/josevalim/subscriptions","organizations_url":"https://api.github.com/users/josevalim/orgs","repos_url":"https://api.github.com/users/josevalim/repos","events_url":"https://api.github.com/users/josevalim/events{/privacy}","received_events_url":"https://api.github.com/users/josevalim/received_events","type":"User","site_admin":false},"created_at":"2015-04-29T13:21:51Z","updated_at":"2015-04-29T13:21:51Z","body":"Can you provide a way to reproduce this in Ecto repo? Or a failing test in Ecto's sample application in the examples directory? I have tried it and everything just works™."}}