SQL Error when trying to access core : Column 'id' in field list is ambiguous

Created on 27 July 2023, over 1 year ago
Updated 28 July 2023, over 1 year ago

When I try accessing the drd/cores/core/{id} page, I get the following error on the dashboard :

SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'id' in field list is ambiguous: SELECT DISTINCT "drd_project_drd_major"."label" AS "drd_project_drd_major_label", "drd_release"."updatestatus" AS "drd_release_updatestatus", "drd_project_drd_major"."type" AS "drd_project_drd_major_type", "drd_release"."id" AS "id_1", "releases_drd_release"."id" AS "releases_drd_release_id", "drd_major_drd_release"."id" AS "drd_major_drd_release_id", "drd_project_drd_major"."id" AS "drd_project_drd_major_id", id AS "id", name AS "name", secure AS "secure", updatestatus AS "updatestatus", label AS "label" FROM "drd_release" "drd_release" INNER JOIN "drd_domain__releases" "drd_domain__releases" ON drd_release.id = drd_domain__releases.releases_target_id INNER JOIN "drd_domain" "releases_drd_release" ON drd_domain__releases.entity_id = releases_drd_release.id INNER JOIN "drd_major" "drd_major_drd_release" ON drd_release.major = drd_major_drd_release.id INNER JOIN "drd_project" "drd_project_drd_major" ON drd_major_drd_release.project = drd_project_drd_major.id WHERE ((releases_drd_release.core = :drd_domain_core2)) AND (("drd_major_drd_release"."hidden" = :db_condition_placeholder_0) AND ("drd_major_drd_release"."parentproject" IS NULL)) ORDER BY "drd_project_drd_major_type" ASC, "drd_project_drd_major_label" ASC; Array ( [:drd_domain_core2] => 2 [:db_condition_placeholder_0] => 0 )

Furthermore, I don't seem to get the modules for each domain, this may be the cause.

Setup :
Server using PHP8, on a fresh Drupal 9 website.

💬 Support request
Status

Fixed

Version

4.0

Component

Code

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇩🇪Germany jurgenhaas Gottmadingen

    Hmm, there is not much information. Can you please provide step by step instructions on how to get to this error together with version numbers of every used component, including PHP, database, Drupal Core, DRD and others? Also, please describe how you installed Drupal and the modules and how you instantiate the Drupal site before getting to this point.

    I know this is a lot to ask for, but I assume there is some error in setting up the site, because so many users are using this module without an issue, so I have doubts that there is an error in it that would cause this.

  • Regarding versions :
    Website that I want to use as dashboard is running on Drupal 9.5.10.
    PHP version is 8.0.12.
    Database is MySQL 8.0.18-9.
    DRD : 4.0.9
    DRD Agent is in a Drupal 7.95 website, suning drd_agent version 7.x-3.6

    The dashboard was installed following the drupal installation guide, by running the install.php script in browser.
    All required and recommended modules in the DRD installation guide were installed ( https://www.drupal.org/docs/8/modules/drupal-remote-dashboard/getting-st... )

  • 🇩🇪Germany jurgenhaas Gottmadingen

    There must be some other module that rewrites your SQL query from that view.

    Your SQL statement from above looks like this:

    SELECT DISTINCT "drd_project_drd_major"."label" AS "drd_project_drd_major_label",
                    "drd_release"."updatestatus"    AS "drd_release_updatestatus",
                    "drd_project_drd_major"."type"  AS "drd_project_drd_major_type",
                    "drd_release"."id"              AS "id_1",
                    "releases_drd_release"."id"     AS "releases_drd_release_id",
                    "drd_major_drd_release"."id"    AS "drd_major_drd_release_id",
                    "drd_project_drd_major"."id"    AS "drd_project_drd_major_id",
                    id                              AS "id",
                    name                            AS "name",
                    secure                          AS "secure",
                    updatestatus                    AS "updatestatus",
                    label                           AS "label"
    FROM "drd_release" "drd_release"
             INNER JOIN "drd_domain__releases" "drd_domain__releases"
                        ON drd_release.id = drd_domain__releases.releases_target_id
             INNER JOIN "drd_domain" "releases_drd_release" ON drd_domain__releases.entity_id = releases_drd_release.id
             INNER JOIN "drd_major" "drd_major_drd_release" ON drd_release.major = drd_major_drd_release.id
             INNER JOIN "drd_project" "drd_project_drd_major" ON drd_major_drd_release.project = drd_project_drd_major.id
    WHERE ((releases_drd_release.core = :drd_domain_core2))
      AND (("drd_major_drd_release"."hidden" = :db_condition_placeholder_0) AND
           ("drd_major_drd_release"."parentproject" IS NULL))
    ORDER BY "drd_project_drd_major_type" ASC, "drd_project_drd_major_label" ASC;
    

    However, when I run this on a fresh installation, the SQL statement looks like this:

    SELECT DISTINCT "drd_project_drd_major"."label" AS "drd_project_drd_major_label",
                    "drd_release"."updatestatus"    AS "drd_release_updatestatus",
                    "drd_project_drd_major"."type"  AS "drd_project_drd_major_type",
                    "drd_release"."id"              AS "id",
                    "releases_drd_release"."id"     AS "releases_drd_release_id",
                    "drd_major_drd_release"."id"    AS "drd_major_drd_release_id",
                    "drd_project_drd_major"."id"    AS "drd_project_drd_major_id"
    FROM {drd_release} "drd_release"
    INNER JOIN {drd_domain__releases} "drd_domain__releases"
    ON drd_release.id = drd_domain__releases.releases_target_id
        INNER JOIN {drd_domain} "releases_drd_release" ON drd_domain__releases.entity_id = releases_drd_release.id
        INNER JOIN {drd_major} "drd_major_drd_release" ON drd_release.major = drd_major_drd_release.id
        INNER JOIN {drd_project} "drd_project_drd_major" ON drd_major_drd_release.project = drd_project_drd_major.id
    WHERE ((releases_drd_release.core = '20'))
      AND (("drd_major_drd_release"."hidden" = '0')
      AND ("drd_major_drd_release"."parentproject" IS NULL))
    ORDER BY "drd_project_drd_major_type" ASC, "drd_project_drd_major_label" ASC;
    

    In your SQL statement there are 5 extra fields in lines 8-12 that certainly don't come from DRD, but they cause this issue. Maybe you try with the latest DRD version 4.1.x-dev to see if you can still reproduce the problem with that?

  • It seems there was indeed a problem with my drupal installation causing the 4 lines in the SQL query to appear.
    Re installed of Drupal solved the issue.
    Thank you for your assistance

  • Status changed to Fixed over 1 year ago
  • 🇩🇪Germany jurgenhaas Gottmadingen

    This is great news, thanks for letting us know.

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024