fix regression for issue #404

Wed, 07 Aug 2024 18:43:15 +0200

author
Mike Becker <universe@uap-core.de>
date
Wed, 07 Aug 2024 18:43:15 +0200
changeset 321
fe73f02d86dc
parent 320
eb77a4149789
child 322
7b154ddd29e3

fix regression for issue #404

where a partially loaded project
object was insufficient to render
the issue view

src/main/kotlin/de/uapcore/lightpit/dao/PostgresDataAccessObject.kt file | annotate | diff | comparison | revisions
--- a/src/main/kotlin/de/uapcore/lightpit/dao/PostgresDataAccessObject.kt	Wed Aug 07 18:11:54 2024 +0200
+++ b/src/main/kotlin/de/uapcore/lightpit/dao/PostgresDataAccessObject.kt	Wed Aug 07 18:43:15 2024 +0200
@@ -365,14 +365,14 @@
         left join lpit_user owner on lpit_project.owner = owner.userid
         """.trimIndent()
 
-    private fun ResultSet.extractProject() =
-        Project(getInt("projectid")).apply {
-            name = getString("name")
-            node = getString("node")
-            ordinal = getInt("ordinal")
-            description = getString("description")
-            vcs = getEnum("vcs")
-            repoUrl = getString("repourl")
+    private fun ResultSet.extractProject(prefix:String = "") =
+        Project(getInt("${prefix}projectid")).apply {
+            name = getString("${prefix}name")
+            node = getString("${prefix}node")
+            ordinal = getInt("${prefix}ordinal")
+            description = getString("${prefix}description")
+            vcs = getEnum("${prefix}vcs")
+            repoUrl = getString("${prefix}repourl")
             owner = extractOptionalUser()
         }
 
@@ -492,8 +492,14 @@
     //language=SQL
     private val issueQuery =
         """
-        select issueid,
-            i.project, p.name as projectname, p.node as projectnode,
+        select issueid, i.project,
+            p.projectid as project_projectid,
+            p.name as project_name,
+            p.node as project_node,
+            p.ordinal as project_ordinal,
+            p.description as project_description,
+            p.vcs as project_vcs,
+            p.repourl as project_repourl,
             component, c.name as componentname, c.node as componentnode,
             status, phase, category, subject, i.description,
             userid, username, givenname, lastname, mail,
@@ -506,10 +512,7 @@
         """.trimIndent()
 
     private fun ResultSet.extractIssue(): Issue {
-        val proj = Project(getInt("project")).apply {
-            name = getString("projectname")
-            node = getString("projectnode")
-        }
+        val proj = extractProject("project_")
         val comp = getInt("component").let {
             if (wasNull()) null else
                 Component(it, proj.id).apply {

mercurial