MCPcopy
hub / github.com/dosco/graphjin / RenderReturning

Method RenderReturning

core/internal/dialect/sqlite.go:718–738  ·  view source on GitHub ↗
(ctx Context, m *qcode.Mutate)

Source from the content-addressed store, hash-verified

716}
717
718func (d *SQLiteDialect) RenderReturning(ctx Context, m *qcode.Mutate) {
719 // SQLite 3.35+ supports RETURNING clause
720 // Return a JSON object with the ID for the execution layer to parse
721 if m.Ti.HasCompositePK() {
722 ctx.WriteString(` RETURNING json_object(`)
723 for i, pkCol := range m.Ti.PrimaryCols {
724 if i > 0 {
725 ctx.WriteString(`, `)
726 }
727 ctx.WriteString(`'`)
728 ctx.WriteString(pkCol.Name)
729 ctx.WriteString(`', `)
730 ctx.Quote(pkCol.Name)
731 }
732 ctx.WriteString(`)`)
733 } else {
734 ctx.WriteString(` RETURNING json_object('id', `)
735 ctx.Quote(m.Ti.PrimaryCol.Name)
736 ctx.WriteString(`)`)
737 }
738}
739
740func (d *SQLiteDialect) RenderAssign(ctx Context, col string, val string) {
741 ctx.WriteString(col)

Callers 3

RenderInsertMethod · 0.95
RenderLinearInsertMethod · 0.95
RenderLinearUpdateMethod · 0.95

Calls 3

HasCompositePKMethod · 0.80
WriteStringMethod · 0.65
QuoteMethod · 0.65

Tested by

no test coverage detected