Models generated for views #332
-
I'm generating code for querying my view. CREATE OR REPLACE VIEW odh_camera AS
SELECT
device_uuid,
source_info -> 'uuid' as camera_uuid,
source_info -> 'title' as camera_title,
source_info -> 'orientation' as camera_orientation
FROM (
SELECT uuid as device_uuid,
jsonb_array_elements(cameras.info) as source_info
FROM (
SELECT uuid, info #> '{odh,cameras}' as info
FROM source
) as cameras
) as camera Bob generated this model: // Camera is an object representing the database table.
type Camera struct {
DeviceUUID null.Val[uuid.UUID] `db:"device_uuid" `
CameraUUID null.Val[types.JSON[json.RawMessage]] `db:"camera_uuid" `
CameraTitle null.Val[types.JSON[json.RawMessage]] `db:"camera_title" `
CameraOrientation null.Val[types.JSON[json.RawMessage]] `db:"camera_orientation" `
} DeviceUUID is a primary key of my table source, but it was generated as nullable type. How can i change this behavior and make DeviceUUID NOT NULL? |
Beta Was this translation helpful? Give feedback.
Answered by
stephenafamo
Dec 26, 2024
Replies: 1 comment
-
This is a limitation of Postgres. Postgres reports all columns of views as nullable, and so they are generated as such. |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
stephenafamo
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is a limitation of Postgres.
Postgres reports all columns of views as nullable, and so they are generated as such.