{"id":"e8a2294fbac30589","repo":"drizzle-team/drizzle-orm","slug":"count-exceeds-max-number-of-unique-countries","errorCode":null,"errorMessage":"count exceeds max number of unique countries.","messagePattern":"count exceeds max number of unique countries\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"drizzle-seed/src/services/Generators.ts","lineNumber":2132,"sourceCode":"\n\t\t[idx, this.state.rng] = prand.uniformIntDistribution(0, countries.length - 1, this.state.rng);\n\t\tconst country = countries[idx] as string;\n\n\t\treturn country;\n\t}\n}\n\nexport class GenerateUniqueCountry extends AbstractGenerator<{ isUnique?: boolean }> {\n\tstatic override readonly entityKind: string = 'GenerateUniqueCountry';\n\n\tprivate state: {\n\t\tgenIndicesObj: GenerateUniqueInt;\n\t} | undefined;\n\tpublic override isUnique = true;\n\n\toverride init({ count, seed }: { count: number; seed: number }) {\n\t\tif (count > countries.length) {\n\t\t\tthrow new Error('count exceeds max number of unique countries.');\n\t\t}\n\n\t\tif (this.stringLength !== undefined && this.stringLength < maxCountryLength) {\n\t\t\tthrow new Error(\n\t\t\t\t`You can't use country generator with a db column length restriction of ${this.stringLength}. Set the maximum string length to at least ${maxCountryLength}.`,\n\t\t\t);\n\t\t}\n\n\t\tconst genIndicesObj = new GenerateUniqueInt({ minValue: 0, maxValue: countries.length - 1 });\n\t\tgenIndicesObj.init({ count, seed });\n\n\t\tthis.state = { genIndicesObj };\n\t}\n\n\tgenerate() {\n\t\tif (this.state === undefined) {\n\t\t\tthrow new Error('state is not defined.');\n\t\t}","sourceCodeStart":2114,"sourceCodeEnd":2150,"githubUrl":"https://github.com/drizzle-team/drizzle-orm/blob/b7862528fd8fc39bc2653a6c18dad7c1f4e68d10/drizzle-seed/src/services/Generators.ts#L2114-L2150","documentation":"Error \"count exceeds max number of unique countries.\" thrown in drizzle-team/drizzle-orm.","triggerScenarios":"Requesting more unique countries than exist in the country pool.","commonSituations":"Unique country column with count greater than the number of countries.","solutions":["Reduce the requested unique country count or drop the unique constraint."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"analyzedSha":"b7862528fd8fc39bc2653a6c18dad7c1f4e68d10","analyzedAt":"2026-08-03T18:11:14.318Z","schemaVersion":2}