bigpresh / bigpresh/Dancer-Plugin-Database

Bug: Dancer::Plugin::Database does not accurately return the last insert id.

Open
#94 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Perl
Stars
39
Forks
36
PR merge metrics
No merged PRs in 30d

Description

Self contained testcase attached.
Issue: database->last_insert_id(undef,undef,undef,$table) does not consistently return the last insert id value.
In the attached testcase and log, I am calling last_insert_id in 4 different tests.

1. The first two are via dancer routes using database.... which fail
2. The third is via direct sql inside a dancer route which passes and
3. The final is via direct SQL outside Dancer which also passes..
------------------------------------------
# Looks like you failed 2 tests of 5.
t/006_million_inserts.t ..
ok 1 - Got app
not ok 2 - Dancer Database Plugin with SQL Insert
not ok 3 - Dancer Database Plugin with quick_insert
ok 4 - Dancer DBI SQL Test
ok 5 - DBI Test
--------------------------------

Sample Failure message
[App:21638] info @2017-11-04 15:00:56> recieved Last insert ID as 175 in t/006_million_inserts.t l. 36
[App:21638] debug @2017-11-04 15:00:56> Executing INSERT query INSERT INTO `test` (`count`) VALUES (?) with params 175 in /opt/perl5/perls/perl-5.26.1/lib/site_perl/5.2
6.1/Dancer2/Plugin.pm l. 533
[App:21638] info @2017-11-04 15:00:56> recieved Last insert ID as 176 in t/006_million_inserts.t l. 36
[App:21638] debug @2017-11-04 15:00:56> Executing INSERT query INSERT INTO `test` (`count`) VALUES (?) with params 176 in /opt/perl5/perls/perl-5.26.1/lib/site_perl/5.2
6.1/Dancer2/Plugin.pm l. 533
[App:21638] info @2017-11-04 15:00:57> recieved Last insert ID as 0 in t/006_million_inserts.t l. 36
[App:21638] debug @2017-11-04 15:00:57> Executing INSERT query INSERT INTO `test` (`count`) VALUES (?) with params 0 in /opt/perl5/perls/perl-5.26.1/lib/site_perl/5.26.
1/Dancer2/Plugin.pm l. 533
[App:21638] core @2017-11-04 15:00:57> Entering hook plugin.database.database_error in (eval 222) l. 1
DBD::mysql::db do failed: Duplicate entry '0' for key 'test_UNIQUE' at /opt/perl5/perls/perl-5.26.1/lib/site_perl/5.26.1/Dancer/Plugin/Database/Core/Handle.pm line 310.

Test and log attached.

[test.zip](https://github.com/bigpresh/Dancer-Plugin-Database/files/1443103/test.zip)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.