hasura / ndc-jvm-mono

0 stars 2 forks source link

Error in MySQL query generation #7

Closed nihxdr closed 1 month ago

nihxdr commented 1 month ago

DDN version: 2.5.0 MySQL ndc version: 1.0.1


Following is the MySQL query generated,

select json_object('rows', (
    select json_arrayagg(json_object(
        'id', id,
        'mode', mode,
        'courseId', course_id
    ))
    from (
        select
        <connector_name>.<table_name>.id as id,
        <connector_name>.<table_name>.mode as mode,
        <connector_name>.<table_name>.course_id as courseId
        from <connector_name>.<table_name>
        where <connector_name>.<table_name>.mode = 'audit'
        group by <connector_name>.<table_name>.id, <connector_name>.<table_name>.mode, <connector_name>.<table_name>.course_id
    ) as <table_name>
))

and this gives following error log:

{
  "timestamp": "2024-09-18T03:26:24.057838179Z",
  "level": "ERROR",
  "message": "Uncaught exception",
  "exception": {
    "exceptionType": "org.jooq.exception.DataAccessException",
    "message": "SQL [select json_object('rows', (select json_arrayagg(json_object('id', id, 'mode', mode, 'courseId', course_id)) from (select <connector_name>.<table_name>.id as id, <connector_name>.<table_name>.mode as mode, <connector_name>.<table_name>.course_id as courseId from <connector_name>.<table_name> where <connector_name>.<table_name>.mode = 'audit' group by <connector_name>.<table_name>.id, <connector_name>.<table_name>.mode, <connector_name>.<table_name>.course_id) as <table_name>))]; Unknown column 'course_id' in 'field list'"
  }
}

This might have caused the issue:

https://github.com/hasura/ndc-jvm-mono/blob/6875748c433e772da7603e3b4fd0798b4c2321a4/ndc-connector-mysql/src/main/kotlin/io/hasura/mysql/JSONGenerator.kt#L59