Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Error inserting data into DB #30

Closed
pajooh opened this Issue · 9 comments

3 participants

@pajooh

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

[PDOException]                                                                                
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
Owner

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:
https://github.com/travis-ci/travis-ci-php-example/blob/master/.travis.yml#L19

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

@lsmith77
Owner

now to fix the issue .. not sure if we need to add manual type casting in places like this?
https://github.com/jackalope/jackalope-doctrine-dbal/blob/master/src/Jackalope/Transport/DoctrineDBAL/Client.php#L1480

@lsmith77
Owner

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
Owner

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

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
Owner

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

@lsmith77
Owner

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
Owner

are you still interested in working on this?

@lsmith77
Owner

fixed with #44

@lsmith77 lsmith77 closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.