Skip to content

Commit c505216

Browse files
committed
Allow optional embeds
1 parent eaae461 commit c505216

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

internal/gen.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ func (v QueryValue) RowNode(rowVar string) *pyast.Node {
129129
Left: &pyast.Node{
130130
Node: &pyast.Node_Call{
131131
Call: &pyast.Call{
132-
Func: f.Type.Annotation(false),
132+
Func: poet.Name(f.Type.InnerType),
133133
Keywords: embedFields,
134134
},
135135
},
@@ -466,7 +466,7 @@ func columnsToStruct(req *plugin.GenerateRequest, name string, columns []pyColum
466466
f.Type = pyType{
467467
InnerType: MODELS_FILENAME + "." + c.embed.modelType,
468468
IsArray: c.IsArray,
469-
IsNull: false,
469+
IsNull: !c.NotNull,
470470
}
471471
f.EmbedFields = c.embed.fields
472472
}
@@ -523,7 +523,9 @@ func buildQueries(conf Config, req *plugin.GenerateRequest, structs []Struct) ([
523523
return nil, errors.New("invalid query parameter limit")
524524
}
525525
enforcedFields := make(map[string]bool)
526+
// log.Printf("%v\n\n", query)
526527
for _, c := range query.Columns {
528+
// log.Printf("%v\n\n", c)
527529
if fields, ok := rlsFieldsByTable[c.GetTable().GetName()]; ok {
528530
for _, f := range fields {
529531
enforcedFields[f] = false
@@ -620,6 +622,7 @@ func buildQueries(conf Config, req *plugin.GenerateRequest, structs []Struct) ([
620622
qs = append(qs, gq)
621623
}
622624
sort.Slice(qs, func(i, j int) bool { return qs[i].MethodName < qs[j].MethodName })
625+
// return nil, errors.New("debug")
623626
return qs, nil
624627
}
625628

0 commit comments

Comments
 (0)