-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ppx_pgsql's nullability heuristic has failed for outer joins #4
Comments
Thank you @NightBlues. This is a bit complicated, and I don't have a good solution right now, will have to check during the weekend to see if I can figure it out. Meanwhile, something that you can do is to create views for such joins, and manually set the nullable property in postgres for each column (or just use the view as is, by default everything is nullable). Here is the query that I use to make every column on a view non-nullable: UPDATE pg_attribute SET attnotnull = 't'
WHERE attrelid IN (
SELECT oid FROM pg_class
WHERE relname = 'name_of_view'); You can find documentation on the |
To add a bit more of information. The reason modifying the contents of that table works is that it is from where ppx_pgsql gets the column type information. When you create a view, it gets a new ID, and all it's columns get new entries in that table. By modifying those entries you control what ppx_pgsql sees when fetching information for the columns on that view. |
Thank you for workaround:) |
There is more simple solution:
coalesce returns first non null value or null if all values are null, so we just confuse postgres with this function call:) |
Very interesting find! It didn't occur to me to use |
As I understand - the reason is that it becomes a calculated value instead of field of table, so describe returns None here https://github.com/darioteixeira/pgocaml/blob/master/src/PGOCaml_generic.ml#L1504 |
"ppx_pgsql's nullability heuristic has failed" for outer joins
For example if we have 2 tables:
Following query will have type
string * string
instead ofstring * (string option)
:Because books.title is
NOT NULL
, but author without any book will causenullability heuristic has failed
May be there is a way to advice nullability for ppx_pgsql?
The text was updated successfully, but these errors were encountered: