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
-- name: UpdateChapter :oneUPDATE chapters
SET name = coalesce(sqlc.narg('name'), name),
content = coalesce(sqlc.narg('content'), content)
WHERE id =sqlc.arg('id')
RETURNING *;
It does not work.
Relevant log output
$ sqlc generate
line 26:29 no viable alternative at input ';\n\n-- name: UpdateChapter :one\nUPDATE chapters\nSET name = coalesce(sqlc.narg('
line 26:29 no viable alternative at input 'UPDATE chapters\nSET name = coalesce(sqlc.narg('# package main
D:\Fang\repos\gobook\db\queries\chapters.sql:1:1: no viable alternative at input 'UPDATE chapters\nSET name = coalesce(sqlc.narg('
Database schema
CREATETABLEIF NOT EXISTS books (
id INTEGERPRIMARY KEY AUTOINCREMENT,
name textNOT NULL,
author text,
created_at DATETIME DEFAULT CURRENT_TIMESTAMPNOT NULL,
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP
);
CREATETABLEIF NOT EXISTS chapters (
id INTEGERPRIMARY KEY AUTOINCREMENT,
name textNOT NULL,
book_id INTEGERNOT NULL,
content text,
created_at DATETIME DEFAULT CURRENT_TIMESTAMPNOT NULL,
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP
);
ALTERTABLE books ADD summary text;
ALTERTABLE books ADD deleted_at DATETIME;
CREATETABLEIF NOT EXISTS chapters (
id INTEGERPRIMARY KEY AUTOINCREMENT,
book_id INTEGERNOT NULL,
name TEXTNOT NULL,
content TEXTNOT NULL,
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
deleted_at DATETIME
);
ALTERTABLE chapters
ADD COLUMN parent_id
INTEGER DEFAULT 0NOT NULL;
ALTERTABLE chapters
ADD COLUMN deleted_at DATETIME;
SQL queries
-- name: ListChapters :manySELECT*FROM chapters
WHERE book_id = ?
AND deleted_at IS NULLORDER BY id;
-- name: CreateChapter :oneINSERT INTO chapters (
book_id,
name,
content
) VALUES (
?,
?,
?
)
RETURNING *;
-- name: DeleteChapter :execUPDATE chapters
SET deleted_at =date('now')
WHERE id = ?;
-- name: UpdateChapter :oneUPDATE chapters
SET name = coalesce(sqlc.narg('name'), name),
content = coalesce(sqlc.narg('content'), content)
WHERE id =sqlc.arg('id')
RETURNING *;
hey @kyleconroy I would love for sqlc.narg to work with sqlite. Is there anything I can do to help? If you have an idea of what it would take to implement this and can give me some pointers to get started, I can take a stab at a PR.
Version
1.15.0
What happened?
It does not work.
Relevant log output
Database schema
SQL queries
Configuration
Playground URL
No response
What operating system are you using?
Windows
What database engines are you using?
PostgreSQL
What type of code are you generating?
Go
The text was updated successfully, but these errors were encountered: