hm sqlite transactions dont play with begin commit
This commit is contained in:
@@ -128,20 +128,20 @@ func (f *Feeds) Get(ctx context.Context, id string) (Feed, error) {
|
||||
versions.created_at AS "Version.Created",
|
||||
versions.url AS "Version.URL",
|
||||
versions.cron AS "Version.Cron",
|
||||
(
|
||||
SELECT executed_at
|
||||
FROM "feed.executions"
|
||||
WHERE entries_id = entry.ID
|
||||
(
|
||||
SELECT executed_at
|
||||
FROM "feed.executions"
|
||||
WHERE entries_id = entry.ID
|
||||
ORDER BY executed_at DESC
|
||||
LIMIT 1
|
||||
) AS "Execution.Executed",
|
||||
(
|
||||
SELECT versions_created_at
|
||||
FROM "feed.executions"
|
||||
WHERE entries_id = entry.ID
|
||||
) AS "Execution.Executed",
|
||||
(
|
||||
SELECT versions_created_at
|
||||
FROM "feed.executions"
|
||||
WHERE entries_id = entry.ID
|
||||
ORDER BY executed_at DESC
|
||||
LIMIT 1
|
||||
) AS "Execution.Version"
|
||||
) AS "Execution.Version"
|
||||
FROM entry
|
||||
JOIN "feed.versions" version_entries_id ON
|
||||
version_entries_id.entries_id=entry.ID
|
||||
@@ -196,22 +196,21 @@ func (f *Feeds) oldGet(ctx context.Context, id string) (Feed, error) {
|
||||
func (f *Feeds) Insert(ctx context.Context, url, cron string) (string, error) {
|
||||
now := time.Now()
|
||||
id := uuid.New().String()
|
||||
q := `
|
||||
BEGIN;
|
||||
INSERT INTO "feed.entries" (
|
||||
id,
|
||||
created_at,
|
||||
updated_at
|
||||
) VALUES (?, ?, ?);
|
||||
INSERT INTO "feed.versions" (
|
||||
entries_id,
|
||||
created_at,
|
||||
url,
|
||||
cron
|
||||
) VALUES (?, ?, ?, ?);
|
||||
COMMIT;
|
||||
`
|
||||
return id, db.Exec(ctx, q,
|
||||
return id, db.Exec(ctx, `
|
||||
BEGIN;
|
||||
INSERT INTO "feed.entries" (
|
||||
id,
|
||||
created_at,
|
||||
updated_at
|
||||
) VALUES ($1, $2, $3);
|
||||
INSERT INTO "feed.versions" (
|
||||
entries_id,
|
||||
created_at,
|
||||
url,
|
||||
cron
|
||||
) VALUES ($4, $5, $6, $7);
|
||||
COMMIT;
|
||||
`,
|
||||
id, now, now,
|
||||
id, now, url, cron,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user