Skip to content

Error while processing poll answer #1086

Closed
@asafov

Description

@asafov

🐞 Bug Report

Required Information

? !
Operating system CentOS 7
PHP Telegram Bot version 0.62.00
PHP version 7.2.27
MySQL version 5.7.29-32 Percona
Update Method Webhook
Self-signed certificate no
RAW update (if available) {...}

Summary

PDOStatement::execute(): SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (kdt.tgbot_poll_answer, CONSTRAINT tgbot_poll_answer_ibfk_1 FOREIGN KEY (poll_id) REFERENCES tgbot_poll (id)) {"exception":"[object] (ErrorException(code: 0): PDOStatement::execute(): SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (kdt.tgbot_poll_answer, CONSTRAINT tgbot_poll_answer_ibfk_1 FOREIGN KEY (poll_id) REFERENCES tgbot_poll (id)) at "/vendor/longman/telegram-bot/src/DB.php:907)

  1. Primary key in table poll_answer is poll_id, seems, that right PK is poll_id + user_id

How to reproduce

Create new non-anonymous poll by sendPoll and answer by user in chat group.

Solution:

  1. Add user id to primary key
  2. Remove restrict for update

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions