0 votes

Hi,
I have not find an option to add "jsonb" to a orm property.

What can I do?

/**
 * @ORM\Column(type="json_array", nullable=true, options={"jsonb"=true})
 */
private $value;
in Solved by (190 points)
recategorized by

Thanks for info. Can you please send link to documentation where is this property described? Thanks!

I cant found in doctrine documentation but It is supported doctrine/dbal v2.6+.
https://stackoverflow.com/questions/37317681/doctrine-orm-how-to-map-jsonb-yaml
https://github.com/doctrine/doctrine2/issues/5797

I have tested it and is working when i update the schema.

Note: the column is better to be "json" type https://www.doctrine-project.org/projects/doctrine-dbal/en/2.8/reference/types.html#json

/**
 * @ORM\Column(type="json", nullable=true, options={"jsonb"=true})
 */
private $value;

1 Answer

0 votes
Best answer

Ok, it seems like some inner hack ;-). But I believe it should be easy to add it.

Open Doctrine2.skipper.cfg.xml file available in your instalation directory (or create separate new configuration file as described here https://help.skipper18.com/expert-usage/customization/configuration-files/ )

and add following element

<attribute name="jsonb" type="true" help-text="" />

to

skipper-configuration / orm-configuration / attribute-types / struct[name="field"] / struct[name="options"]

it should be on line 130 in mentioned cfg file.

Final result should look something like this:

 <struct name="options" help-text="" help-url="http://doctrine-orm.readthedocs.io/en/latest/reference/annotations-reference.html#column">

 <attribute name="jsonb" type="true" help-text="" />

          <attribute name="fixed" type="bool" help-text="Boolean value to determine if the specified length of a string column should be fixed or varying (applies only for string/binary column and might not be supported by all vendors)." />
          <attribute name="comment" type="string" help-text="The comment of the column in the schema (might not be supported by all vendors)."/>
          <attribute name="collation" type="string" help-text="The collation of the column (only supported by Drizzle, Mysql, PostgreSQL>=9.1, Sqlite and SQLServer)."/>
          <attribute name="check" type="string" help-text="Adds a check constraint type to the column (might not be supported by all vendors)"/>
          <attribute name="version" type="string" help-text=""/>          
        </struct>
by Skipper developer (141k points)
selected by

Thx. It works :)

but you have a typo:
type="true"
to
type="bool"

Perfect, glad it's working.

And thanks for info about typo. I wrote it on my personal laptop without validating it ;-)