Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Error inserting data into DB #30

pajooh opened this Issue May 21, 2012 · 9 comments


None yet
3 participants

pajooh commented May 21, 2012

when i run doctrine:phpcr:register-system-node-types, i get:

SQLSTATE[22P02]: Invalid text representation: 7 ERROR:  invalid input syntax for integer: ""  

the strange statement sent to database is (see the VALUES part)

INSERT INTO phpcr_type_props (node_type_id, name, protected, mandatory, auto_created, on_parent_version, multiple, fulltext_searchable, query_orderable, required_type, query_operators, default_value) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12)

here is the exception trace:

at ./vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php:754
PDOStatement->execute() at ./vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php:754
Doctrine\DBAL\Connection->executeUpdate() at ./vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php:525
Doctrine\DBAL\Connection->insert() at ./vendor/jackalope/jackalope-doctrine-dbal/src/Jackalope/Transport/DoctrineDBAL/Client.php:1507
Jackalope\Transport\DoctrineDBAL\Client->registerNodeTypes() at ./vendor/jackalope/jackalope/src/Jackalope/ObjectManager.php:597
Jackalope\ObjectManager->registerNodeTypes() at ./vendor/jackalope/jackalope/src/Jackalope/NodeType/NodeTypeManager.php:353
Jackalope\NodeType\NodeTypeManager->registerNodeTypes() at ./vendor/jackalope/jackalope/src/Jackalope/NodeType/NodeTypeManager.php:318
Jackalope\NodeType\NodeTypeManager->registerNodeType() at ./vendor/doctrine/phpcr-odm/lib/Doctrine/ODM/PHPCR/Tools/Console/Command/RegisterSystemNodeTypesCommand.php:77
Doctrine\ODM\PHPCR\Tools\Console\Command\RegisterSystemNodeTypesCommand->execute() at ./vendor/doctrine/phpcr-bundle/Doctrine/Bundle/PHPCRBundle/Command/RegisterSystemNodeTypesCommand.php:50
Doctrine\Bundle\PHPCRBundle\Command\RegisterSystemNodeTypesCommand->execute() at ./vendor/symfony/symfony/src/Symfony/Component/Console/Command/Command.php:239
Symfony\Component\Console\Command\Command->run() at ./vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:193
Symfony\Component\Console\Application->doRun() at ./vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php:77
Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at ./vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:106
Symfony\Component\Console\Application->run() at ./app/console:22

lsmith77 commented May 21, 2012

currently the functional tests only run against mysql. however at least in theory PostgreSQL support is in place, so we should modify our .travis.yml to also run against PostgreSQL.

could you look into this?

here is an example of how to run the tests against multiple databases:

if you need help there is someone around most of the day on freenode IRC in #jackalope and #travis


lsmith77 commented May 21, 2012

now to fix the issue .. not sure if we need to add manual type casting in places like this?


lsmith77 commented May 22, 2012

hmm no .. the error must be that we don't get an integer value returned from https://github.com/jackalope/jackalope-doctrine-dbal/blob/master/src/Jackalope/Transport/DoctrineDBAL/Client.php#L1474


dbu commented May 22, 2012

is it possible that the sequence name change of #29 was incomplete? maybe some sanity checks in this code could be a good thing, to throw exceptions early if something went not as expected.

/cc @adou600 (not exactly what you are currently doing, but could affect you maybe)


pajooh commented May 23, 2012

the problem is about lastInsertId, see some Note from documentation of Doctrine DBAL:

This method may not return a meaningful or consistent result across different drivers,
because the underlying database may not even support the notion of AUTO_INCREMENT/IDENTITY
columns or sequences.

as far as i know, Postgresql driver does not support that

also see #31


lsmith77 commented May 23, 2012

hmm i thought by passing the sequence name it should work reliably.


lsmith77 commented May 23, 2012

here is a chat log:

[23:10 ] <lsmith> beberlei: hmm i have a question of lastInsertId() with PostgreSQL
[23:11 ] <lsmith> if i pass in a sequence name as a parameter
[23:11 ] <lsmith> shouldnt it work as expected?
[23:11 ] <lsmith> https://github.com/jackalope/jackalope-doctrine-dbal/issues/30
[23:13 ] <lsmith> https://github.com/jackalope/jackalope-doctrine-dbal/blob/master/src/Jackalope/Transport/DoctrineDBAL/Client.php#L1474
[23:13 ] <lsmith> https://github.com/jackalope/jackalope-doctrine-dbal/blob/master/src/Jackalope/Transport/DoctrineDBAL/Client.php#L142
[23:14 ] <lsmith> https://github.com/jackalope/jackalope-doctrine-dbal/blob/master/src/Jackalope/Transport/DoctrineDBAL/RepositorySchema.php#L70
[23:14 ] <beberlei> i added a test yesterday in dbal which shows it working
[23:14 ] <lsmith> is array('autoincrement' => true) wrong .. and we need to use something else ?
[23:20 ] <beberlei> autoincrement true is wrong
[23:20 ] <beberlei> that makes a SERIAL column out of it
[23:21 ] <beberlei> in that case you dont need sequence handling anymore
[23:21 ] <beberlei> serial is integer + pre insert trigger + sequence
[23:32 ] <lsmith> beberlei: hmm .. didnt you write that code? :)
[23:32 ] <lsmith> so what is the best approach here .. ?
[23:32 ] <lsmith> i just remove the manual sequence code and be done with it ?
[23:33 ] <beberlei> hm.
[23:33 ] <beberlei> test it i would say :)
[23:36 ] <lsmith> :)

lsmith77 commented Jun 2, 2012

are you still interested in working on this?


lsmith77 commented Jul 9, 2012

fixed with #44

@lsmith77 lsmith77 closed this Jul 9, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment