{"action":"opened","issue":{"url":"https://api.github.com/repos/npgsql/EntityFramework6.Npgsql/issues/27","repository_url":"https://api.github.com/repos/npgsql/EntityFramework6.Npgsql","labels_url":"https://api.github.com/repos/npgsql/EntityFramework6.Npgsql/issues/27/labels{/name}","comments_url":"https://api.github.com/repos/npgsql/EntityFramework6.Npgsql/issues/27/comments","events_url":"https://api.github.com/repos/npgsql/EntityFramework6.Npgsql/issues/27/events","html_url":"https://github.com/npgsql/EntityFramework6.Npgsql/issues/27","id":154487189,"number":27,"title":"Postgre can't detect type from const strings (add ::text)","user":{"login":"roji","id":1862641,"avatar_url":"https://avatars.githubusercontent.com/u/1862641?v=3","gravatar_id":"","url":"https://api.github.com/users/roji","html_url":"https://github.com/roji","followers_url":"https://api.github.com/users/roji/followers","following_url":"https://api.github.com/users/roji/following{/other_user}","gists_url":"https://api.github.com/users/roji/gists{/gist_id}","starred_url":"https://api.github.com/users/roji/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/roji/subscriptions","organizations_url":"https://api.github.com/users/roji/orgs","repos_url":"https://api.github.com/users/roji/repos","events_url":"https://api.github.com/users/roji/events{/privacy}","received_events_url":"https://api.github.com/users/roji/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/npgsql/EntityFramework6.Npgsql/labels/bug","name":"bug","color":"ee0701"},{"url":"https://api.github.com/repos/npgsql/EntityFramework6.Npgsql/labels/ef6","name":"ef6","color":"ededed"}],"state":"open","locked":false,"assignee":{"login":"Emill","id":1660778,"avatar_url":"https://avatars.githubusercontent.com/u/1660778?v=3","gravatar_id":"","url":"https://api.github.com/users/Emill","html_url":"https://github.com/Emill","followers_url":"https://api.github.com/users/Emill/followers","following_url":"https://api.github.com/users/Emill/following{/other_user}","gists_url":"https://api.github.com/users/Emill/gists{/gist_id}","starred_url":"https://api.github.com/users/Emill/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Emill/subscriptions","organizations_url":"https://api.github.com/users/Emill/orgs","repos_url":"https://api.github.com/users/Emill/repos","events_url":"https://api.github.com/users/Emill/events{/privacy}","received_events_url":"https://api.github.com/users/Emill/received_events","type":"User","site_admin":false},"milestone":null,"comments":0,"created_at":"2016-05-12T13:50:21Z","updated_at":"2016-05-12T13:50:21Z","closed_at":null,"body":"_From @smstuebe on October 27, 2015 9:55_\n\nWhen the Queries get complex, we often see `'0X0X'` in the SELECT statements.\r\nUnfortunately Postgre fails to detect the type of constants if the SELECTS are inner SELECTS. A simple description of this Problem: \r\nhttp://stackoverflow.com/questions/18073901/failed-to-find-conversion-function-from-unknown-to-text \r\n\r\nQuery from query log:\r\n```sql\r\nSELECT   \"Project2\".\"id\", \r\n         \"Project2\".\"C2\" AS \"C1\", \r\n         \"Project2\".\"C1\" AS \"C2\", \r\n         \"Project2\".\"description\", \r\n         \"Project2\".\"creation_date\", \r\n         \"Project2\".\"vehicle_brand_id\", \r\n         \"Project2\".\"country_variant_id\", \r\n         \"Project2\".\"hardware_variant_id\", \r\n         \"Project2\".\"type_id\", \r\n         \"Project2\".\"sop_date_id\", \r\n         \"Project2\".\"project_id\", \r\n         \"Project2\".\"release_date_id\", \r\n         \"Project2\".\"config\", \r\n         \"Project2\".\"released\", \r\n         \"Project2\".\"number_index\", \r\n         \"Project2\".\"deprecated\", \r\n         \"Project2\".\"field\", \r\n         \"Project2\".\"blocked\", \r\n         \"Project2\".\"link_teamforge\", \r\n         \"Project2\".\"link_infopool\", \r\n         \"Project2\".\"release_info\", \r\n         \"Project2\".\"release_info_short\", \r\n         \"Project2\".\"train_status\", \r\n         \"Project2\".\"created\", \r\n         \"Project2\".\"creator\", \r\n         \"Project2\".\"last_modified\", \r\n         \"Project2\".\"last_modifier\", \r\n         \"Project2\".\"name\", \r\n         \"Project2\".\"C3\", \r\n         \"Project2\".\"C5\" AS \"C4\", \r\n         \"Project2\".\"id1\", \r\n         \"Project2\".\"C4\" AS \"C5\", \r\n         \"Project2\".\"description1\", \r\n         \"Project2\".\"device_number_type\", \r\n         \"Project2\".\"kpmwebprnumber\", \r\n         \"Project2\".\"vehicle_brand_id1\", \r\n         \"Project2\".\"parent_id\", \r\n         \"Project2\".\"platform_id\", \r\n         \"Project2\".\"doors_name\", \r\n         \"Project2\".\"created1\", \r\n         \"Project2\".\"creator1\", \r\n         \"Project2\".\"last_modified1\", \r\n         \"Project2\".\"last_modifier1\", \r\n         \"Project2\".\"name1\" \r\nFROM     ( \r\n                         SELECT          \"Alias1\".\"id\", \r\n                                         \"Alias1\".\"description\", \r\n                                         \"Alias1\".\"creation_date\", \r\n                                         \"Alias1\".\"vehicle_brand_id\", \r\n                                         \"Alias1\".\"country_variant_id\", \r\n                                         \"Alias1\".\"hardware_variant_id\", \r\n                                         \"Alias1\".\"type_id\", \r\n                                         \"Alias1\".\"sop_date_id\", \r\n                                         \"Alias1\".\"project_id\", \r\n                                         \"Alias1\".\"release_date_id\", \r\n                                         \"Alias1\".\"config\", \r\n                                         \"Alias1\".\"released\", \r\n                                         \"Alias1\".\"number_index\", \r\n                                         \"Alias1\".\"deprecated\", \r\n                                         \"Alias1\".\"field\", \r\n                                         \"Alias1\".\"blocked\", \r\n                                         \"Alias1\".\"link_teamforge\", \r\n                                         \"Alias1\".\"link_infopool\", \r\n                                         \"Alias1\".\"release_info\", \r\n                                         \"Alias1\".\"release_info_short\", \r\n                                         \"Alias1\".\"train_status\", \r\n                                         \"Alias1\".\"created\", \r\n                                         \"Alias1\".\"creator\", \r\n                                         \"Alias1\".\"last_modified\", \r\n                                         \"Alias1\".\"last_modifier\", \r\n                                         \"Alias1\".\"name\", \r\n                                         \"Alias1\".\"C1\", \r\n                                         \"Alias1\".\"C2\", \r\n                                         \"Alias1\".\"C3\", \r\n                                         \"Extent3\".\"id\"          AS \"id1\", \r\n                                         \"Extent3\".\"description\" AS \"description1\", \r\n                                         \"Extent3\".\"device_number_type\", \r\n                                         \"Extent3\".\"kpmwebprnumber\", \r\n                                         \"Extent3\".\"vehicle_brand_id\" AS \"vehicle_brand_id1\",\r\n                                         \"Extent3\".\"parent_id\", \r\n                                         \"Extent3\".\"platform_id\", \r\n                                         \"Extent3\".\"doors_name\", \r\n                                         \"Extent3\".\"created\"       AS \"created1\", \r\n                                         \"Extent3\".\"creator\"       AS \"creator1\", \r\n                                         \"Extent3\".\"last_modified\" AS \"last_modified1\", \r\n                                         \"Extent3\".\"last_modifier\" AS \"last_modifier1\", \r\n                                         \"Extent3\".\"name\"          AS \"name1\", \r\n                                         CASE \r\n                                                         WHEN ( \r\n                                                                                         \"Extent2\".\"vehicle_id\" IS NULL) THEN (Cast (NULL AS TEXT))\r\n                                                         ELSE (e'bc1f6d3a-e7c0-4e64-a4a6-9238b7fb45bc') \r\n                                         END AS \"C4\", \r\n                                         CASE \r\n                                                         WHEN ( \r\n                                                                                         \"Extent2\".\"vehicle_id\" IS NULL) THEN (cast (NULL AS int4))\r\n                                                         ELSE (1) \r\n                                         END AS \"C5\" \r\n                         FROM            ( \r\n                                                  SELECT   \"Project1\".\"C1\", \r\n                                                           \"Project1\".\"id\", \r\n                                                           \"Project1\".\"description\", \r\n                                                           \"Project1\".\"creation_date\", \r\n                                                           \"Project1\".\"vehicle_brand_id\", \r\n                                                           \"Project1\".\"country_variant_id\", \r\n                                                           \"Project1\".\"hardware_variant_id\", \r\n                                                           \"Project1\".\"type_id\", \r\n                                                           \"Project1\".\"sop_date_id\", \r\n                                                           \"Project1\".\"project_id\", \r\n                                                           \"Project1\".\"release_date_id\", \r\n                                                           \"Project1\".\"config\", \r\n                                                           \"Project1\".\"released\", \r\n                                                           \"Project1\".\"number_index\", \r\n                                                           \"Project1\".\"deprecated\", \r\n                                                           \"Project1\".\"field\", \r\n                                                           \"Project1\".\"blocked\", \r\n                                                           \"Project1\".\"link_teamforge\", \r\n                                                           \"Project1\".\"link_infopool\", \r\n                                                           \"Project1\".\"release_info\", \r\n                                                           \"Project1\".\"release_info_short\", \r\n                                                           \"Project1\".\"train_status\", \r\n                                                           \"Project1\".\"created\", \r\n                                                           \"Project1\".\"creator\", \r\n                                                           \"Project1\".\"last_modified\", \r\n                                                           \"Project1\".\"last_modifier\", \r\n                                                           \"Project1\".\"name\", \r\n                                                           \"Project1\".\"C2\", \r\n                                                           \"Project1\".\"C3\" \r\n                                                  FROM     ( \r\n                                                                  SELECT \"Extent1\".\"id\", \r\n                                                                         \"Extent1\".\"description\",\r\n                                                                         \"Extent1\".\"creation_date\",\r\n                                                                         \"Extent1\".\"vehicle_brand_id\",\r\n                                                                         \"Extent1\".\"country_variant_id\",\r\n                                                                         \"Extent1\".\"hardware_variant_id\",\r\n                                                                         \"Extent1\".\"type_id\",\r\n                                                                         \"Extent1\".\"sop_date_id\",\r\n                                                                         \"Extent1\".\"project_id\",\r\n                                                                         \"Extent1\".\"release_date_id\",\r\n                                                                         \"Extent1\".\"config\", \r\n                                                                         \"Extent1\".\"released\",\r\n                                                                         \"Extent1\".\"number_index\",\r\n                                                                         \"Extent1\".\"deprecated\",\r\n                                                                         \"Extent1\".\"field\", \r\n                                                                         \"Extent1\".\"blocked\",\r\n                                                                         \"Extent1\".\"link_teamforge\",\r\n                                                                         \"Extent1\".\"link_infopool\",\r\n                                                                         \"Extent1\".\"release_info\",\r\n                                                                         \"Extent1\".\"release_info_short\",\r\n                                                                         \"Extent1\".\"train_status\",\r\n                                                                         \"Extent1\".\"created\",\r\n                                                                         \"Extent1\".\"creator\",\r\n                                                                         \"Extent1\".\"last_modified\",\r\n                                                                         \"Extent1\".\"last_modifier\",\r\n                                                                         \"Extent1\".\"name\", \r\n                                                                         e'0X0X'                           AS \"C1\",\r\n                                                                         e'bc1f6d3a-e7c0-4e64-a4a6-9238b7fb45bc' AS \"C2\", \r\n                                                                         e'Vehicles'                             AS \"C3\"\r\n                                                                  FROM   \"public\".\"train\"                        AS \"Extent1\"\r\n                                                                  WHERE  \"Extent1\".\"Discriminator\" = e'Train'\r\n                                                                  AND    \"Extent1\".\"config\" != true) AS \"Project1\"\r\n                                                  ORDER BY \"Project1\".\"id\" ASC limit 10) AS \"Alias1\"\r\n                         LEFT OUTER JOIN \"public\".\"vehicle_x_train\"                      AS \"Extent2\"\r\n                         INNER JOIN      \"public\".\"vehicle\"                              AS \"Extent3\"\r\n                         ON              \"Extent3\".\"id\" = \"Extent2\".\"vehicle_id\" \r\n                         ON \r\n                                         CASE \r\n                                                         WHEN ( \r\n                                                                                         \"Alias1\".\"C1\" LIKE e'0X%') THEN (\"Alias1\".\"id\")\r\n                                         END = \"Extent2\".\"train_id\") AS \"Project2\" \r\nORDER BY \"Project2\".\"id\" ASC , \r\n         \"Project2\".\"C5\" ASC\r\n```\r\n\r\nWhen I specifiy the type implicitly with changing the line\r\n```sql \r\ne'0X0X' AS \"C1\",\r\n```\r\nto\r\n```sql\r\ne'0X0X'::text AS \"C1\",\r\n```\r\nthe query is executed without any Problems.\r\n\r\nCould you implement explicit typing for this constants? Or is there already any solution for this? Where does this Hugs and Kisses '0X0X' come from? Is this a EF or a npgsql 'feature'?\r\n\r\nOur Environment:\r\nPostgre 9.4\r\nnpgSQL 3.0.3\r\nEntityFramework6.Npgsql 3.0.3\r\nEntityFramework 6.1.3\n\n_Copied from original issue: npgsql/npgsql#837_"}}