I have a postgresql database with postGIS, and I am using the framework entity with dotconnect 6.7 for postgreSQL.
With the following table in my database:
CREATE TABLE geo ( the_geom geometry, id integer NOT NULL, CONSTRAINT primary_key PRIMARY KEY (id), CONSTRAINT enforce_srid_geometry CHECK (st_srid(the_geom) = 4326) )
and execute the following code
class Program { static void Main(string[] args) { using (test_Model.test_Entities ctx = new test_Model.test_Entities()) { var geom = new test_Model.geo(); geom.id = 0; geom.the_geom = DbGeometry.PointFromText("POINT (1 1)", 4326).AsBinary(); ctx.geos.AddObject(geom); ctx.SaveChanges(); } }
in the database
The following restriction does not apply:
CONSTRAINT enforce_srid_the_geom CHECK (st_srid(the_geom) = 4326)
Curious what value the database registered, I tried to have the following two limitations
CONSTRAINT enforce_srid_the_geom CHECK(st_srid(the_geom) > 4326) CONSTRAINT enforce_srid_the_geom CHECK(st_srid(the_geom) < 4326)
None of them worked. Since they are compared with integer values, at least one of the last three queries must be true.
After some time, I found that the following restriction allows me to insert something with srid = 4326 into the table
st_srid(the_geom) <= 4326)
but apparently, for some reason, it accepts everything, both large and smaller srids.
Is this a bug in postgresql, entity framework, or dotconnect?
Edit: Request
SELECT st_srid(the_geom) FROM geo WHERE geo.id == 0
returns srid 0. Thus, no matter what srid parameter I specify in the entity infrastructure, it is displayed as 0 in the database. What's happening?