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

sqlc compile does not report issues in sql files #3703

Open
zbelial opened this issue Nov 12, 2024 · 3 comments
Open

sqlc compile does not report issues in sql files #3703

zbelial opened this issue Nov 12, 2024 · 3 comments
Labels

Comments

@zbelial
Copy link

zbelial commented Nov 12, 2024

Version

1.27.0

What happened?

I wanted to use sqlc compile to check sql syntax errors, but I didn't get what I expected.

The following schema and queries were copied from sqlc document to used for testing.

Could you please help me figure out where the problem was? thanks.

Relevant log output

nothing

Database schema

CREATE TABLE authors (
  id   BIGINT  NOT NULL AUTO_INCREMENT PRIMARY KEY,
  name text    NOT NULL,
  bio  text
);

SQL queries

-- name: GetAuthor :one
SELECT * FROM authors
WHERE id = ? LIMIT 1;

-- name: ListAuthors :many
SELECT * FROM authors
ORDER BY name;

-- name: CreateAuthor :execresult
INSERT INTO authors (
  name, bio
) VALUES (
  ?, ?
);

-- name: DeleteAuthor :exec
DELETE FROM authors
WHERE id = ?;

Configuration

version: "2"
sql:
  - engine: "postgresql"
    queries: "query-pg.sql"
    schema: "schema-pg.sql"

Playground URL

No response

What operating system are you using?

Linux

What database engines are you using?

PostgreSQL

What type of code are you generating?

No response

@zbelial zbelial added the bug Something isn't working label Nov 12, 2024
@kyleconroy
Copy link
Collaborator

I'm going to need a bit more information here to help you out.

sqlc compile doesn't print anything on success. If there is a problem with your queries, it will print the error and exit with a non-zero code.

@zbelial
Copy link
Author

zbelial commented Dec 12, 2024

Sorry for the late reply.

I meant the queries in my first comment have some problems ( for example, there are "?" which aren't valid sql ), but sql compile did print anything.

If you need more information, please tell me, thanks.

@benjaco
Copy link

benjaco commented Dec 31, 2024

the ? placeholders are standard for prepared statements in sql. they’re just placeholders that get replaced with actual values when the query runs. sqlc expects these and validates them without issues, so if no errors showed up

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants