Fix extra comma bug in mutations

This commit is contained in:
Vikram Rangnekar 2020-01-02 01:54:25 -05:00
parent 5803395bd5
commit 7a5cf47486
5 changed files with 33 additions and 6 deletions

View File

@ -520,7 +520,20 @@ query {
}
```
### Advanced queries
### Sorting
To sort or ordering results just use the `order_by` argument. This can be combined with `where`, `search`, etc to build complex queries to fit you needs.
```graphql
query {
products(order_by: { cached_votes_total: desc }) {
id
name
}
}
```
### Filtering
Super Graph support complex queries where you can add filters, ordering,offsets and limits on the query. For example the below query will list all products where the price is greater than 10 and the id is not 5.

View File

@ -131,7 +131,6 @@ func nestedInsertRelColumnsMap(item kvitem) map[string]struct{} {
func renderNestedInsertRelColumns(w io.Writer, item kvitem, values bool) error {
if len(item.items) == 0 {
if item.relPC != nil && item.relPC.Type == RelOneToMany {
io.WriteString(w, `, `)
if values {
colWithTable(w, item.relPC.Left.Table, item.relPC.Left.Col)
} else {
@ -141,14 +140,18 @@ func renderNestedInsertRelColumns(w io.Writer, item kvitem, values bool) error {
} else {
// Render child foreign key columns if child-to-parent
// relationship is one-to-many
i := 0
for _, v := range item.items {
if v.relCP.Type == RelOneToMany {
io.WriteString(w, `, `)
if i != 0 {
io.WriteString(w, `, `)
}
if values {
colWithTable(w, v.relCP.Left.Table, v.relCP.Left.Col)
} else {
quoted(w, v.relCP.Right.Col)
}
i++
}
}
}

View File

@ -360,6 +360,7 @@ func renderInsertUpdateColumns(w io.Writer,
values bool) (uint32, error) {
root := &qc.Selects[0]
renderedCol := false
n := 0
for _, cn := range ti.Columns {
@ -386,6 +387,10 @@ func renderInsertUpdateColumns(w io.Writer,
} else {
quoted(w, cn.Name)
}
if !renderedCol {
renderedCol = true
}
n++
}
@ -407,10 +412,17 @@ func renderInsertUpdateColumns(w io.Writer,
io.WriteString(w, root.PresetMap[cn])
io.WriteString(w, `' :: `)
io.WriteString(w, col.Type)
} else {
quoted(w, cn)
}
if !renderedCol {
renderedCol = true
}
}
if len(skipcols) != 0 && renderedCol {
io.WriteString(w, `, `)
}
return 0, nil
}

View File

@ -164,7 +164,6 @@ func renderNestedUpdateRelColumns(w io.Writer, item kvitem, values bool) error {
// relationship is one-to-many
for _, v := range item.items {
if v._ctype > 0 && v.relCP.Type == RelOneToMany {
io.WriteString(w, `, `)
if values {
colWithTable(w, v.relCP.Left.Table, v.relCP.Left.Col)
} else {

View File

@ -203,7 +203,7 @@ func cmdDBMigrate(cmd *cobra.Command, args []string) {
}
if err != nil {
logger.Info().Err(err).Send()
logger.Fatal().Err(err).Send()
// if err, ok := err.(m.MigrationPgError); ok {
// if err.Detail != "" {