From: | Jeroen van Dongen <jeroen(at)jkwadraat(dot)net> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Possible bug in PL/Python? |
Date: | 2012-01-17 16:27:19 |
Message-ID: | CAH-c8MpdK24oT8DFL=53kvYw0r1ZrRKyZUMUum7oGEegp0autw@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hi,
In a current project I've a PL/Python function that uses default
parameters, like this:
CREATE FUNCTION auth.create_user(
email text,
initial_password text,
display_name text DEFAULT NULL,
mobile_phone text DEFAULT NULL,
status auth.enum_user_status DEFAULT 'active'
) RETURNS text AS $$
... rest of function ...
Now I try to test if 'display_name' is actually passed or not, and if not
set it to something sensible, like so:
...
if display_name is None:
display_name = email[:email.find('@')]
...
And ... that fails with an error stating that 'display_name' is referenced
before assignment.
However, if I do it like this, it works:
...
if display_name is None:
real_display_name = email[:email.find('@')]
...
In straight Python the first example works, however in PL/Python only the
second works.
Is this how it is supposed to be and did I perhaps miss something in the
docs, or is it a bug?
Kind regards,
Jeroen
From | Date | Subject | |
---|---|---|---|
Next Message | Adrian Klaver | 2012-01-17 16:40:38 | Re: Possible bug in PL/Python? |
Previous Message | Tom Lane | 2012-01-17 15:03:23 | Re: PostgreSQL counterpart to DBMS_METADATA? |