Golang Postgres Синтаксическая ошибка белка (SQLSTATE 42601) - PullRequest
0 голосов
/ 03 мая 2020

Я просто пытаюсь вставить свой объект, в котором одно из полей является срезом. Поэтому я построил свой запрос с помощью Squirrel, как показано ниже:

squirrel.StatementBuilder.PlaceholderFormat(squirrel.Dollar).RunWith(db).Insert("educations").
        Columns("id", "school", "city", "state", "degree", "month_start", "year_start", "month_end", "year_end", "order", "logo_url", "created_at", "updated_at", "style", "descriptions").
        Values(
            uuid.Must(uuid.NewV4()).String(),
            education.School,
            education.City,
            education.State,
            education.Degree,
            education.MonthStart,
            education.YearStart,
            education.MonthEnd,
            education.YearEnd,
            education.Order,
            education.LogoURL,
            currentTime,
            currentTime,
            savedStyle.ID,
            pq.Array(education.Descriptions),
        ).
        Suffix("RETURNING *")

Поле description - это просто строка строк. Тем не менее я получаю сообщение об ошибке ERROR: syntax error at or near "order" (SQLSTATE 42601). Нужна еще пара глаз, чтобы увидеть, что идет не так.

Вот результат .To Sql ():

INSERT INTO educations (id,school,city,state,degree,month_start,year_start,month_end,year_end,order,logo_url,
created_at,updated_at,style,descriptions) VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,
$12,$13,$14,$15) RETURNING * [9d54d890-1d24-47a0-a96d-652e525b6c72 XXX University San Jose, CA Bachelor of Science 7 2014 0xc000410450 0xc000410458 0 https://i.imgur.com/123123.png 2020-05-02 19:50:52.626946 -0700 PDT m=+74.496935801 2020-05-02 19:50:52.626946 -0700 PDT m=+74.496935801 0xc000169510 {[0xc0005b34c0 0xc0005b34d0 0xc0005b34e0]}] <nil>
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...