10000 🐛 Bug: When a linked column ID is used as a column name in SQL Query, it's truncated and not properly escaped · Issue #11375 · nocodb/nocodb · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
🐛 Bug: When a linked column ID is used as a column name in SQL Query, it's truncated and not properly escaped #11375
Closed
@grv87

Description

@grv87

Please confirm that the bug report does not already exist

  • I confirm there is no existing issue for this bug.

Steps to reproduce

  1. Have a database with a relationship
  2. Update the metadata database directly, add a . or [<digit>] (e.g. [2]) to the linked column ID
  3. Restart NocoDB
  4. Check out the view and get an SQL error

Example of generated invalid SQL:

SELECT
  (
    SELECT
      count("__nc_rollup"."uuid")
    FROM
      "mart_ncdb"."attribute" AS "__nc_rollup"
    INNER JOIN "mart_ncdb"."attribute_may_have_val_particular" ON
      "mart_ncdb"."attribute_may_have_val_particular"."left_item_uuid" = "__nc_rollup"."uuid"
    WHERE
      "mart_ncdb"."attribute_may_have_val_particular"."right_item_uuid" = "mart_ncdb"."sentence"."uuid"
  ) AS "!TL)X{)~uzc=15"[2], -- ERROR
  "mart_ncdb"."sentence"."uuid" AS "c1uyfpahct7vkcw"
FROM
  "mart_ncdb"."sentence"
WHERE
  "uuid" = '4e5ef00c-8d3a-4d43-a94d-3d783c8c70c0'
LIMIT 1

The actual column ID is !TL)X{)~uzc=15[2]QFb

Desired Behavior

  • Whatever datum is used as an SQL column name, it's not truncated and correctly escaped when necessary
  • Maybe it's better to use column_name, not column_id, to increase SQL readability in the case of troubleshooting

Project Details

Node: v22.15.0
Arch: x64
Platform: linux
Docker: false
RootDB: pg
PackageVersion: 0.263.1

Attachments

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0