Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

sql query for attach id in current comment

Виктор Максимов
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
April 17, 2019

Hello,

got 2 different comments with attachmets with same name, but with different content.

need select from jira db which returns attach id for current comment for current attach file  name. 

something like: select [attach file id] .... where [commentid]=xxxx and [attach file name]='xxxxxxxx'

any ideas?

2 answers

1 vote
kortov
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
April 17, 2019

AFAIK there are 2 ways to get comments:

with users as (select LOWER_USER_NAME, DISPLAY_NAME, UPDATED_DATE,
row_number() over(partition by LOWER_USER_NAME
order by UPDATED_DATE desc) seq
from CWD_USER)
select ja.id as id, ja.ISSUEID as issueId, dbms_lob.substr( ja.ACTIONBODY, 4000, 1 ) as content,
ja.AUTHOR as commentLogin, users.DISPLAY_NAME as commentFio, ja.CREATED as createdDate, ja.id
from
(
select ISSUEID, ID, CREATED,
row_number() over(partition by ISSUEID
order by CREATED desc) seq
from JIRAACTION
where ISSUEID = {ISSUEID}
) lastComments
join JIRAACTION ja on lastComments.id = ja.ID
join users on ja.AUTHOR = users.LOWER_USER_NAME and users.seq = 1
where ja.ACTIONTYPE = 'comment'
 {jiraUrl}/rest/api/2/issue/{issueKeyOrId}/comment

 

And there no mention about id of comment. And as I can see, JIRA doesn't keep ids of of attachements in comments, so if you upload two attachements with the same name in two comments the link to attachement in comments will be the same

0 votes
Виктор Максимов
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
April 17, 2019

In-depth analysis of the problem showed that files with the same name are saved in the issue, but there is no data for linking a specific file to a specific comment (or tag [^] inside the comment). This is sad :) so you have to insert short stubs that solve this problem at the script level.

If I am mistaken I will be glad to see the solution.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events