Skip to content

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

Description

@jahagirdar

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

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions