update sqlc gen

This commit is contained in:
Pavel 2024-04-22 17:43:11 +03:00
parent 87cdea8e08
commit 33c04c20f3
2 changed files with 23 additions and 15 deletions

@ -763,7 +763,7 @@ WHERE f.amoID = (update_data ->> 'AmoID')::INT
-- name: CheckTags :many
WITH user_data AS (
SELECT AmoID
SELECT AmoID, AccountID
FROM users
WHERE users.AccountID = $1
), new_tags AS (
@ -785,8 +785,9 @@ WITH user_data AS (
ON CONFLICT (amoID, accountID, Entity) DO NOTHING
RETURNING *
)
SELECT nt.*
SELECT nt.*,ud.AccountID
FROM new_tags nt
JOIN user_data ud ON true
WHERE NOT EXISTS (
SELECT *
FROM inserted_tags ins
@ -823,7 +824,7 @@ WHERE NOT EXISTS (
-- name: CheckFields :many
WITH user_data AS (
SELECT AmoID
SELECT AmoID, AccountID
FROM users
WHERE users.AccountID = $1
), new_fields AS (
@ -848,8 +849,9 @@ WITH user_data AS (
ON CONFLICT (amoID, accountID, entity) DO NOTHING
RETURNING *
)
SELECT nf.*
SELECT nf.*,ud.AccountID
FROM new_fields nf
JOIN user_data ud ON true
WHERE NOT EXISTS (
SELECT *
FROM inserted_fields ins
@ -928,4 +930,4 @@ WITH user_data AS (
JOIN user_data ud ON true
RETURNING *
)
SELECT * from inserted_utms;
SELECT * from inserted_utms;

@ -168,7 +168,7 @@ func (q *Queries) CheckExpired(ctx context.Context) ([]Token, error) {
const checkFields = `-- name: CheckFields :many
WITH user_data AS (
SELECT AmoID
SELECT AmoID, AccountID
FROM users
WHERE users.AccountID = $1
), new_fields AS (
@ -193,10 +193,11 @@ WITH user_data AS (
ON CONFLICT (amoID, accountID, entity) DO NOTHING
RETURNING id, amoid, code, accountid, name, entity, type, deleted, createdat
)
SELECT nf.amoid, nf.code, nf.name, nf.entity, nf.type, nf.createdat
SELECT nf.amoid, nf.code, nf.name, nf.entity, nf.type, nf.createdat,ud.AccountID
FROM new_fields nf
JOIN user_data ud ON true
WHERE NOT EXISTS (
SELECT id, ins.amoid, code, accountid, name, entity, type, deleted, createdat, ud.amoid
SELECT id, ins.amoid, code, ins.accountid, name, entity, type, deleted, createdat, ud.amoid, ud.accountid
FROM inserted_fields ins
JOIN user_data ud ON true
WHERE ins.amoID = nf.amoID AND ins.accountID = ud.amoid AND ins.Entity = nf.Entity
@ -215,6 +216,7 @@ type CheckFieldsRow struct {
Entity interface{} `db:"entity" json:"entity"`
Type string `db:"type" json:"type"`
Createdat interface{} `db:"createdat" json:"createdat"`
Accountid string `db:"accountid" json:"accountid"`
}
func (q *Queries) CheckFields(ctx context.Context, arg CheckFieldsParams) ([]CheckFieldsRow, error) {
@ -233,6 +235,7 @@ func (q *Queries) CheckFields(ctx context.Context, arg CheckFieldsParams) ([]Che
&i.Entity,
&i.Type,
&i.Createdat,
&i.Accountid,
); err != nil {
return nil, err
}
@ -452,7 +455,7 @@ func (q *Queries) CheckSteps(ctx context.Context, dollar_1 json.RawMessage) ([]C
const checkTags = `-- name: CheckTags :many
WITH user_data AS (
SELECT AmoID
SELECT AmoID, AccountID
FROM users
WHERE users.AccountID = $1
), new_tags AS (
@ -474,10 +477,11 @@ WITH user_data AS (
ON CONFLICT (amoID, accountID, Entity) DO NOTHING
RETURNING id, amoid, accountid, entity, name, color, deleted, createdat
)
SELECT nt.amoid, nt.entity, nt.name, nt.color
SELECT nt.amoid, nt.entity, nt.name, nt.color,ud.AccountID
FROM new_tags nt
JOIN user_data ud ON true
WHERE NOT EXISTS (
SELECT id, ins.amoid, accountid, entity, name, color, deleted, createdat, ud.amoid
SELECT id, ins.amoid, ins.accountid, entity, name, color, deleted, createdat, ud.amoid, ud.accountid
FROM inserted_tags ins
JOIN user_data ud ON true
WHERE ins.amoID = nt.amoID AND ins.accountID = ud.amoid AND ins.Entity = nt.Entity
@ -490,10 +494,11 @@ type CheckTagsParams struct {
}
type CheckTagsRow struct {
Amoid int32 `db:"amoid" json:"amoid"`
Entity interface{} `db:"entity" json:"entity"`
Name string `db:"name" json:"name"`
Color string `db:"color" json:"color"`
Amoid int32 `db:"amoid" json:"amoid"`
Entity interface{} `db:"entity" json:"entity"`
Name string `db:"name" json:"name"`
Color string `db:"color" json:"color"`
Accountid string `db:"accountid" json:"accountid"`
}
func (q *Queries) CheckTags(ctx context.Context, arg CheckTagsParams) ([]CheckTagsRow, error) {
@ -510,6 +515,7 @@ func (q *Queries) CheckTags(ctx context.Context, arg CheckTagsParams) ([]CheckTa
&i.Entity,
&i.Name,
&i.Color,
&i.Accountid,
); err != nil {
return nil, err
}