From 8a47d8320876599924e73a75a33c8fe3d20dc163 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Sun, 11 Feb 2018 14:00:34 +0100 Subject: bin/db-update: fix mysql expression - tables should have distinct names --- bin/db-update | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'bin/db-update') diff --git a/bin/db-update b/bin/db-update index 9662ec4..f5ec07a 100755 --- a/bin/db-update +++ b/bin/db-update @@ -329,15 +329,19 @@ move_packages() { while read -r package; do while read -r part; do printf 'UPDATE `binary_packages`' - printf ' JOIN `repositories` ON `binary_packages`.`repository`=`repositories`.`id`' + printf ' JOIN `repositories` AS `from_repo` ON `binary_packages`.`repository`=`from_repo`.`id`' printf ' JOIN `architectures` ON `binary_packages`.`architecture`=`architectures`.`id`' - printf ' SET `binary_packages`.`repository`=(SELECT `repositories`.`id` FROM `repositories` WHERE `repositories`.`name`=from_base64("%s"))' \ - "$( - base64_encode_each < \ - "${tmp_dir}/tmp/${package}.to_repo" - )" + printf ' SET `binary_packages`.`repository`=(' + printf 'SELECT `to_repo`.`id`' + printf ' FROM `repositories` as `to_repo`' + printf ' WHERE `to_repo`.`name`=from_base64("%s")' \ + "$( + base64_encode_each < \ + "${tmp_dir}/tmp/${package}.to_repo" + )" + printf ')' printf ' WHERE' - printf ' `repositories`.`name`=from_base64("%s")' \ + printf ' `from_repo`.`name`=from_base64("%s")' \ "$( base64_encode_each < \ "${tmp_dir}/tmp/${package}.from_repo" -- cgit v1.2.3-70-g09d2