update myorders
set content = jsonb_set(content, '{orders, initialTaskId}', to_jsonb(concat(ticket_id, ':', (select min(x.task_id) over (partition by x.ticket_id) from myorders x where x.ticket_id=ticket_id))::text), false)
where task_id = (select max(t.task_id) from myorders t where t.ticket_id=1792829)
ERROR: more than one row returned by a subquery used as an expression
Необходимо с использованием оконной функции получить следюущее
select *, min(x.task_id) over (partition by x.ticket_id) from myorders x
DO $$
DECLARE
arr int[] := array[1792829,1792830,1792831,1792832];
x int;
BEGIN
FOREACH x IN ARRAY arr
LOOP
update myorders
set content = jsonb_set(content, '{orders, initialTaskId}', to_jsonb((select t.content #>> '{orders, initialTaskId}' from myorders t where t.id = (select min(t.id) from myorders t where t.ticket_id=x))::text), false)
where id = (select max(t.id) from myorders t where t.ticket_id=x);
END LOOP;
END;
$$
update myorders
set content = jsonb_set(content, '{orders, initialTaskId}', to_jsonb((select t.content #>> '{orders, initialTaskId}' from myorders t where t.id = (select min(t.id) from myorders t where t.ticket_id=1792829))::text), false)
where id = (select max(t.id) from myorders t where t.ticket_id=1792829)
{orders, initialTaskId}
из минимального id и по тому же ключу заапдейтить значение у максимального id. возможно так будет проще? update myorders
set content = jsonb_set(content , '{orders, initialTaskId}', to_jsonb(concat(ticket_id, ':', (select min(xx.task_id) over (partition by ticket_id) from myorders xx limit 1))::text), false)
where id = (select max(t.id) from myorders t where t.ticket_id=1792829)
limit 1
так как select min(xx.task_id) over (partition by ticket_id) from myorders xx
возвращало 2 одинаковых значения(но возвращает то что нужно). id |ticket_id|task_id |mycontent
------+---------+--------+-------------------------------------------------
106849| 1792829|14709539|{"orders": {"initialTaskId": "1792829:14709539"}}
108057| 1792829|14740625|{"orders": {"initialTaskId": null}}
id |ticket_id|task_id |mycontent
------+---------+--------+-------------------------------------------------
106849| 1792829|14709539|{"orders": {"initialTaskId": "1792829:14709539"}}
108057| 1792829|14740625|{"orders": {"initialTaskId": "1792829:1"}}
id |ticket_id|task_id |mycontent
------+---------+--------+-------------------------------------------------
106849| 1792829|14709539|{"orders": {"initialTaskId": "1792829:14709539"}}
108057| 1792829|14740625|{"orders": {"initialTaskId": "1792829:14709539"}}
[AboutDialog]
Size=@Size(545 331)
[AddNewTorrentDialog]
Enabled=true
TopLevel=true
[Application]
FileLogger\Age=1
FileLogger\AgeType=1
FileLogger\Backup=true
FileLogger\DeleteOld=true
FileLogger\Enabled=true
FileLogger\MaxSizeBytes=66560
FileLogger\Path=/home/pi/.var/app/org.qbittorrent.qBittorrent/data/qBittorrent/logs
GUI\Notifications\TorrentAdded=false
[AutoRun]
OnTorrentAdded\Enabled=false
OnTorrentAdded\Program=
enabled=false
program=
[BitTorrent]
Session\AddExtensionToIncompleteFiles=true
Session\AnonymousModeEnabled=true
Session\BTProtocol=Both
Session\DefaultSavePath=/mnt/usbhd/Films
Session\Encryption=1
Session\ExcludedFileNames=
Session\GlobalMaxSeedingMinutes=1
Session\IgnoreLimitsOnLAN=true
Session\MaxConnectionsPerTorrent=20
Session\Port=42160
Session\Preallocation=true
Session\ProxyPeerConnections=false
Session\QueueingSystemEnabled=true
Session\uTPRateLimited=false
[Core]
AutoDeleteAddedTorrentFile=Never
[GUI]
ConfirmActions\PauseAndResumeAllTorrents=true
DownloadTrackerFavicon=false
Log\Enabled=false
MainWindow\FiltersSidebarWidth=120
[IPSubnetWhitelistOptionsDialog]
Size=@Size(360 450)
[LegalNotice]
Accepted=true
[MainWindow]
geometry=@ByteArray(\x1\xd9\xd0\xcb\0\x3\0\0\0\0\0\t\0\0\0\x2\0\0\x5^\0\0\x2\x99\0\0\0\t\0\0\0'\0\0\x5^\0\0\x2\x99\0\0\0\0\0\0\0\0\x5V\0\0\0\t\0\0\0'\0\0\x5^\0\0\x2\x99)
[Meta]
MigrationVersion=4
[Network]
Proxy\IP=
Proxy\OnlyForTorrents=false
Proxy\Password=
Proxy\Port=@Variant(\0\0\0\x85\0\x1)
Proxy\Type=None
Proxy\Username=
[OptionsDialog]
HorizontalSplitterSizes=123, 630
LastViewedPage=2
Size=@Size(779 591)
[Preferences]
Advanced\DisableRecursiveDownload=false
Advanced\EnableIconsInMenus=true
Advanced\RecheckOnCompletion=false
Advanced\TrayIconStyle=Normal
Advanced\confirmRemoveAllTags=true
Advanced\confirmTorrentDeletion=true
Advanced\confirmTorrentRecheck=true
Advanced\trackerPort=9000
Advanced\trackerPortForwarding=false
Advanced\useSystemIconTheme=false
Connection\ResolvePeerCountries=true
Connection\ResolvePeerHostNames=false
Downloads\DblClOnTorDl=0
Downloads\DblClOnTorFn=1
Downloads\ScanDirsLastPath=/home/pi/torrents
DynDNS\DomainName=changeme.dyndns.org
DynDNS\Enabled=false
DynDNS\Password=
DynDNS\Service=DynDNS
DynDNS\Username=
General\AlternatingRowColors=true
General\CloseToTray=true
General\CloseToTrayNotified=true
General\CustomUIThemePath=
General\ExitConfirm=true
General\HideZeroComboValues=0
General\HideZeroValues=false
General\Locale=ru
General\MinimizeToTray=false
General\NoSplashScreen=true
General\PreventFromSuspendWhenDownloading=true
General\PreventFromSuspendWhenSeeding=false
General\StartMinimized=true
General\SystrayEnabled=true
General\UseCustomUITheme=false
MailNotification\email=
MailNotification\enabled=false
MailNotification\password=
MailNotification\req_auth=true
MailNotification\req_ssl=false
MailNotification\sender=qBittorrent_notification@example.com
MailNotification\smtp_server=smtp.changeme.com
MailNotification\username=
Scheduler\days=EveryDay
Scheduler\end_time=@Variant(\0\0\0\xf\x4J\xa2\0)
Scheduler\start_time=@Variant(\0\0\0\xf\x1\xb7t\0)
WebUI\Address=*
WebUI\AlternativeUIEnabled=false
WebUI\AuthSubnetWhitelist=192.168.1.0/24
WebUI\AuthSubnetWhitelistEnabled=true
WebUI\BanDuration=3600
WebUI\CSRFProtection=true
WebUI\ClickjackingProtection=true
WebUI\CustomHTTPHeaders=
WebUI\CustomHTTPHeadersEnabled=false
WebUI\Enabled=true
WebUI\HTTPS\CertificatePath=
WebUI\HTTPS\Enabled=false
WebUI\HTTPS\KeyPath=
WebUI\HostHeaderValidation=true
WebUI\LocalHostAuth=false
WebUI\MaxAuthenticationFailCount=5
WebUI\Password_PBKDF2="@ByteArray(admin)"
WebUI\Port=8080
WebUI\ReverseProxySupportEnabled=false
WebUI\RootFolder=
WebUI\SecureCookie=true
WebUI\ServerDomains=*
WebUI\SessionTimeout=3600
WebUI\TrustedReverseProxiesList=
WebUI\UseUPnP=false
WebUI\Username=admin
[RSS]
AutoDownloader\DownloadRepacks=true
AutoDownloader\SmartEpisodeFilter=s(\\d+)e(\\d+), (\\d+)x(\\d+), "(\\d{4}[.\\-]\\d{1,2}[.\\-]\\d{1,2})", "(\\d{1,2}[.\\-]\\d{1,2}[.\\-]\\d{4})"
[ShutdownConfirmDlg]
DontConfirmAutoExit=false
[SpeedWidget]
Enabled=true
graph_enable_0=true
graph_enable_1=true
graph_enable_2=false
graph_enable_3=false
graph_enable_4=false
graph_enable_5=false
graph_enable_6=false
graph_enable_7=false
graph_enable_8=false
graph_enable_9=false
period=1
[TorrentProperties]
CurrentTab=5
Peers\qt5\PeerListState=@ByteArray(\0\0\0\xff\0\0\0\0\0\0\0\x1\0\0\0\x1\0\0\0\0\x1\0\0\0\0\0\0\0\0\0\0\0\xf@@\0\0\0\x2\0\0\0\x6\0\0\0\x64\0\0\0\xe\0\0\0\x64\0\0\x5\x14\0\0\0\xf\x1\x1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x64\xff\xff\xff\xff\0\0\0\x81\0\0\0\0\0\0\0\xf\0\0\0\x64\0\0\0\x1\0\0\0\0\0\0\0\x64\0\0\0\x1\0\0\0\0\0\0\0\x64\0\0\0\x1\0\0\0\0\0\0\0\x64\0\0\0\x1\0\0\0\0\0\0\0\x64\0\0\0\x1\0\0\0\0\0\0\0\x64\0\0\0\x1\0\0\0\0\0\0\0\0\0\0\0\x1\0\0\0\0\0\0\0\x64\0\0\0\x1\0\0\0\0\0\0\0\x64\0\0\0\x1\0\0\0\0\0\0\0\x64\0\0\0\x1\0\0\0\0\0\0\0\x64\0\0\0\x1\0\0\0\0\0\0\0\x64\0\0\0\x1\0\0\0\0\0\0\0\x64\0\0\0\x1\0\0\0\0\0\0\0\x64\0\0\0\x1\0\0\0\0\0\0\0\0\0\0\0\x1\0\0\0\0\0\0\x3\xe8\0\xff\xff\xff\xff)
SplitterSizes="156,369"
Trackers\qt5\TrackerListState=@ByteArray(\0\0\0\xff\0\0\0\0\0\0\0\x1\0\0\0\x1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x3 \0\0\0\b\x1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x64\xff\xff\xff\xff\0\0\0\x81\0\0\0\0\0\0\0\b\0\0\0\x64\0\0\0\x1\0\0\0\0\0\0\0\x64\0\0\0\x1\0\0\0\0\0\0\0\x64\0\0\0\x1\0\0\0\0\0\0\0\x64\0\0\0\x1\0\0\0\0\0\0\0\x64\0\0\0\x1\0\0\0\0\0\0\0\x64\0\0\0\x1\0\0\0\0\0\0\0\x64\0\0\0\x1\0\0\0\0\0\0\0\x64\0\0\0\x1\0\0\0\0\0\0\x3\xe8\0\0\0\0\x64)
Visible=true
qt5\FilesListState=@ByteArray(\0\0\0\xff\0\0\0\0\0\0\0\x1\0\0\0\x1\0\0\0\0\x1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x2X\0\0\0\x6\x1\x1\0\x1\0\0\0\0\0\0\0\0\0\0\0\0\x64\xff\xff\xff\xff\0\0\0\x81\0\0\0\0\0\0\0\x6\0\0\0\x64\0\0\0\x1\0\0\0\0\0\0\0\x64\0\0\0\x1\0\0\0\0\0\0\0\x64\0\0\0\x1\0\0\0\0\0\0\0\x64\0\0\0\x1\0\0\0\0\0\0\0\x64\0\0\0\x1\0\0\0\0\0\0\0\x64\0\0\0\x1\0\0\0\0\0\0\x3\xe8\0\0\0\0\x64)
[TransferList]
qt5\HeaderState=@ByteArray(\0\0\0\xff\0\0\0\0\0\0\0\x1\0\0\0\x1\0\0\0\0\x1\0\0\0\0\0\0\0\0\0\0\0\"\b\x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\x1\0\0\0\0\0\0\0\0\0\0\0\x1\0\0\0\0\0\0\0\0\0\0\0\x1\0\0\0\0\0\0\0\0\0\0\0\x1\0\0\0\0\0\0\0\0\0\0\0\x1\0\0\0\0\0\0\0\0\0\0\0\x1\0\0\0\0\0\0\0\0\0\0\0\x1\0\0\0\0\0\0\0\0\0\0\0\x1\0\0\0\0\0\0\0\0\0\0\0\x1\0\0\0\0\0\0\0\x64\0\0\0\x1\0\0\0\0\0\0\0\0\0\0\0\x1\0\0\0\0\0\0\0\0\0\0\0\x1\0\0\0\0\0\0\0\0\0\0\0\x1\0\0\0\0\0\0\x3\xe8\0\0\0\0\x64)
[TransferListFilters]
selectedFilterIndex=0
[WatchedFolderOptionsDialog]
DialogSize=@Size(462 421)
[AutoRun]
OnTorrentAdded\Enabled=false
OnTorrentAdded\Program=
enabled=false
program=
[BitTorrent]
Session\AddExtensionToIncompleteFiles=true
Session\AnonymousModeEnabled=true
Session\BTProtocol=Both
Session\DHTEnabled=true
Session\DefaultSavePath=/mnt/usbhd/Films_nox
Session\Encryption=1
Session\ExcludedFileNames=
Session\GlobalMaxSeedingMinutes=1
Session\GlobalUPSpeedLimit=0
Session\IgnoreLimitsOnLAN=true
Session\IncludeOverheadInLimits=false
Session\LSDEnabled=true
Session\MaxActiveUploads=3
Session\MaxConnectionsPerTorrent=20
Session\MaxUploads=20
Session\PeXEnabled=true
Session\Port=42161
Session\Preallocation=true
Session\QueueingSystemEnabled=true
Session\UseAlternativeGlobalSpeedLimit=false
Session\uTPRateLimited=false
[Core]
AutoDeleteAddedTorrentFile=Never
[Meta]
MigrationVersion=4
[Network]
Cookies=@Invalid()
PortForwardingEnabled=true
Proxy\IP=
Proxy\OnlyForTorrents=true
Proxy\Password=
Proxy\Port=@Variant(\0\0\0\x85\0\0)
Proxy\Type=None
Proxy\Username=
[Preferences]
Advanced\RecheckOnCompletion=false
Advanced\trackerPort=9000
Advanced\trackerPortForwarding=false
Connection\ResolvePeerCountries=true
DynDNS\DomainName=changeme.dyndns.org
DynDNS\Enabled=false
DynDNS\Password=
DynDNS\Service=DynDNS
DynDNS\Username=
General\Locale=ru
MailNotification\email=
MailNotification\enabled=false
MailNotification\password=
MailNotification\req_auth=true
MailNotification\req_ssl=false
MailNotification\sender=qBittorrent_notification@example.com
MailNotification\smtp_server=smtp.changeme.com
MailNotification\username=
WebUI\Address=*
WebUI\AlternativeUIEnabled=false
WebUI\AuthSubnetWhitelist=192.168.1.0/24
WebUI\AuthSubnetWhitelistEnabled=true
WebUI\BanDuration=3600
WebUI\CSRFProtection=true
WebUI\ClickjackingProtection=true
WebUI\CustomHTTPHeaders=
WebUI\CustomHTTPHeadersEnabled=false
WebUI\HTTPS\CertificatePath=
WebUI\HTTPS\Enabled=false
WebUI\HTTPS\KeyPath=
WebUI\HostHeaderValidation=true
WebUI\LocalHostAuth=false
WebUI\MaxAuthenticationFailCount=5
WebUI\Port=8081
WebUI\ReverseProxySupportEnabled=false
WebUI\RootFolder=/home/pi/qtorwebui/qbit-matUI_Unix_1.16.4
WebUI\SecureCookie=true
WebUI\ServerDomains=*
WebUI\SessionTimeout=3600
WebUI\TrustedReverseProxiesList=
WebUI\UseUPnP=false
WebUI\Username=admin
[RSS]
AutoDownloader\DownloadRepacks=true
AutoDownloader\SmartEpisodeFilter=s(\\d+)e(\\d+), (\\d+)x(\\d+), "(\\d{4}[.\\-]\\d{1,2}[.\\-]\\d{1,2})", "(\\d{1,2}[.\\-]\\d{1,2}[.\\-]\\d{4})"