[ 
https://issues.apache.org/jira/browse/OPENJPA-3018?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Richard Zowalla reassigned OPENJPA-3018:
----------------------------------------

    Assignee: Richard Zowalla

> Size appended to a JSON or JSONB column definition on PostgreSQL, MySQL and 
> MariaDB
> -----------------------------------------------------------------------------------
>
>                 Key: OPENJPA-3018
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-3018
>             Project: OpenJPA
>          Issue Type: Bug
>    Affects Versions: 4.1.1
>            Reporter: Richard Zowalla
>            Assignee: Richard Zowalla
>            Priority: Major
>
> A column declared with {{columnDefinition}} (or {{column-definition}} in a 
> mapping file) of type {{jsonb}} on PostgreSQL, or {{json}} on MySQL and 
> MariaDB, gets the column length appended in the generated DDL. For a 
> {{String}} column the default length is 255, so the schema tool emits 
> {{jsonb(255)}} and the database rejects the statement:
> {noformat}
> org.apache.openjpa.lib.jdbc.ReportingSQLException: ERROR: type modifier is 
> not allowed for type "jsonb"
> CREATE TABLE AnyObject (id VARCHAR(36) NOT NULL, ..., plainAttrs jsonb(255), 
> ...)
> {noformat}
> {{DBDictionary.getTypeName(Column)}} passes the column definition through 
> {{appendSize()}}, which appends the size unless the type name is in 
> {{fixedSizeTypeNameSet}}. {{PostgresDictionary}} does not list {{JSON}} or 
> {{JSONB}}, and {{MySQLDictionary}} and {{MariaDBDictionary}} do not list 
> {{JSON}}. None of these types takes a length.
> Reported on PR #220 by Francesco Chicchiriccò while testing Apache Syncope 
> master against 4.2.0-SNAPSHOT, with this mapping:
> {code:xml}
> <basic name="plainAttrs">
>   <column column-definition="jsonb"/>
> </basic>
> {code}
> Syncope 3.x did not hit this because its mapping also declared {{<lob/>}}, 
> which sets the size to -1.
> Workaround: {{openjpa.jdbc.DBDictionary=postgres(FixedSizeTypeNames=JSONB)}}.
> Fix: add {{JSON}} and {{JSONB}} to the fixed size type names of 
> {{PostgresDictionary}}, and {{JSON}} to those of {{MySQLDictionary}} and 
> {{MariaDBDictionary}}.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to