Skip to content

Commit 4294fc7

Browse files
Fix: hasura with Bun
1 parent a072d9c commit 4294fc7

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

hasura/hasura.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,11 @@ func getTableName(value reflect.Value, typ reflect.Type) string {
298298
return values[0]
299299
}
300300
}
301+
if tag := field.Tag.Get("bun"); tag != "" {
302+
if values := strings.Split(tag, ","); len(values) > 0 {
303+
return values[0]
304+
}
305+
}
301306
}
302307
return ToSnakeCase(typ.Name())
303308
}
@@ -328,6 +333,10 @@ func getColumns(typ reflect.Type) []string {
328333
if !strings.HasPrefix(tag, "-") && field.Name != "tableName" && !strings.Contains(tag, "rel:") {
329334
columns = append(columns, ToSnakeCase(field.Name))
330335
}
336+
} else if tag := field.Tag.Get("bun"); tag != "" {
337+
if !strings.HasPrefix(tag, "-") && field.Name != "BaseModel" && !strings.Contains(tag, "rel:") {
338+
columns = append(columns, ToSnakeCase(field.Name))
339+
}
331340
} else {
332341
columns = append(columns, ToSnakeCase(field.Name))
333342
}

0 commit comments

Comments
 (0)