look through all the structs and attempt to find a matching one to embed We need the name of the struct and its field names.
(embed *plugin.Identifier, structs []Struct, defaultSchema string)
| 125 | // look through all the structs and attempt to find a matching one to embed |
| 126 | // We need the name of the struct and its field names. |
| 127 | func newGoEmbed(embed *plugin.Identifier, structs []Struct, defaultSchema string) *goEmbed { |
| 128 | if embed == nil { |
| 129 | return nil |
| 130 | } |
| 131 | |
| 132 | for _, s := range structs { |
| 133 | embedSchema := defaultSchema |
| 134 | if embed.Schema != "" { |
| 135 | embedSchema = embed.Schema |
| 136 | } |
| 137 | |
| 138 | // compare the other attributes |
| 139 | if embed.Catalog != s.Table.Catalog || embed.Name != s.Table.Name || embedSchema != s.Table.Schema { |
| 140 | continue |
| 141 | } |
| 142 | |
| 143 | fields := make([]Field, len(s.Fields)) |
| 144 | copy(fields, s.Fields) |
| 145 | |
| 146 | return &goEmbed{ |
| 147 | modelType: s.Name, |
| 148 | modelName: s.Name, |
| 149 | fields: fields, |
| 150 | } |
| 151 | } |
| 152 | |
| 153 | return nil |
| 154 | } |
| 155 | |
| 156 | func columnName(c *plugin.Column, pos int) string { |
| 157 | if c.Name != "" { |