Skip to content

Commit a62412a

Browse files
committed
many to many needs a datatype
1 parent dba3bc5 commit a62412a

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

dsl/relationalmodel.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,12 +292,13 @@ func HasMany(name, child string) {
292292
// This specifies that the Order and Product tables have a "junction" table
293293
// called `order_lines` that contains the order and product information.
294294
// The generated model will have a field called `Products` that will
295-
// be an array of type `product.Product`.
295+
// be an array of type `Product`.
296296
func ManyToMany(other, tablename string) {
297297
if r, ok := relationalModelDefinition(false); ok {
298298
field := gorma.NewRelationalFieldDefinition()
299299
field.FieldName = inflect.Pluralize(other)
300300
field.Many2Many = other
301+
field.Datatype = gorma.Many2Many
301302
field.Description = "many to many " + r.ModelName + "/" + strings.Title(other)
302303
field.Parent = r
303304
r.RelationalFields[field.FieldName] = field

init.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ const (
4848
HasMany FieldType = "hasmany"
4949
// HasManyKey is used internally
5050
HasManyKey FieldType = "hasmanykey"
51+
// Many2Many is used internally
52+
Many2Many FieldType = "many2many"
53+
// Many2ManyKey is used internally
54+
Many2ManyKey FieldType = "many2manykey"
5155
// BelongsTo is used internally
5256
BelongsTo FieldType = "belongsto"
5357
)

0 commit comments

Comments
 (0)