Skip to content

Commit 94c1dd0

Browse files
committed
fix: add fallback for AddPerson
1 parent 8c0e3e5 commit 94c1dd0

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

tests/data_generator/datagenerator.go

+13-1
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ func AddPerson(personId int64) {
178178

179179
// only add if this personId is new:
180180
if utils.Pos(personId, personIds) == -1 {
181-
tests.ExecSQLStringOrFail(
181+
result := tests.ExecSQLString(
182182
fmt.Sprintf(
183183
"INSERT into %s.person "+
184184
"(person_id,year_of_birth,month_of_birth,day_of_birth,gender_concept_id,race_concept_id,ethnicity_concept_id) "+
@@ -187,6 +187,18 @@ func AddPerson(personId int64) {
187187
tests.GetOmopDataSourceForSourceId(sourceId).Schema,
188188
personId, rand.Intn(100)+1900, rand.Intn(12), rand.Intn(28), genderConceptIds[rand.Intn(len(genderConceptIds))]),
189189
sourceId)
190+
if result.Error != nil {
191+
// fallback, try simpler record:
192+
tests.ExecSQLStringOrFail(
193+
fmt.Sprintf(
194+
"INSERT into %s.person "+
195+
"(person_id) "+
196+
"values "+
197+
"(%d)",
198+
tests.GetOmopDataSourceForSourceId(sourceId).Schema,
199+
personId),
200+
sourceId)
201+
}
190202
// keep track of added persons, so we don't add them twice:
191203
personIds = append(personIds, personId)
192204
}

0 commit comments

Comments
 (0)