Conversation
de24f93 to
0a7e7f1
Compare
|
Unfortunately this change would mean we can hit the following line when trying decode an anonymous record: postgrex/lib/postgrex/type_module.ex Line 448 in 07c8380 Technically we can handle this situation because we decode inside a connection now - we did not use to. It would be possible (but I imagine complex) to lookup the missing oids after a results set, then decode the rows from that result. Is this something we would want to do? |
|
@tlvenn could you try this branch with your cockroachdb ecto adapter? @michalmuskala do you have thoughts on #352 (comment) |
Carry out full bootstrap on first connect and then fetch new types when trying to describe a query. This means reconnects don't run a bootstrap query and describe runs minimal query.
0a7e7f1 to
53585e7
Compare
|
Ebert has finished reviewing this Pull Request and has found:
But beware that this branch is 1 commit behind the You can see more details about this review at https://ebertapp.io/github/elixir-ecto/postgrex/pulls/352. |
|
Unfortunately this PR has the issue that we may not discover sub-types. For example if a new type is added and the super type (such as a composite or array) uses the new type we may not be able to resolve the new super type because we don't know about the sub type. |
|
@fishcakez regarding your comment. What if we went the @josevalim way? Do the least we can get away with and wait until somebody comes with a use case. If it's broken right now anyway and adds a lot of complexity, maybe we should hold off on this. I also understand that this is "fixable" by adding some explicit type casts to the query, is that right? |
When bootstrapping unknown oids also check for their subtypes.
|
@michalmuskala what is Jose's way? Please see #353 as it goes into more detail. One could cast to a named composite yes but the trouble is that its possible to discover the issue in production and not tests. We could also have the wrong types for the named composite. I have fixed this PR to recursively fetch the types. |
|
@ericmj could you take a look at this as I believe you are best placed to understand the consequences? |
|
@fishcakez As discussed in Slack, I tested the branch with CDB and the bootstrap query still does not work outside of the box unfortunately for just a single remaining reason: ARRAY (
SELECT a.atttypid
FROM pg_attribute AS a
WHERE a.attrelid = t.typrelid AND a.attnum > 0 AND NOT a.attisdropped
ORDER BY a.attnum
)Which is a correlated subquery which CDB does not support at the moment |
|
ping @elixir-ecto/ecto |
|
@fishcakez I don't understand this comment:
It is my understand that, right now, when decoding composites we should always know the subtypes. This would be a new limitation? |
| assert :ok = query("CREATE TYPE missing_comp AS (a int, b missing_enum)", []) | ||
| assert :ok = query("CREATE TABLE missing_comp_table (a missing_comp)", []) | ||
|
|
||
| assert :ok = query("INSERT INTO missing_comp_table VALUES ($1)", [{1, "missing"}]) |
There was a problem hiding this comment.
Is this supposed to test for named or anonymous composites? I believe this will be inferred as named since it's inserting directly into a table.
|
🎉 thank you, folks! |
Closes #310.
Closes #320.