volatiletech / sqlboiler

Generate a Go ORM tailored to your database schema.
BSD 3-Clause "New" or "Revised" License
6.74k stars 545 forks source link

Issue with Update on object (empty column names): models: unable to update <table> row: pq: zero-length delimited identifier at or near """" #1275

Open simon-connektica opened 1 year ago

simon-connektica commented 1 year ago

I have a runtime error with an Update call, there are extra empty column names in the query which leads to a PG error:

models: unable to update station row: pq: zero-length delimited identifier at or near """"

What version of SQLBoiler are you using (sqlboiler --version)?

v4.12.2

What is your database and version (eg. Postgresql 10)

Postgres 15

If this happened at runtime what code produced the issue? (if not applicable leave blank)

m, err := models.Stations(models.StationWhere.ID.EQ(req.Id)).One(ctx, db)
if err != nil {
    return nil, err
}

m.Name = req.Name
m.Description = req.Description
m.Queue = req.Queue

rowsAff, err := m.Update(ctx, db, boil.Greylist(models.StationColumns.Name, models.StationColumns.Description, models.StationColumns.Queue))
if err != nil {
    return nil, err
}

What is the output of the command above with the -d flag added to it? (Provided you are comfortable sharing this, it contains a blueprint of your schema)

UPDATE "station" SET "name"=$1,"title"=$2,"description"=$3,"queue"=$4,"create_time"=$5,"update_time"=$6,""=$7,""=$8,""=$9 WHERE "id"=$10
[NewName StationTitle NewDescription NewQueue 2023-05-23 21:07:07.066346 +0000 +0000 2023-05-23 21:07:07.066346 +0000 +0000 0xc000430950 0xc000430960 0xc000430970 acdfb748-aee1-420e-9892-1ace318cc984]

I'm not sure what's going here, there are empty columns being added to the update.

Please provide a relevant database schema so we can replicate your issue (Provided you are comfortable sharing this)

CREATE TABLE station (
    id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
    name TEXT NOT NULL,
    title TEXT NOT NULL,
    description TEXT NOT NULL,
    queue TEXT NOT NULL,
    create_time TIMESTAMP NOT NULL DEFAULT NOW(),
    update_time TIMESTAMP NOT NULL DEFAULT NOW(),
    UNIQUE (name)
);

Further information. What did you do, what did you expect?

It should update the row without having empty columns.

simon-connektica commented 1 year ago

There's no issue if I use boil.Infer() instead of boil.Greylist. Did I misunderstand how to use the Greylist with update?