There is no need for array_to_string() in tags

This commit is contained in:
jordi fita mas 2023-05-27 21:36:10 +02:00
parent 27a266097a
commit 07a28639f2
4 changed files with 8 additions and 8 deletions

View File

@ -390,7 +390,7 @@ func (form *contactForm) MustFillFromDatabase(ctx context.Context, conn *Conn, s
, province
, postal_code
, country_code
, array_to_string(tags, ',')
, tags
from contact
where slug = $1
`, slug).Scan(
@ -414,7 +414,7 @@ func ServeEditContactTags(w http.ResponseWriter, r *http.Request, params httprou
company := getCompany(r)
slug := params[0].Value
form := newTagsForm(companyURI(company, "/contacts/"+slug+"/tags"), slug, locale)
if notFoundErrorOrPanic(conn.QueryRow(r.Context(), `select array_to_string(tags, ',') from contact where slug = $1`, form.Slug).Scan(form.Tags)) {
if notFoundErrorOrPanic(conn.QueryRow(r.Context(), `select tags from contact where slug = $1`, form.Slug).Scan(form.Tags)) {
http.NotFound(w, r)
return
}

View File

@ -241,7 +241,7 @@ func (form *expenseForm) MustFillFromDatabase(ctx context.Context, conn *Conn, s
, invoice_date
, to_price(amount, decimal_digits)
, array_agg(tax_id)
, array_to_string(tags, ',')
, tags
from expense
left join expense_tax using (expense_id)
join currency using (currency_code)
@ -397,7 +397,7 @@ func ServeEditExpenseTags(w http.ResponseWriter, r *http.Request, params httprou
company := getCompany(r)
slug := params[0].Value
form := newTagsForm(companyURI(company, "/expenses/"+slug+"/tags"), slug, locale)
if notFoundErrorOrPanic(conn.QueryRow(r.Context(), `select array_to_string(tags, ',') from expense where slug = $1`, form.Slug).Scan(form.Tags)) {
if notFoundErrorOrPanic(conn.QueryRow(r.Context(), `select tags from expense where slug = $1`, form.Slug).Scan(form.Tags)) {
http.NotFound(w, r)
return
}

View File

@ -722,7 +722,7 @@ func (form *invoiceForm) MustFillFromDatabase(ctx context.Context, conn *Conn, s
, invoice_date
, notes
, payment_method_id
, array_to_string(tags, ',')
, tags
from invoice
where slug = $1
`, slug).Scan(&invoiceId, form.InvoiceStatus, form.Customer, &form.Number, form.Date, form.Notes, form.PaymentMethod, form.Tags)) {
@ -1066,7 +1066,7 @@ func ServeEditInvoiceTags(w http.ResponseWriter, r *http.Request, params httprou
company := getCompany(r)
slug := params[0].Value
form := newTagsForm(companyURI(company, "/invoices/"+slug+"/tags"), slug, locale)
if notFoundErrorOrPanic(conn.QueryRow(r.Context(), `select array_to_string(tags, ',') from invoice where slug = $1`, form.Slug).Scan(form.Tags)) {
if notFoundErrorOrPanic(conn.QueryRow(r.Context(), `select tags from invoice where slug = $1`, form.Slug).Scan(form.Tags)) {
http.NotFound(w, r)
return
}

View File

@ -321,7 +321,7 @@ func (form *productForm) MustFillFromDatabase(ctx context.Context, conn *Conn, s
, product.description
, to_price(price, decimal_digits)
, array_agg(tax_id)
, array_to_string(tags, ',')
, tags
from product
left join product_tax using (product_id)
join company using (company_id)
@ -359,7 +359,7 @@ func ServeEditProductTags(w http.ResponseWriter, r *http.Request, params httprou
company := getCompany(r)
slug := params[0].Value
form := newTagsForm(companyURI(company, "/products/"+slug+"/tags"), slug, locale)
if notFoundErrorOrPanic(conn.QueryRow(r.Context(), `select array_to_string(tags, ',') from product where slug = $1`, form.Slug).Scan(form.Tags)) {
if notFoundErrorOrPanic(conn.QueryRow(r.Context(), `select tags from product where slug = $1`, form.Slug).Scan(form.Tags)) {
http.NotFound(w, r)
return
}