{"action":"created","issue":{"url":"https://api.github.com/repos/npgsql/Npgsql.EntityFrameworkCore.PostgreSQL/issues/666","repository_url":"https://api.github.com/repos/npgsql/Npgsql.EntityFrameworkCore.PostgreSQL","labels_url":"https://api.github.com/repos/npgsql/Npgsql.EntityFrameworkCore.PostgreSQL/issues/666/labels{/name}","comments_url":"https://api.github.com/repos/npgsql/Npgsql.EntityFrameworkCore.PostgreSQL/issues/666/comments","events_url":"https://api.github.com/repos/npgsql/Npgsql.EntityFrameworkCore.PostgreSQL/issues/666/events","html_url":"https://github.com/npgsql/Npgsql.EntityFrameworkCore.PostgreSQL/issues/666","id":371000786,"node_id":"MDU6SXNzdWUzNzEwMDA3ODY=","number":666,"title":"Zero-trailing issue with domains (Numeric value does not fit in a System.Decimal)","user":{"login":"alexk8","id":31513440,"node_id":"MDQ6VXNlcjMxNTEzNDQw","avatar_url":"https://avatars1.githubusercontent.com/u/31513440?v=4","gravatar_id":"","url":"https://api.github.com/users/alexk8","html_url":"https://github.com/alexk8","followers_url":"https://api.github.com/users/alexk8/followers","following_url":"https://api.github.com/users/alexk8/following{/other_user}","gists_url":"https://api.github.com/users/alexk8/gists{/gist_id}","starred_url":"https://api.github.com/users/alexk8/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexk8/subscriptions","organizations_url":"https://api.github.com/users/alexk8/orgs","repos_url":"https://api.github.com/users/alexk8/repos","events_url":"https://api.github.com/users/alexk8/events{/privacy}","received_events_url":"https://api.github.com/users/alexk8/received_events","type":"User","site_admin":false},"labels":[{"id":355737759,"node_id":"MDU6TGFiZWwzNTU3Mzc3NTk=","url":"https://api.github.com/repos/npgsql/Npgsql.EntityFrameworkCore.PostgreSQL/labels/bug","name":"bug","color":"ee0701","default":true}],"state":"open","locked":false,"assignee":{"login":"YohDeadfall","id":10694013,"node_id":"MDQ6VXNlcjEwNjk0MDEz","avatar_url":"https://avatars0.githubusercontent.com/u/10694013?v=4","gravatar_id":"","url":"https://api.github.com/users/YohDeadfall","html_url":"https://github.com/YohDeadfall","followers_url":"https://api.github.com/users/YohDeadfall/followers","following_url":"https://api.github.com/users/YohDeadfall/following{/other_user}","gists_url":"https://api.github.com/users/YohDeadfall/gists{/gist_id}","starred_url":"https://api.github.com/users/YohDeadfall/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/YohDeadfall/subscriptions","organizations_url":"https://api.github.com/users/YohDeadfall/orgs","repos_url":"https://api.github.com/users/YohDeadfall/repos","events_url":"https://api.github.com/users/YohDeadfall/events{/privacy}","received_events_url":"https://api.github.com/users/YohDeadfall/received_events","type":"User","site_admin":false},"assignees":[{"login":"YohDeadfall","id":10694013,"node_id":"MDQ6VXNlcjEwNjk0MDEz","avatar_url":"https://avatars0.githubusercontent.com/u/10694013?v=4","gravatar_id":"","url":"https://api.github.com/users/YohDeadfall","html_url":"https://github.com/YohDeadfall","followers_url":"https://api.github.com/users/YohDeadfall/followers","following_url":"https://api.github.com/users/YohDeadfall/following{/other_user}","gists_url":"https://api.github.com/users/YohDeadfall/gists{/gist_id}","starred_url":"https://api.github.com/users/YohDeadfall/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/YohDeadfall/subscriptions","organizations_url":"https://api.github.com/users/YohDeadfall/orgs","repos_url":"https://api.github.com/users/YohDeadfall/repos","events_url":"https://api.github.com/users/YohDeadfall/events{/privacy}","received_events_url":"https://api.github.com/users/YohDeadfall/received_events","type":"User","site_admin":false}],"milestone":null,"comments":7,"created_at":"2018-10-17T10:17:52Z","updated_at":"2018-10-18T12:06:35Z","closed_at":null,"author_association":"NONE","body":"I have a domain: `CREATE DOMAIN amount_type AS numeric(34,18)`\r\nIt's used in model like:   ` [Column(TypeName = \"amount_type\")] decimal ;`\r\nI have two problems:\r\n1) inserting \"0.1\" gives back \"0.100000000000000000\" when reading\r\n2) selecting, lets say, `x=>new {mul = x.a * x.b}` - gives \"Numeric value does not fit in a System.Decimal\" even if numbers are 0.1 (as an examples) because of number of trailing zeros\r\n\r\nRecently it wasn't the case (everything worked well)\r\nCan it be considered as a bug?\r\nIs there any workaround?"},"comment":{"url":"https://api.github.com/repos/npgsql/Npgsql.EntityFrameworkCore.PostgreSQL/issues/comments/430983261","html_url":"https://github.com/npgsql/Npgsql.EntityFrameworkCore.PostgreSQL/issues/666#issuecomment-430983261","issue_url":"https://api.github.com/repos/npgsql/Npgsql.EntityFrameworkCore.PostgreSQL/issues/666","id":430983261,"node_id":"MDEyOklzc3VlQ29tbWVudDQzMDk4MzI2MQ==","user":{"login":"alexk8","id":31513440,"node_id":"MDQ6VXNlcjMxNTEzNDQw","avatar_url":"https://avatars1.githubusercontent.com/u/31513440?v=4","gravatar_id":"","url":"https://api.github.com/users/alexk8","html_url":"https://github.com/alexk8","followers_url":"https://api.github.com/users/alexk8/followers","following_url":"https://api.github.com/users/alexk8/following{/other_user}","gists_url":"https://api.github.com/users/alexk8/gists{/gist_id}","starred_url":"https://api.github.com/users/alexk8/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexk8/subscriptions","organizations_url":"https://api.github.com/users/alexk8/orgs","repos_url":"https://api.github.com/users/alexk8/repos","events_url":"https://api.github.com/users/alexk8/events{/privacy}","received_events_url":"https://api.github.com/users/alexk8/received_events","type":"User","site_admin":false},"created_at":"2018-10-18T12:06:35Z","updated_at":"2018-10-18T12:06:35Z","author_association":"NONE","body":"```\r\nusing System;\r\nusing System.ComponentModel.DataAnnotations.Schema;\r\nusing System.Linq;\r\nusing System.Threading.Tasks;\r\nusing Microsoft.EntityFrameworkCore;\r\nusing Microsoft.VisualStudio.TestTools.UnitTesting;\r\nusing System.Globalization;\r\n\r\nnamespace pgsql_efcore_test\r\n{\r\n    public class Order\r\n    {\r\n        [DatabaseGenerated(DatabaseGeneratedOption.None)]\r\n        public Guid id { get; set; }\r\n        [Column(TypeName = \"numeric(34,18)\")]\r\n        public decimal price { get; set; }\r\n        [Column(TypeName = \"numeric(34,18)\")]\r\n        public decimal quantity { get; set; }\r\n    }\r\n\r\n    class MyContext : DbContext\r\n    {\r\n        public DbSet<Order> orders { get; set; }\r\n\r\n        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)\r\n        {\r\n            optionsBuilder\r\n                .UseNpgsql(string.Join(';', new[] {\r\n                    \"Server=localhost\",\r\n                    \"Port=5432\",\r\n                    \"Database=testdb\",\r\n                    \"User Id=tester\",\r\n                    \"Password=testpass\"\r\n                }))\r\n                .EnableSensitiveDataLogging();\r\n        }\r\n\r\n    }\r\n\r\n    [TestClass]\r\n    public class UnitTest1\r\n    {\r\n        static readonly Guid orderID = Guid.NewGuid();\r\n        static bool initialized = false;\r\n\r\n        [TestInitialize]\r\n        public async Task TestInit()\r\n        {\r\n            if (!initialized)\r\n                using (MyContext context = new MyContext())\r\n                {\r\n                    //context.Database.EnsureDeleted();\r\n                    context.Database.EnsureCreated();\r\n\r\n                    Order order = new Order\r\n                    {\r\n                        id = orderID,\r\n                        price = 0.2m,\r\n                        quantity = 0.2m\r\n                    };\r\n                    await context.orders.AddAsync(order);\r\n                    await context.SaveChangesAsync();\r\n                    initialized = true;\r\n                }\r\n        }\r\n\r\n        [TestMethod]\r\n        public async Task TestMethod1()\r\n        {\r\n            using (MyContext context = new MyContext())\r\n            {\r\n                var order = await context.orders.FindAsync(orderID);\r\n                Assert.AreNotEqual(\"0.200000000000000000\", order.price.ToString(CultureInfo.InvariantCulture));\r\n            }\r\n        }\r\n        [TestMethod]\r\n        //[ExpectedException(typeof(OverflowException), \"Numeric value does not fit in a System.Decimal\")]\r\n        public async Task TestMethod2()\r\n        {\r\n            using (MyContext context = new MyContext())\r\n            {\r\n                var vol = await context.orders\r\n                    .Where(x => x.id == orderID)\r\n                    .Select(x => new { vol = x.price * x.quantity })\r\n                    .SingleAsync();\r\n                Assert.AreEqual(0.04m, vol);\r\n            }\r\n        }\r\n    }\r\n}\r\n```"}}
{"actor":{"display_login":"alexk8"}}