MCPcopy Create free account
hub / github.com/araddon/qlbridge / TableToString

Function TableToString

datasource/sqlite/schemawriter.go:44–60  ·  view source on GitHub ↗

TableToString Table output a CREATE TABLE statement using mysql dialect.

(tbl *schema.Table)

Source from the content-addressed store, hash-verified

42
43// TableToString Table output a CREATE TABLE statement using mysql dialect.
44func TableToString(tbl *schema.Table) string {
45
46 w := &bytes.Buffer{}
47 //u.Infof("%s tbl=%p fields? %#v fields?%v", tbl.Name, tbl, tbl.FieldMap, len(tbl.Fields))
48 fmt.Fprintf(w, "CREATE TABLE `%s` (", tbl.Name)
49 for i, fld := range tbl.Fields {
50 if i != 0 {
51 w.WriteByte(',')
52 }
53 fmt.Fprint(w, "\n ")
54 WriteField(w, fld)
55 }
56 fmt.Fprint(w, "\n);")
57 //tblStr := fmt.Sprintf("CREATE TABLE `%s` (\n\n);", tbl.Name, strings.Join(cols, ","))
58 //return tblStr, nil
59 return w.String()
60}
61
62// WriteField write a schema.Field as string output for sqlite create statement
63//

Callers 2

LoadTestDataOnceFunction · 0.92
TableMethod · 0.85

Calls 2

WriteFieldFunction · 0.85
StringMethod · 0.65

Tested by 1

LoadTestDataOnceFunction · 0.74