Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

builder.getInput() is different from input for Struct fields #1863

Open
Swahvay opened this issue Dec 4, 2024 · 2 comments
Open

builder.getInput() is different from input for Struct fields #1863

Swahvay opened this issue Dec 4, 2024 · 2 comments

Comments

@Swahvay
Copy link
Contributor

Swahvay commented Dec 4, 2024

In triggers, when calling builder.getInput(), any fields that are structs, will be returned with their snake_case DB keys, instead of the camelCase field definition keys. The input parameter has the correct keys though.

@Swahvay
Copy link
Contributor Author

Swahvay commented Dec 5, 2024

An example:

// Schema field
horses: StructTypeAsList({
  tsType: 'CompetitionEventHorseEntry',
  fields: {
    horseID: UUIDType({
      nullable: true,
      foreignKey: {
        schema: 'Horse',
        column: 'id',
      },
    }),
    horseName: StringType({
      nullable: true,
      maxLen: 200,
    }).formatter(horseNameFormatter),
    backNumber: IntegerType({
      nullable: true,
      min: 1,
    }),
  },
}),
getTriggers() {
  return [
    {
      changeset(builder, input) {
        console.log(input.horses, builder.getInput().horses);
      },
    },
  ];
}
[
  {
    backNumber: 3396,
    horseName: 'Quality Time',
    horseId: '2762b397-cd62-4f4f-8ed8-2203935f1f44'
  }
] [
  {
    horse_id: '2762b397-cd62-4f4f-8ed8-2203935f1f44',
    horse_name: 'Quality Time',
    back_number: 3396
  }
]

@Swahvay
Copy link
Contributor Author

Swahvay commented Dec 5, 2024

This is especially bad because when I do builder.getNewHorsesValue(), it will sometimes return the horse_name version if it's in the input, otherwise if it gets it from existingEnt it will return the horseName version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant