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

Handle UUID Generation for Strings in addition to ID #134

Open
jarrodplacide opened this issue Apr 29, 2023 · 0 comments
Open

Handle UUID Generation for Strings in addition to ID #134

jarrodplacide opened this issue Apr 29, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@jarrodplacide
Copy link

Currently, the library only identifies strings with attribute type, @id via the IsId parameter to be assigned a UUID as a scalar default

export const scalarFieldValueGenerator: StrictScalarFieldValueGenerator = {
  Boolean: () => true,
  String: ({ fieldName, isId, isUnique }) => {
    if (isId || isUnique) {
      return short.generate();
    }
    return `${fieldName} field`;
  },
  Int: ({ isId, isUnique, seq }) => {
    if (isId || isUnique) {
      return seq;
    }
    return 10;
  },
  Float: () => 3.14,
  BigInt: () => BigInt(12_345_678),
  Decimal: () => {
    throw new Error("Not support Decimal field generation");
  },
  DateTime: () => new Date(),
  Bytes: () => Buffer.from([0x80, 0xff]),
  Json: () => ({
    key: "value",
  }),
};

However, schemas that make use of the attribute @db.Uuid are treated a regular strings, which is a mismatched handling.

@Quramy Quramy added the enhancement New feature or request label Oct 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants