Subject: | DBIx::SearchBuilder::Handle::Pg - No longer finds sequences for 7.3.x PostgreSQL |
As of version 1.42 (not sure if this is the case for version before
this, but it definitely works in 1.38) the
DBIx::SearchBuilder::Handle::Pg->IdSequenceName can no longer find
sequences in the 7.3.x (and possibly 7.4.x) versions of PostgreSQL.
The culprit seems to be that the regex to determine if a column is a
sequence (on line 240 (v 1.38) or 241 (v. 1.42)) changed from and (to):
v. 1.38: m!^nextval\('"?([^"']+)"?'::(?:text|regclass)\)!i
v. 1.42: m!^nextval\(\('"?([^"']+)"?'::(?:text|regclass)\).*\)!i
I assume this was to support the change in PostgreSQL's response, which was:
v. 7.3.11: id: nextval('principals_id_seq'::text)
v. 8.1.1: id: nextval(('principals_id_seq'::text)::regclass)
Unfortunately.. the new regex breaks support for the older version of
PostgreSQL!
I think (and have tested on Pg 7.3.11 and 8.1.1) that the following
regex will work on both:
m!^nextval\(?\('"?([^"']+)"?'::(?:text|regclass)\).*\)?!i
but it is possible, this'll break for some other version, or be too
permissive.
Just for comparison:
current: m!^nextval\(\('"?([^"']+)"?'::(?:text|regclass)\).*\)!i
proposed: m!^nextval\(?\('"?([^"']+)"?'::(?:text|regclass)\).*\)?!i
I just added the two ? so that it'll match both the
(('yada'::text)::regclass) and the older ('yada'::text).
Thanks!