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
uuid is only overridden for the primary keys, but not for the foreign keys.
Relevant log output
type Event struct {
ID uuid.UUID
OrganizerID pgtype.UUID
Name string
Description string
Status string
ImgUrl string
Url string
CreatedAt pgtype.Timestamptz
UpdatedAt pgtype.Timestamptz
}
type Organizer struct {
ID uuid.UUID
Name string
ImgUrl string
Url string
CreatedAt pgtype.Timestamptz
UpdatedAt pgtype.Timestamptz
}
Database schema
CREATETABLEorganizer
(
id uuid DEFAULT gen_random_uuid() PRIMARY KEY,
name VARCHAR(100) NOT NULL,
img_url TEXTNOT NULL,
url TEXTNOT NULL,
created_at TIMESTAMP with time zone DEFAULT now() NOT NULL,
updated_at TIMESTAMP with time zone DEFAULT now() NOT NULL
);
CREATETABLEevent
(
id uuid DEFAULT gen_random_uuid() PRIMARY KEY,
organizer_id uuid REFERENCES organizer (id),
name VARCHAR(100) NOT NULL,
description TEXTNOT NULL,
status VARCHAR(100) NOT NULL,
img_url TEXTNOT NULL,
url TEXTNOT NULL,
created_at TIMESTAMP with time zone DEFAULT now() NOT NULL,
updated_at TIMESTAMP with time zone DEFAULT now() NOT NULL
);
SQL queries
-- name: GetEventById :oneSELECT*FROM event WHERE id = $1;
-- name: GetOrganizerById :manySELECT*FROM organizer WHERE id = $1;
-- name: ListEventsByOrganizer :manySELECT*FROM event WHERE organizer_id = $1;
It's a bit confusing, but the issue is that your foreign key field can be null so you'll need an additional override for nullable uuids.
Note that a single db_type override configuration applies to either nullable or non-nullable columns, but not both. If you want the same Go type to override in both cases, you’ll need to configure two overrides.
Version
1.25.0
What happened?
uuid
is only overridden for the primary keys, but not for the foreign keys.Relevant log output
Database schema
SQL queries
Configuration
Playground URL
No response
What operating system are you using?
macOS
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: