Skip to content
This repository was archived by the owner on Jan 10, 2023. It is now read-only.
This repository was archived by the owner on Jan 10, 2023. It is now read-only.

found a bug with groupBy clause #251

@tim-tai

Description

@tim-tai

I found this when I was trying to create a query that will return a list of task.

Here is the query

var query = db.select(task.id,
       		task.note,
	      	).
		from(item).
		innerJoin(task, task.id.eq(item.task_id)).
		where(item.auditor_id.eq(123)).
		groupBy(item.task_id);

Here are the sample data for both table, task(master) and item(detail).

var task_data = [{
      'id': 1,
      'initiator_id': 1,
      'schedule_id': 1,
      'status': 0,
      'description': 'Task Example A'
    }, {
      'id': 2,
      'initiator_id': 2,
      'schedule_id': 2,
      'status': 0,
      'description': 'Task Example B'
    }];

var item_data = [{
        'id': 1,
        'task_id': 1,
        'auditor_id': 123,
        'tag_id': 1,
        'asset_name': 'Item A',
        'asset_type_name': 'Type A',
        'description': 'example A'
      }, {
        'id': 2,
        'task_id': 1,
        'auditor_id': 123,
        'tag_id': 2,
        'asset_name': 'Item B',
        'asset_type_name': 'Type B',
        'description': 'example B'
      }
      /*,{
            'id': 3,
            'task_id': 2,
            'auditor_id': 123,
            'tag_id': 3,
            'asset_name': 'Item C',
            'asset_type_name': 'Type C',
            'description': 'example C'
          }*/
    ];

So with the Sample data above the query should just return one row of task id (1) and description (example A), but somehow it return twice.

The result will be correct when third data row(commented) is added, which will return two task id(1, 2) and two description(example A, example B).

Here is the example: jsfiddle

Metadata

Metadata

Assignees

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