Insertion of geometric type column with column[0], column[1] and etc.

Поиск
Список
Период
Сортировка
От Marcelo Zabani
Тема Insertion of geometric type column with column[0], column[1] and etc.
Дата
Msg-id AANLkTi=1q1ye_yHb-1-CbEN34chJyjzvM4G=UiXHDRkC@mail.gmail.com
обсуждение исходный текст
Ответы Re: Insertion of geometric type column with column[0], column[1] and etc.  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: Insertion of geometric type column with column[0], column[1] and etc.  (Stephen Frost <sfrost@snowman.net>)
Список pgsql-hackers
I've been using postgresql with geometric types and I've been using NHibernate as an ORM solution.<br />The problem is
thatNHibernate can't map geometric data types to any kind of property of a class (not for insertions).<br /> I've (with
partialsuccess, as will be explained) mapped the desired column (in my case, a POINT pgsql type) by mapping from
column[0]and column[1].<br />I know I can do updates and selects using column[0] and column[1], but I can't do INSERTS
(atleast not if the column has a not-null constraint).<br /> The documentation doesn't say that insertions would work
(<a
href="http://www.postgresql.org/docs/9.0/interactive/functions-geometry.html">http://www.postgresql.org/docs/9.0/interactive/functions-geometry.html</a>),
soI'm not filing this as a bug report.<br /><br />However, with the huge popularity of ORM solutions and the complexity
ofdb-specific datatypes (geometric types in other dbs probably work differently), we can't really expect ORM software
todo all the mapping successfully (although projects such as Hibernate Spatial exist for java solutions, NHibernate
Spatialseems to be abandoned, and there are, of course, other ORM solutions for other platforms).<br /><br />While I
haveemphasized the POINT data type, it would be desirable that all types in pgsql could be accessed/updated/inserted
withthe array-analogy (or other analogy), so that we could easily map ANYTHING with ORM software these days.<br /><br
/>Also,just to note, if there isn't a not null constraint on the column, inserting with column[0] and column[1] will
inserta null value in that column.<br /><br /><b>The SQL to show what I mean:</b><br />postgres=# create table test
(coordinatesPOINT NOT NULL);<br /> CREATE TABLE<br />postgres=# insert into test (coordinates[0], coordinates[1])
values(1,2);<br />ERROR:  null value in column "coordinates" violates not-null constraint<br /><br /><b>And
then:</b><br/>postgres=# alter table test alter column coordinates drop not null;<br /> ALTER TABLE<br />postgres=#
insertinto test (coordinates[0], coordinates[1]) values (1,2);<br />INSERT 0 1<br />postgres=# select * from test where
coordinatesis null;<br /> coordinates<br />-------------<br /><br />(1 row)<br /><br /><i>* In the results above, the
blankline shows the null value (obviously)</i><br /> 

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Joseph Adams
Дата:
Сообщение: Re: Basic JSON support
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Insertion of geometric type column with column[0], column[1] and etc.