{"action":"created","issue":{"url":"https://api.github.com/repos/elixir-lang/ecto/issues/547","labels_url":"https://api.github.com/repos/elixir-lang/ecto/issues/547/labels{/name}","comments_url":"https://api.github.com/repos/elixir-lang/ecto/issues/547/comments","events_url":"https://api.github.com/repos/elixir-lang/ecto/issues/547/events","html_url":"https://github.com/elixir-lang/ecto/issues/547","id":65665811,"number":547,"title":"Decimals not saved correctly in Postgres DB","user":{"login":"swerter","id":11270,"avatar_url":"https://avatars.githubusercontent.com/u/11270?v=3","gravatar_id":"","url":"https://api.github.com/users/swerter","html_url":"https://github.com/swerter","followers_url":"https://api.github.com/users/swerter/followers","following_url":"https://api.github.com/users/swerter/following{/other_user}","gists_url":"https://api.github.com/users/swerter/gists{/gist_id}","starred_url":"https://api.github.com/users/swerter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/swerter/subscriptions","organizations_url":"https://api.github.com/users/swerter/orgs","repos_url":"https://api.github.com/users/swerter/repos","events_url":"https://api.github.com/users/swerter/events{/privacy}","received_events_url":"https://api.github.com/users/swerter/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/elixir-lang/ecto/labels/Kind:Bug","name":"Kind:Bug","color":"fc2929"},{"url":"https://api.github.com/repos/elixir-lang/ecto/labels/Level:Advanced","name":"Level:Advanced","color":"f7c6c7"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2015-04-01T11:48:27Z","updated_at":"2015-04-10T10:13:40Z","closed_at":"2015-04-10T09:52:38Z","body":"Hi\r\nI think I found a bug when trying to save a decimal into a postgresql database. \r\nHow to reproduce:\r\nChange in the file integration_test/support/migrations.exs the decimal precision to higher value, eg:\r\n\r\n    add :cost, :decimal, precision: 5, scale: 3\r\n\r\nThe integration tests then fails: `MIX_ENV=pg mix test`\r\n```\r\n  1) test primitive types (Ecto.Integration.TypeTest)\r\n     integration_test/cases/type.exs:10\r\n     match (=) failed\r\n     code: [^decimal] = TestRepo.all(from(p in Post, where: p.cost() == ^decimal, select: p.cost()))\r\n     rhs:  [#Decimal<1.00>]\r\n     stacktrace:\r\n       integration_test/cases/type.exs:34\r\n```\r\n\r\nI found this error by trying to save a small number (0.002) to postgres as a decimal. The stored value, however, was always 0.2 instead (only one decimal after the dot).\r\n\r\nThanks for your help."},"comment":{"url":"https://api.github.com/repos/elixir-lang/ecto/issues/comments/91506193","html_url":"https://github.com/elixir-lang/ecto/issues/547#issuecomment-91506193","issue_url":"https://api.github.com/repos/elixir-lang/ecto/issues/547","id":91506193,"user":{"login":"swerter","id":11270,"avatar_url":"https://avatars.githubusercontent.com/u/11270?v=3","gravatar_id":"","url":"https://api.github.com/users/swerter","html_url":"https://github.com/swerter","followers_url":"https://api.github.com/users/swerter/followers","following_url":"https://api.github.com/users/swerter/following{/other_user}","gists_url":"https://api.github.com/users/swerter/gists{/gist_id}","starred_url":"https://api.github.com/users/swerter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/swerter/subscriptions","organizations_url":"https://api.github.com/users/swerter/orgs","repos_url":"https://api.github.com/users/swerter/repos","events_url":"https://api.github.com/users/swerter/events{/privacy}","received_events_url":"https://api.github.com/users/swerter/received_events","type":"User","site_admin":false},"created_at":"2015-04-10T10:13:40Z","updated_at":"2015-04-10T10:13:40Z","body":"To all, thanks a lot!"}}