MCPcopy Create free account
hub / github.com/cloudquery/cloudquery / upsert

Method upsert

plugins/destination/sqlite/client/write.go:106–134  ·  view source on GitHub ↗
(sc *arrow.Schema)

Source from the content-addressed store, hash-verified

104}
105
106func (*Client) upsert(sc *arrow.Schema) string {
107 var sb strings.Builder
108 tableName, ok := sc.Metadata().GetValue(schema.MetadataTableName)
109 if !ok {
110 panic("missing table name in schema metadata")
111 }
112 sb.WriteString("insert or replace into ")
113 sb.WriteString(identifier(tableName))
114 sb.WriteString(" (")
115 columns := sc.Fields()
116 columnsLen := len(columns)
117 for i, c := range columns {
118 sb.WriteString(identifier(c.Name))
119 if i < columnsLen-1 {
120 sb.WriteString(",")
121 } else {
122 sb.WriteString(") values (")
123 }
124 }
125 for i := range columns {
126 sb.WriteString(fmt.Sprintf("$%d", i+1))
127 if i < columnsLen-1 {
128 sb.WriteString(",")
129 } else {
130 sb.WriteString(")")
131 }
132 }
133 return sb.String()
134}

Callers 1

insertMessageMethod · 0.95

Calls 2

identifierFunction · 0.70
StringMethod · 0.45

Tested by

no test coverage detected