sqlc icon indicating copy to clipboard operation
sqlc copied to clipboard

column reference not found: if you want to skip this validation, set 'strict_order_by' to false

Open G1tQuality opened this issue 8 months ago • 2 comments

Version

1.28.0

What happened?

I have read some issues related to this but I can't fix it while using the latest version. There is this column in my pgSQL server and the following query was successfully run.

Relevant log output

sql\queries\feeds.sql:17:1: column reference "last_fetched_at" not found: if you want to skip this validation, set 'strict_order_by' to false

Database schema

-- +goose Up
CREATE TABLE feeds(
    id UUID PRIMARY KEY,
    created_at TIMESTAMP NOT NULL,
    updated_at TIMESTAMP NOT NULL,
    name TEXT NOT NULL,
    url TEXT UNIQUE NOT NULL,
    user_id UUID NOT NULL REFERENCES users(id) ON DELETE CASCADE
    );
-- +goose Down
DROP TABLE feeds;
-- +goose up
ALTER TABLE feeds ADD COLUMN last_fetched_at TIMESTAMP;

-- +goose down
ALTER TABLE feeds DROP COLUMN last_fetched_at;

SQL queries

-- name: CreateFeed :one
INSERT INTO feeds (id, created_at, updated_at, name, url, user_id)
VALUES (
    $1,
    $2,
    $3,
    $4,
    $5,
    $6
)
RETURNING *;

-- name: GetFeeds :many
SELECT * FROM feeds;

-- name: GetNextFeedsToFetch :many
SELECT * FROM feeds
ORDER BY last_fetched_at ASC NULLS FIRST
LIMIT $1;

Configuration

version: "2"
sql:
  - schema: "sql/schema"
    queries: "sql/queries"
    engine: "postgresql"
    gen:
      go:
        out: "internal/database"

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

G1tQuality avatar Feb 24 '25 07:02 G1tQuality