{"action":"created","issue":{"url":"https://api.github.com/repos/aspnet/EntityFrameworkCore/issues/10405","repository_url":"https://api.github.com/repos/aspnet/EntityFrameworkCore","labels_url":"https://api.github.com/repos/aspnet/EntityFrameworkCore/issues/10405/labels{/name}","comments_url":"https://api.github.com/repos/aspnet/EntityFrameworkCore/issues/10405/comments","events_url":"https://api.github.com/repos/aspnet/EntityFrameworkCore/issues/10405/events","html_url":"https://github.com/aspnet/EntityFrameworkCore/issues/10405","id":276899308,"number":10405,"title":"Joining tables with \"xmin\" defined as concurrency token throws \"column x.xmin does not exist\" (PostgresSQL)","user":{"login":"orobert91","id":6403705,"avatar_url":"https://avatars3.githubusercontent.com/u/6403705?v=4","gravatar_id":"","url":"https://api.github.com/users/orobert91","html_url":"https://github.com/orobert91","followers_url":"https://api.github.com/users/orobert91/followers","following_url":"https://api.github.com/users/orobert91/following{/other_user}","gists_url":"https://api.github.com/users/orobert91/gists{/gist_id}","starred_url":"https://api.github.com/users/orobert91/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/orobert91/subscriptions","organizations_url":"https://api.github.com/users/orobert91/orgs","repos_url":"https://api.github.com/users/orobert91/repos","events_url":"https://api.github.com/users/orobert91/events{/privacy}","received_events_url":"https://api.github.com/users/orobert91/received_events","type":"User","site_admin":false},"labels":[{"id":403964875,"url":"https://api.github.com/repos/aspnet/EntityFrameworkCore/labels/closed-external","name":"closed-external","color":"777777","default":false}],"state":"closed","locked":false,"assignee":{"login":"smitpatel","id":1528107,"avatar_url":"https://avatars0.githubusercontent.com/u/1528107?v=4","gravatar_id":"","url":"https://api.github.com/users/smitpatel","html_url":"https://github.com/smitpatel","followers_url":"https://api.github.com/users/smitpatel/followers","following_url":"https://api.github.com/users/smitpatel/following{/other_user}","gists_url":"https://api.github.com/users/smitpatel/gists{/gist_id}","starred_url":"https://api.github.com/users/smitpatel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smitpatel/subscriptions","organizations_url":"https://api.github.com/users/smitpatel/orgs","repos_url":"https://api.github.com/users/smitpatel/repos","events_url":"https://api.github.com/users/smitpatel/events{/privacy}","received_events_url":"https://api.github.com/users/smitpatel/received_events","type":"User","site_admin":false},"assignees":[{"login":"smitpatel","id":1528107,"avatar_url":"https://avatars0.githubusercontent.com/u/1528107?v=4","gravatar_id":"","url":"https://api.github.com/users/smitpatel","html_url":"https://github.com/smitpatel","followers_url":"https://api.github.com/users/smitpatel/followers","following_url":"https://api.github.com/users/smitpatel/following{/other_user}","gists_url":"https://api.github.com/users/smitpatel/gists{/gist_id}","starred_url":"https://api.github.com/users/smitpatel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smitpatel/subscriptions","organizations_url":"https://api.github.com/users/smitpatel/orgs","repos_url":"https://api.github.com/users/smitpatel/repos","events_url":"https://api.github.com/users/smitpatel/events{/privacy}","received_events_url":"https://api.github.com/users/smitpatel/received_events","type":"User","site_admin":false}],"milestone":null,"comments":9,"created_at":"2017-11-27T04:40:09Z","updated_at":"2017-12-01T04:32:45Z","closed_at":"2017-11-29T22:00:45Z","author_association":"NONE","body":"AppDbContext.cs:\r\n\r\n```\r\nmodelBuilder.Entity<User>().ToTable(\"user\").HasKey(u => u.Id);\r\nmodelBuilder.Entity<User>().Property(u => u.Id).HasColumnName(\"id\");\r\nmodelBuilder.Entity<User>().Property(u => u.FriendlyId).HasColumnName(\"friendly_id\").HasDefaultValueSql(\"nextval('user_friendly_id_seq')\").IsRequired();\r\nmodelBuilder.Entity<User>().Property(u => u.ConcurrencyToken).HasColumnName(\"xmin\").HasColumnType(\"xid\").HasColumnType(\"xid\").ValueGeneratedOnAddOrUpdate().IsConcurrencyToken();\r\nmodelBuilder.Entity<User>().Property(u => u.Username).HasColumnName(\"username\");\r\nmodelBuilder.Entity<User>().HasOne(u => u.AccountPicture).WithOne().HasForeignKey<User>(u => u.AccountPictureId);\r\n\r\nmodelBuilder.Entity<UserFile>().ToTable(\"user_file\").HasKey(uf => uf.Id);\r\nmodelBuilder.Entity<UserFile>().Property(uf => uf.Id).HasColumnName(\"id\");\r\nmodelBuilder.Entity<UserFile>().Property(uf => uf.FriendlyId).HasColumnName(\"friendly_id\").HasDefaultValueSql(\"nextval('user_file_friendly_id_seq')\").IsRequired();\r\nmodelBuilder.Entity<UserFile>().Property(uf => uf.ConcurrencyToken).HasColumnName(\"xmin\").HasColumnType(\"xid\").HasColumnType(\"xid\").ValueGeneratedOnAddOrUpdate().IsConcurrencyToken();\r\nmodelBuilder.Entity<UserFile>().Property(uf => uf.OriginalFileName).HasColumnName(\"original_file_name\");\r\nmodelBuilder.Entity<UserFile>().Property(uf => uf.SizeInBytes).HasColumnName(\"size_in_bytes\");\r\nmodelBuilder.Entity<UserFile>().Property(uf => uf.SubDirectoryName).HasColumnName(\"sub_directory\");\r\n\r\nmodelBuilder.Entity<UserImageFile>().ToTable(\"user_file\");\r\nmodelBuilder.Entity<UserImageFile>().Property(uif => uif.Width).HasColumnName(\"width\");\r\nmodelBuilder.Entity<UserImageFile>().Property(uif => uif.Height).HasColumnName(\"height\");\r\n```\r\nWhere `UserImageFile` inherits from `UserFile` and `User.AccountPicture` is of type` UserImageFile`.\r\n\r\nUserRepository.cs:\r\n\r\n`_dbContext.Users.Include(u => u.AccountPicture).ToList();`\r\n\r\nGenerated SQL by Entity Framework:\r\n\r\n```\r\nSELECT \"u\".\"id\", \r\n       \"u\".\"xmin\", \r\n       \"u\".\"username\", \r\n       \"t\".\"id\", \r\n       \"t\".\"xmin\", \r\n       \"t\".\"discriminator\", \r\n       \"t\".\"original_file_name\", \r\n       \"t\".\"size_in_bytes\", \r\n       \"t\".\"sub_directory\", \r\nFROM   \"user\" AS \"u\" \r\n       LEFT JOIN (SELECT \"u.AccountPicture\".* \r\n                  FROM   \"user_file\" AS \"u.AccountPicture\" \r\n                  WHERE  \"u.AccountPicture\".\"discriminator\" = 'UserImageFile') \r\n                 AS \"t\" \r\n              ON \"u\".\"account_picture_id\" = \"t\".\"id\" \r\nORDER  BY \"u\".\"id\";\r\n```\r\nThrows \"column t.xmin does not exist\". This query isn't valid because PostgreSQL will not select xmin as part of `\"u.AccountPicture\".*` . EFCore should implicitly select all columns (including xmin) for this query to be valid."},"comment":{"url":"https://api.github.com/repos/aspnet/EntityFrameworkCore/issues/comments/348398700","html_url":"https://github.com/aspnet/EntityFrameworkCore/issues/10405#issuecomment-348398700","issue_url":"https://api.github.com/repos/aspnet/EntityFrameworkCore/issues/10405","id":348398700,"user":{"login":"smitpatel","id":1528107,"avatar_url":"https://avatars0.githubusercontent.com/u/1528107?v=4","gravatar_id":"","url":"https://api.github.com/users/smitpatel","html_url":"https://github.com/smitpatel","followers_url":"https://api.github.com/users/smitpatel/followers","following_url":"https://api.github.com/users/smitpatel/following{/other_user}","gists_url":"https://api.github.com/users/smitpatel/gists{/gist_id}","starred_url":"https://api.github.com/users/smitpatel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smitpatel/subscriptions","organizations_url":"https://api.github.com/users/smitpatel/orgs","repos_url":"https://api.github.com/users/smitpatel/repos","events_url":"https://api.github.com/users/smitpatel/events{/privacy}","received_events_url":"https://api.github.com/users/smitpatel/received_events","type":"User","site_admin":false},"created_at":"2017-12-01T04:32:45Z","updated_at":"2017-12-01T04:32:45Z","author_association":"CONTRIBUTOR","body":"I will be fixing making sure that `SelectExpression._starProjections` is accurate enough for all cases. Removing all star projection does not seem best idea because of smaller SQL with * projection. So eventually all the cases where explicit listing of columns needed like #10433 EF or provider could expand star projection into list. It would be similar to xmin scenario but xmin is provider specific and postgre would need to identify the case and do the necessary thing. There could be 2 ways to achieve it. 1. When translating xmin column when it is added to projection, if it is coming from star projection then expand star. This would make the SelectExpression in correct syntax all the time.\r\n2. Another easier way could be to expand once whole query is translated at the end. Plumbing for this would be really easy (just like `JoinEliminator`). Though SelectExpression at intermediate state would be some invalid sql (but we don't run it anyway).\r\n\r\nYou can fix it in postgre at anytime. I would be fixing the binding issue next week. If you can wait till then. 😄 \r\n\r\n"}}
{"actor":{"display_login":"smitpatel"}}