Skip to content
  • Arturo Pie's avatar
    3980465f
    #7914 get default value when type uses schema name · 3980465f
    Arturo Pie authored
    PostgreSQL adapter properly parses default values when using multiple
    schemas and domains.
    
    When using domains across schemas, PostgresSQL prefixes the type of the
    default value with the name of the schema where that type (or domain) is.
    
    For example, this query:
    ```
    SELECT a.attname, d.adsrc
    FROM pg_attribute a LEFT JOIN pg_attrdef d
    ON a.attrelid = d.adrelid AND a.attnum = d.adnum
    WHERE a.attrelid = "defaults"'::regclass
    AND a.attnum > 0 AND NOT a.attisdropped
    ORDER BY a.attnum;
    ```
    
    could return something like "'<default_value>'::pg_catalog.text" or
    "(''<default_value>'::pg_catalog.text)::text" for the text columns with
    defaults.
    
    I modified the regexp used to parse this value so that it ignores
    anything between ':: and \b(?:character varying|bpchar|text), and it
    allows to have optional parens like in the above second example.
    3980465f
    #7914 get default value when type uses schema name
    Arturo Pie authored
    PostgreSQL adapter properly parses default values when using multiple
    schemas and domains.
    
    When using domains across schemas, PostgresSQL prefixes the type of the
    default value with the name of the schema where that type (or domain) is.
    
    For example, this query:
    ```
    SELECT a.attname, d.adsrc
    FROM pg_attribute a LEFT JOIN pg_attrdef d
    ON a.attrelid = d.adrelid AND a.attnum = d.adnum
    WHERE a.attrelid = "defaults"'::regclass
    AND a.attnum > 0 AND NOT a.attisdropped
    ORDER BY a.attnum;
    ```
    
    could return something like "'<default_value>'::pg_catalog.text" or
    "(''<default_value>'::pg_catalog.text)::text" for the text columns with
    defaults.
    
    I modified the regexp used to parse this value so that it ignores
    anything between ':: and \b(?:character varying|bpchar|text), and it
    allows to have optional parens like in the above second example.
Loading