Skip to content

Non-deterministic parameter ordering in JOOQ-generated Dataset constructor #3821

@bobbai00

Description

@bobbai00

Description

The JOOQ-generated Dataset.java class has a constructor with non-deterministic parameter ordering. This can cause issues when manually creating Dataset instances using the constructor, as the parameter order may change between JOOQ code generations.

Problem

In DatasetResource.scala, we were manually constructing a new Dataset object by passing parameters to the constructor:

new Dataset(
  createdDataset.getDid,
  createdDataset.getOwnerUid,
  createdDataset.getName,
  createdDataset.getRepositoryName,
  createdDataset.getIsPublic,
  createdDataset.getIsDownloadable,
  createdDataset.getDescription,
  createdDataset.getCreationTime
)

However, the constructor parameter order in the generated class is non-deterministic and may not match this order.

Solution

Use JOOQ's built-in into() method to convert from DatasetRecord to Dataset POJO:

createdDataset.into(classOf[Dataset])

This avoids relying on constructor parameter ordering entirely.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions