Bugzilla – Attachment 102340 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: monkeypatch Schema::Loader for recent MariaDB
Bug-25040-monkeypatch-SchemaLoader-for-recent-Mari.patch (text/plain), 2.87 KB, created by
Martin Renvoize (ashimema)
on 2020-04-03 10:38:52 UTC
(
hide
)
Description:
Bug 25040: monkeypatch Schema::Loader for recent MariaDB
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2020-04-03 10:38:52 UTC
Size:
2.87 KB
patch
obsolete
>From 5993d465c81bb9121ebb7f8c5a8a40d1010cc511 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Fri, 3 Apr 2020 11:16:39 +0100 >Subject: [PATCH] Bug 25040: monkeypatch Schema::Loader for recent MariaDB > >Recent versions of MariaDB changed the output of 'DESCRIBE' for >timestamp columns with defaults from `CURRENT_TIMESTAMP` to >`current_timestamp()`. As such the code inside >DBIx::Class::Schema::Loader which catches such cases and outputs >`\"current_timestamp"` as a sensible cross platform default is missed >and this leads of inconsistent class files and bugs with out default >lookup code in Koha::Objects. > >This patch serves as a backport of the code I have submitted upstream >such that out developers can continue to use update_dbix_class_files.pl >to build their schema classes from the database and regardless of their >db server version get a consistently correct output. > >You will need Sub::Override (libsub-override-perl) after this patch to >use update_dbix_class_files. >--- > misc/devel/update_dbix_class_files.pl | 34 +++++++++++++++++++++++++++ > 1 file changed, 34 insertions(+) > >diff --git a/misc/devel/update_dbix_class_files.pl b/misc/devel/update_dbix_class_files.pl >index b89ec635a5..96817a4646 100755 >--- a/misc/devel/update_dbix_class_files.pl >+++ b/misc/devel/update_dbix_class_files.pl >@@ -20,6 +20,7 @@ > > use Modern::Perl; > >+use Sub::Override; > use DBIx::Class::Schema::Loader qw/ make_schema_at /; > > use Getopt::Long; >@@ -91,6 +92,39 @@ $db_name //= $db_defaults{name}; > $db_user //= $db_defaults{user}; > $db_passwd //= $db_defaults{passwd}; > >+# This is being upstreamed, but for now lets make sure whatever version of DBIx::Class::Schema::Loader you are using, >+# we will catch MariaDB current_timestamp() and convert it to \"current_timestamp" correctly. >+my $override = Sub::Override->new( >+ 'DBIx::Class::Schema::Loader::DBI::mysql::_extra_column_info', >+ sub { >+ no warnings 'uninitialized'; >+ my ( $self, $table, $col, $info, $dbi_info ) = @_; >+ my %extra_info; >+ >+ if ( $dbi_info->{mysql_is_auto_increment} ) { >+ $extra_info{is_auto_increment} = 1; >+ } >+ if ( $dbi_info->{mysql_type_name} =~ /\bunsigned\b/i ) { >+ $extra_info{extra}{unsigned} = 1; >+ } >+ if ( $dbi_info->{mysql_values} ) { >+ $extra_info{extra}{list} = $dbi_info->{mysql_values}; >+ } >+ if ( >+ ( not blessed $dbi_info) # isa $sth >+ && lc( $dbi_info->{COLUMN_DEF} ) =~ m/^current_timestamp/ >+ && lc( $dbi_info->{mysql_type_name} ) eq 'timestamp' >+ ) >+ { >+ >+ my $current_timestamp = 'current_timestamp'; >+ $extra_info{default_value} = \$current_timestamp; >+ } >+ >+ return \%extra_info; >+ } >+); >+ > if (! defined $db_name ) { > print "Error: \'db_name\' parameter is mandatory.\n"; > pod2usage(1); >-- >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