You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
I'll start with the SQL I'm trying to create/execute
WITH ins1 AS (
INSERT INTO account (
email,
status,
uuid)
VALUES(
'email@email.com',
'active',
'XXX-XXX-XXXXX')
RETURNING
*
),
ins2 AS (
INSERT INTO account_user (account_id,
user_id)
SELECT
id,
6FROM
ins1
)
SELECT*FROM
ins1
The goal with the above SQL is to insert into one table, insert the returned data to a join table, and finally, return all the columns from the first row/execution.
To Reproduce
goqu.Dialect("postgres").
From("ins1").
With("ins1",
goqu.Dialect("postgres").
Insert("account").
Rows(Account{Email:"email@email.com", Status:"active",UUID:"XXX-XXX-XXXX"}).
Returning("*"),
).
With("ins2",
goqu.Dialect("postgres").
Insert("account_user").
Cols("account_id", "user_id").
FromQuery(goqu.Dialect("postgres").
From("ins1").
Select(
"id",
goqu.V(req.UserID),
),
).
Returning("user_id"), // will panic if not included even though I don't need the return
).
Select("*").ToSQL()
The above works, however, the Returning clause on the second With clause is required even though I don't need to do anything with it. If a Returning clause isn't present within a with clause, goqu will panic. It took a lot of banging my head against the wall trying to figure out why it's panicing since I'm not using any of the data therefore I wasn't including a return clause.
Dialect:
postgres
mysql
sqlite3
The text was updated successfully, but these errors were encountered:
Describe the bug
I'll start with the SQL I'm trying to create/execute
The goal with the above SQL is to insert into one table, insert the returned data to a join table, and finally, return all the columns from the first row/execution.
To Reproduce
The above works, however, the
Returning
clause on the secondWith
clause is required even though I don't need to do anything with it. If aReturning
clause isn't present within a with clause, goqu will panic. It took a lot of banging my head against the wall trying to figure out why it's panicing since I'm not using any of the data therefore I wasn't including a return clause.Dialect:
The text was updated successfully, but these errors were encountered: