-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Open
Labels
bugSomething isn't workingSomething isn't workingdrizzle/kitpriorityWill be worked on nextWill be worked on next
Description
Report hasn't been filed before.
- I have verified that the bug I'm about to report hasn't been filed before.
What version of drizzle-orm are you using?
0.40.0
What version of drizzle-kit are you using?
0.30.5
Other packages
No response
Describe the Bug
When introspecting a postgres database schema using bun drizzle-kit pull, the introspected views does not have notNull() even if it's NOT NULL in the original tables.
Example:
SQL schema file:
CREATE TABLE "students" (
"student_id" serial PRIMARY KEY,
"full_name_ar" TEXT NOT NULL,
);
-- Same thing with other tables
CREATE VIEW admin_applications_list AS
SELECT
a.application_id,
s.full_name_ar AS student_name,
r.academic_degree,
d.title AS department,
a.is_admin_accepted
FROM
applications a
JOIN students s USING (student_id)
JOIN registerations r USING (application_id)
JOIN departments d ON d.department_id = r.department_id;Drizzle schema file:
export const adminApplicationsList = pgView("admin_applications_list", { applicationId: integer("application_id"),
studentName: text("student_name"),
academicDegree: departmentType("academic_degree"),
department: text(),
isAdminAccepted: boolean("is_admin_accepted"),
}).as(sql`SELECT a.application_id, s.full_name_ar AS student_name, r.academic_degree, d.title AS department, a.is_admin_accepted FROM applications a JOIN students s USING (student_id) JOIN registerations r USING (application_id) JOIN departments d ON d.department_id = r.department_id`);The problem with this is when combining it with drizzle-zod for example, it makes all fields nullable which isn't a desired behavior for end-to-end safety for example (RPC Clients)
// Resulted type from Zod schema
type ApplicationsList = {
applicationId: number | null;
isAdminAccepted: boolean | null;
academicDegree: "diploma" | "master" | "phd" | null;
studentName: string | null;
department: string | null;
}[]If it's a limitation is there a way at least to auto-add notNulls on views instead of adding them manually? Thanks in advance.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingdrizzle/kitpriorityWill be worked on nextWill be worked on next