| Summary: | DBI->last_insert_id does not work as expected | ||
|---|---|---|---|
| Product: | Koha | Reporter: | Jonathan Druart <jonathan.druart> | 
| Component: | Architecture, internals, and plumbing | Assignee: | Bugs List <koha-bugs> | 
| Status: | NEW --- | QA Contact: | Testopia <testopia> | 
| Severity: | normal | ||
| Priority: | P5 - low | CC: | dcook, julian.maurice, m.de.rooy, tomascohen | 
| Version: | unspecified | ||
| Hardware: | All | ||
| OS: | All | ||
| See Also: | https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=20562 | ||
| GIT URL: | Initiative type: | --- | |
| Sponsorship status: | --- | Crowdfunding goal: | 0 | 
| Patch complexity: | --- | Documentation contact: | |
| Documentation submission: | Text to go in the release notes: | ||
| Version(s) released in: | Circulation function: | ||
| I do not have time to investigate this right now, but there is something scary. It could lead to very bad side-effects. Sounds like the only place it is buggy is t/db_dependent/Circulation/issue.t No problematic occurrences found in controllers or modules. From DBI POD: """ * For some drivers the $catalog, $schema, $table, and $field parameters are required, for others they are ignored (e.g., mysql). """ (In reply to Jonathan Druart from comment #3) > From DBI POD: > > """ > * For some drivers the $catalog, $schema, $table, and $field parameters are > required, for others they are ignored (e.g., mysql). > """ Sounds like it's not an issue then? Shouldn't we then remove the parameters? (In reply to Jonathan Druart from comment #5) > Shouldn't we then remove the parameters? Ahh I didn't realize we were using them. Yeah that would make sense. | 
Try the following code: use Koha::Database; use Koha::Cities; use Koha::AuthorisedValues; my $schema = Koha::Database->schema; $schema->storage->txn_begin; my $dbh = C4::Context->dbh; my $city = Koha::City->new({ city_name => 'name' })->store; say $city->cityid; say $dbh->last_insert_id( undef, undef, 'cities', undef ); say $dbh->last_insert_id( undef, undef, 'not_exist', undef ); say "==="; my $av = Koha::AuthorisedValue->new({category => 'LOC', authorised_value => 'just_a_test'})->store; say $av->id; say $dbh->last_insert_id( undef, undef, 'authorised_values', undef ); say $dbh->last_insert_id( undef, undef, 'cities', undef ); say $dbh->last_insert_id( undef, undef, 'not_exist', undef ); It will display: 12 12 12 === 401 401 401 401