Closed SamuelMarks closed 1 month ago
I cannot reproduce this locally. Additionally diesel does "only" query the database to get information whether or not a column is nullable. So if your schema.rs file says that the column is nullable the database considers it to be nullable. You should be able to verify this by using the following query:
SELECT "information_schema"."columns"."column_name", "information_schema"."columns"."udt_name", "information_schema"."columns"."udt_schema", "information_schema"."columns"."is_nullable", "information_schema"."columns"."character_maximum_length", col_description('users'::regclass, "information_schema"."columns"."ordinal_position") FROM "information_schema"."columns" WHERE (("information_schema"."columns"."table_name" = 'users') AND ("information_schema"."columns"."table_schema" = 'public')) ORDER BY "information_schema"."columns"."ordinal_position"
Please provide the output of that query for further debugging, otherwise this issue will likely be closed as cannot reproduce.
Try deleting the schema.rs file. Then run that diesel command again and you'll see it get regenerated. It has Nullable
s; it shouldn't.
And to answer your question:
column_name | udt_name | udt_schema | is_nullable | character_maximum_length | col_description
---------------+-----------+------------+-------------+--------------------------+-----------------
username | varchar | pg_catalog | NO | 50 |
password_hash | varchar | pg_catalog | YES | 50 |
role | text | pg_catalog | YES | |
created_at | timestamp | pg_catalog | NO | |
(4 rows)
Thanks for providing the output of that query. This output clearly shows that the database allows nullable values for these columns. At this point it's likely that the provided SQL does not match that SQL what you actually used to create the table. The other possibility is a bug in the database system itself.
Both variants are not an issue in diesel, so I will close this issue now.
Setup
Versions
Feature Flags
Problem Description
What are you trying to accomplish?
What is the expected output?
schema.rs
ofWhat is the actual output?
schema.rs
ofAre you seeing any additional errors?
No
Steps to reproduce
https://github.com/offscale/rust-actix-diesel-auth-scaffold/tree/2f01d2b
Checklist