Re: Postgres / plpgsql equivalent to python's getattr() ?
От
Hannu Krosing
Тема
Re: Postgres / plpgsql equivalent to python's getattr() ?
Дата
Msg-id
1312466425.4917.21.camel@hvost
Ответ на
Список
Дерево обсуждения
Postgres / plpgsql equivalent to python's getattr() ? James Robinson <jlrobins@socialserve.com>
Re: Postgres / plpgsql equivalent to python's getattr() ? Tom Lane <tgl@sss.pgh.pa.us>
Re: Postgres / plpgsql equivalent to python's getattr() ? Hannu Krosing <hannu@2ndQuadrant.com>
Re: Postgres / plpgsql equivalent to python's getattr() ? Florian Pflug <fgp@phlo.org>
Re: Postgres / plpgsql equivalent to python's getattr() ? James Robinson <jlrobins@socialserve.com>
Re: Postgres / plpgsql equivalent to python's getattr() ? Pavel Stehule <pavel.stehule@gmail.com>
Re: Postgres / plpgsql equivalent to python's getattr() ? Merlin Moncure <mmoncure@gmail.com>
On Wed, 2011-08-03 at 18:48 -0400, Tom Lane wrote: > James Robinson writes: > > Python's getattr() allows for dynamic lookup of attributes on an > > object, as in: > > > inst = MyClass(x=12, y=24) > > v = getattr(inst, 'x') > > assert v == 12 > > > Oftentimes in writing data validating trigger functions, it'd be real > > handy to be able to do a similar thing in plpgsql > > > Is there something in the internals which inherently prevent this? > > plpgsql is strongly typed (much more so than python, anyway). For example the plpgsql type RECORD is about as strongly typed as (some) python classes , that is once assigned the record itself is typed, but the same variable can point to different record types -- ------- Hannu Krosing PostgreSQL Infinite Scalability and Performance Consultant PG Admin Book: http://www.2ndQuadrant.com/books/
В списке pgsql-hackers по дате отправления
От: Hannu Krosing
Дата:
От: James Robinson
Дата: