I am creating a point geometries in a view from an x,y column in a postgresql/postgis table.
I do:
create or replace view my_points as
select
ST_SetSRID(ST_MakePoint(geo.x,geo.y), 2154) as geom,
pg_typeof(geom) as type
from table1
join table2 geo on table1.id = geo.id
Everything works fine in postgresql and I can see that this returns a view with a geometry in the column geom. Just for the sake of checking the type there is a second column type that checks if the format of geom is a geometry.
Now when I am in QGIS and try to bring the view in my layer list the following message appears:
Layer is not valid: The layer dbname='x' host=x port=5432 user='x' password='x' sslmode=x key='geom' srid=2154 type=POINT table="public"."my_points" (geom) sql= is not a valid layer and can not be added to the map
What is happening? Is not possible to create a geom in a query to be imported in QGIS?
ps: I use QGIS 2.8.1