[DBAL-1291] In PostgreSqlSchemaManager::_getPortableTableColumnDefinition Regex for nextval/sequence does not match Created: 03/Sep/15  Updated: 03/Sep/15

Status: Open
Project: Doctrine DBAL
Component/s: Schema Managers
Affects Version/s: 2.5.1
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: Jason B Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: postgresql

PostgreSQL 9.2.13


I ran into a schema that was showing the default value for a nextval as:

  "default" => "nextval(('tablename_id_seq'::text)::regclass)"
           Column           |       Type       |                     Modifiers
 id                         | bigint           | default nextval(('tablename_id_seq'::text)::regclass)

There seems to be an extra set of parentheses. I'm not sure how or why they're showing the extra set of parentheses. As far as I can tell the table column was created with BIGSERIAL. This table/schema could have originally been created in an older version of PostgreSQL.

I am suggesting we loosen up the regex to detect sequences/autoincrement


        if (preg_match("/^nextval\('(.*)'(::.*)?\)$/", $tableColumn['default'], $matches)) {


        if (preg_match("/^nextval\({1,2}'(.*)'(::.*)?\)$/", $tableColumn['default'], $matches)) {

This will match 1 or 2 open parentheses.

Generated at Fri Sep 04 17:14:58 EDT 2015 using JIRA 6.4.10#64025-sha1:5b8b74079161cd76a20ab66dda52747ee6701bd6.