Download the PHP package fwolfsjaeger/doctrine-cockroachdb without Composer
On this page you can find all versions of the php package fwolfsjaeger/doctrine-cockroachdb. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download fwolfsjaeger/doctrine-cockroachdb
More information about fwolfsjaeger/doctrine-cockroachdb
Files in fwolfsjaeger/doctrine-cockroachdb
Package doctrine-cockroachdb
Short Description Doctrine DBAL CockroachDB Driver
License MIT
Homepage https://github.com/fwolfsjaeger/doctrine-cockroachdb
Informations about the package doctrine-cockroachdb
CockroachDB Driver
CockroachDB Driver is a Doctrine DBAL Driver and ORM patcher to handle incompatibilities with PostgreSQL.
Big Thanks To
- Lapay Group for their CockroachDB Doctrine driver, which this driver is based on
- media.monks for the idea to patch FQCNs using a composer script
- sweoggy for his contributions to use CockroachDB's built in SERIAL generator
CockroachDB Quick Setup Guide
Usage
Configuration
(Optional) Use modified BasicEntityPersister and SerialGenerator
For improved compatibility and performance we recommend you to override Doctrine ORM's default BasicEntityPersister with the custom one provided with this package. When using the custom BasicEntityPersister you can use CockroachDB's built in SERIAL generator for primary keys, which performs vastly better than Doctrine's recommended SequenceGenerator.
Overriding is done by adding the composer script DoctrineCockroachDB\\Composer\\PatchDoctrine::overrideBasicEntityPersister
to the composer.json
script sections post-install-cmd
and post-update-cmd
:
Then change your entities to use the SerialGenerator
provided by this package:
Finally, you should register the DoctrineCockroachDB\ORM\Listener\AddDefaultToSerialGeneratorListener
and
DoctrineCockroachDB\ORM\Listener\RemoveDefaultFromForeignKeysListener
(in that order)
to get proper default values for the identifiers using SerialGenerator when using Doctrine ORM.
Troubleshooting
ERROR: currval(): could not determine data type of placeholder $1
This is caused by using the IdentityGenerator as GenerateValue strategy and Doctrine ORM's default BasicEntityPersister
.
It is solved by using our custom BasicEntityPersister
and SerialGenerator
, see above for instructions.
Unit testing
Start an insecure single-node instance:
Connect to CockroachDB:
Create the user & database for the tests: