MCPcopy Index your code
hub / github.com/go-dev-frame/sponge / setOptions

Function setOptions

pkg/sql2code/sql2code.go:126–191  ·  view source on GitHub ↗
(args *Args)

Source from the content-addressed store, hash-verified

124}
125
126func setOptions(args *Args) []parser.Option {
127 var opts []parser.Option
128
129 if args.DBDriver != "" {
130 opts = append(opts, parser.WithDBDriver(args.DBDriver))
131 }
132 if args.fieldTypes != nil {
133 opts = append(opts, parser.WithFieldTypes(args.fieldTypes))
134 }
135
136 if args.Charset != "" {
137 opts = append(opts, parser.WithCharset(args.Charset))
138 }
139 if args.Collation != "" {
140 opts = append(opts, parser.WithCollation(args.Collation))
141 }
142 if args.JSONTag {
143 opts = append(opts, parser.WithJSONTag(args.JSONNamedType))
144 }
145 if args.TablePrefix != "" {
146 opts = append(opts, parser.WithTablePrefix(args.TablePrefix))
147 }
148 if args.ColumnPrefix != "" {
149 opts = append(opts, parser.WithColumnPrefix(args.ColumnPrefix))
150 }
151 if args.NoNullType {
152 opts = append(opts, parser.WithNoNullType())
153 }
154 if args.IsEmbed {
155 opts = append(opts, parser.WithEmbed())
156 }
157 if args.IsWebProto {
158 opts = append(opts, parser.WithWebProto())
159 }
160
161 if args.NullStyle != "" {
162 switch args.NullStyle {
163 case "sql":
164 opts = append(opts, parser.WithNullStyle(parser.NullInSql))
165 case "ptr":
166 opts = append(opts, parser.WithNullStyle(parser.NullInPointer))
167 default:
168 fmt.Printf("invalid null style: %s\n", args.NullStyle)
169 return nil
170 }
171 } else {
172 opts = append(opts, parser.WithNullStyle(parser.NullDisable))
173 }
174 if args.Package != "" {
175 opts = append(opts, parser.WithPackage(args.Package))
176 }
177 if args.GormType {
178 opts = append(opts, parser.WithGormType())
179 }
180 if args.ForceTableName {
181 opts = append(opts, parser.WithForceTableName())
182 }
183 if args.IsExtendedAPI {

Callers 2

GenerateFunction · 0.85
Test_setOptionsFunction · 0.85

Calls 15

WithDBDriverFunction · 0.92
WithFieldTypesFunction · 0.92
WithCharsetFunction · 0.92
WithCollationFunction · 0.92
WithJSONTagFunction · 0.92
WithTablePrefixFunction · 0.92
WithColumnPrefixFunction · 0.92
WithNoNullTypeFunction · 0.92
WithEmbedFunction · 0.92
WithWebProtoFunction · 0.92
WithNullStyleFunction · 0.92
WithPackageFunction · 0.92

Tested by 1

Test_setOptionsFunction · 0.68