Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SQLite UPDATE FROM statements not supported #3132

Open
alexbakker opened this issue Jan 13, 2024 · 2 comments · May be fixed by #3610
Open

SQLite UPDATE FROM statements not supported #3132

alexbakker opened this issue Jan 13, 2024 · 2 comments · May be fixed by #3610
Labels
bug Something isn't working

Comments

@alexbakker
Copy link

Version

1.25.0

What happened?

I tried to use a SQLite UPDATE FROM statement, but sqlc failed to parse it.

Relevant log output

line 4:0 extraneous input 'FROM' expecting {<EOF>, ';', ALTER_, ANALYZE_, ATTACH_, BEGIN_, COMMIT_, CREATE_, DEFAULT_, DELETE_, DETACH_, DROP_, END_, EXPLAIN_, INSERT_, PRAGMA_, REINDEX_, RELEASE_, REPLACE_, ROLLBACK_, SAVEPOINT_, SELECT_, UPDATE_, VACUUM_, VALUES_, WITH_}
line 4:27 no viable alternative at input 'node'
# package 
query.sql:1:1: no viable alternative at input 'node'

Database schema

CREATE TABLE node (
  id   INTEGER PRIMARY KEY,
  name TEXT NOT NULL
);

CREATE TABLE node_address (
  id INTEGER PRIMARY KEY,
  node_id INTEGER NOT NULL,
  hostport TEXT NOT NULL,
  pinged_at REAL,
  FOREIGN KEY (node_id) REFERENCES node (id)
);

SQL queries

-- name: PingNodeAddress :exec
UPDATE node_address
SET pinged_at = unixepoch('subsec')
FROM (SELECT id, name FROM node) AS n
WHERE node_address.node_id = n.id AND node_address.hostport = ? AND n.name = ?;

Configuration

{
  "version": "2",
  "sql": [{
    "schema": "schema.sql",
    "queries": "query.sql",
    "engine": "sqlite",
    "gen": {
      "go": {
        "out": "db"
      }
    }
  }]
}

Playground URL

https://play.sqlc.dev/p/b3a24492f28da8e2fa4189d99731f42a02e7f481d7ac7a6aaeca4eaf1c979ec3

What operating system are you using?

Linux

What database engines are you using?

SQLite

What type of code are you generating?

Go

@alexbakker alexbakker added bug Something isn't working triage New issues that hasn't been reviewed labels Jan 13, 2024
@Voles
Copy link

Voles commented Apr 18, 2024

@alexbakker I'm also running into this. Did you manage to find a workaround?

@kyleconroy kyleconroy removed the triage New issues that hasn't been reviewed label Aug 5, 2024
@IdoKendo
Copy link

IdoKendo commented Sep 3, 2024

I'm also running into this issue, is there any effort on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants