summaryrefslogtreecommitdiff
path: root/util/sqleditfunc.pl
diff options
context:
space:
mode:
Diffstat (limited to 'util/sqleditfunc.pl')
-rwxr-xr-xutil/sqleditfunc.pl15
1 files changed, 6 insertions, 9 deletions
diff --git a/util/sqleditfunc.pl b/util/sqleditfunc.pl
index e18adde4..59558822 100755
--- a/util/sqleditfunc.pl
+++ b/util/sqleditfunc.pl
@@ -1,9 +1,7 @@
#!/usr/bin/perl
-use strict;
-use warnings;
+use v5.28;
use List::Util 'any';
-
use Cwd 'abs_path';
our $ROOT;
BEGIN { ($ROOT = abs_path $0) =~ s{/util/sqleditfunc\.pl$}{}; }
@@ -19,7 +17,7 @@ sub gensql {
# table_name_without_hist => [ column_names_without_chid ]
my %ts = map
- +($_, [ map "\"$_->{name}\"", grep $_->{name} !~ /^chid$/, @{$schema->{"${_}_hist"}{cols}} ]),
+ +($_, [ map $_->{name}, grep $_->{name} !~ /^chid$/, @{$schema->{"${_}_hist"}{cols}} ]),
map /^${item}_/ && /^(.+)_hist$/ ? $1 : (), keys %$schema;
my %replace = ( item => $item, itemtype => $schema->{$item}{dbentry_type} );
@@ -52,9 +50,8 @@ sub gensql {
}
-open my $F, '>', "$ROOT/sql/editfunc.sql" or die $!;
-print $F "-- Automatically generated by util/sqleditfunc.pl. DO NOT EDIT.\n";
-print $F gensql $_ for sort grep $schema->{$_}{dbentry_type}, keys %$schema;
+print "-- Automatically generated by util/sqleditfunc.pl. DO NOT EDIT.\n";
+print gensql $_ for sort grep $schema->{$_}{dbentry_type}, keys %$schema;
__DATA__
@@ -96,8 +93,8 @@ BEGIN
INSERT INTO {item} DEFAULT VALUES RETURNING id INTO nitemid;
END IF;
-- insert change
- INSERT INTO changes (itemid, rev, requester, ip, comments, ihid, ilock)
- SELECT nitemid, nrev, requester, ip, comments, ihid, ilock FROM edit_revision RETURNING id INTO nchid;
+ INSERT INTO changes (itemid, rev, requester, comments, ihid, ilock)
+ SELECT nitemid, nrev, requester, comments, ihid, ilock FROM edit_revision RETURNING id INTO nchid;
-- insert data
{copyfromtemp}
{copymainfromtemp}