Bugzilla – Attachment 102277 Details for
Bug 25040
Problematic current_timestamp syntax generated by DBIx::Class::Schema::Loader
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 25040: Handle incorrect current_timestamp syntax
Bug-25040-Handle-incorrect-currenttimestamp-syntax.patch (text/plain), 2.67 KB, created by
Jonathan Druart
on 2020-04-02 09:22:06 UTC
(
hide
)
Description:
Bug 25040: Handle incorrect current_timestamp syntax
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2020-04-02 09:22:06 UTC
Size:
2.67 KB
patch
obsolete
>From 472dabbb60f9ea64f1a8d5b4a1bbbfdaebcd3118 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Thu, 2 Apr 2020 11:17:55 +0200 >Subject: [PATCH] Bug 25040: Handle incorrect current_timestamp syntax > >There is an incorrect current_timestamp syntax generated by DBIx::Class::Schema::Loader > >Caught by the changes made to Koha::Object->store by bug 23463 (especially 9c383aa286fee5a29c6f084873f2eb6644bad64f) > >154 elsif ( not defined $self->$col >155 && $columns_info->{$col}->{datetime_undef_if_invalid} ) >156 { >157 # timestamp >158 $self->_result()->set_column($col => $columns_info->{$col}->{default_value}); >159 } > >If a timestamp not null column does not have a value when store is called, the default value is set. >The expected default value is \"current_timestamp"(`git grep current_timestamp Koha/Schema/Result`) but for some reasons DBIx::Class::Schema::Loader sometimes generates "current_timestamp()" (certainly depending on versions of DBIx::Class::Schema::Loader and DBMS MySQL vs MariaDB) > >It ends up with an error on insert/update: > >DBD::mysql::st execute failed: Incorrect datetime value: 'current_timestamp()' > >This should be a temporary patch, the root of the problem should be >found and correct fixed. > >With this patch we want people to continue working with Koha until we investigate. > >Test plan: >Apply this change: >@ Koha/Schema/Result/Aqorder.pm:374 @ __PACKAGE__->add_columns( > { > data_type => "timestamp", > datetime_undef_if_invalid => 1, >- default_value => \"current_timestamp", >+ default_value => "current_timestamp()", > is_nullable => 0, > }, > "rrp", > >and run: >use Koha::Acquisition::Orders; >use t::lib::TestBuilder; >my $builder = t::lib::TestBuilder->new; >my $order = $builder->build_object({ class => 'Koha::Acquisition::Orders' }); >$order->timestamp(undef)->store; > >Without this patch you get an error >--- > Koha/Object.pm | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > >diff --git a/Koha/Object.pm b/Koha/Object.pm >index fde0fa9917..33f5e88492 100644 >--- a/Koha/Object.pm >+++ b/Koha/Object.pm >@@ -155,7 +155,9 @@ sub store { > && $columns_info->{$col}->{datetime_undef_if_invalid} ) > { > # timestamp >- $self->_result()->set_column($col => $columns_info->{$col}->{default_value}); >+ my $default_value = $columns_info->{$col}->{default_value}; >+ $default_value = \"current_timestamp" if $default_value eq "current_timestamp()"; >+ $self->_result()->set_column($col => $default_value); > } > } > } >-- >2.20.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 25040
:
102277
|
102339
|
102340
|
102341
|
102342
|
102343
|
102344
|
102345
|
102645
|
102696