Repository navigation
Async Schema APIs - #3017
Async Schema APIs#3017
Conversation
|
@manandre thanks for doing this! I'm going to delay reviewing this for a bit - dotnet/runtime#38028 should get reviewed relatively soon. In any case it should have little effect on the work you've already done here. |
|
@roji API has been approved with some slight adjustments. I have updated this PR accordingly. |
|
@roji I have prepared the implementation to be ready for new async Schema API in public Task<ReadOnlyCollection<NpgsqlDbColumn>> GetColumnSchemaAsync(CancellationToken cancellationToken = default)and the new API introduces public Task<ReadOnlyCollection<DbColumn>> GetColumnSchemaAsync(CancellationToken cancellationToken = default)Should we rename the existing one?!? which would be a breaking change then... 😞 |
|
No worries, the change will be for v5 in our driver. Therefore, it's absolutely fine to invest a breaking change (: Just replace existing one by the new. |
|
Ok then for a breaking change. But we should also keep alignment with the sync variant: public ReadOnlyCollection<NpgsqlDbColumn> GetColumnSchema()Should we replace it also? |
|
Wouldn't the common ADO.NET way be to hide the method with |
|
The default implementation of |
|
There is a explicitly implemented interface member to obtain schema information. We can make it visible and return a collection of |
roji
left a comment
There was a problem hiding this comment.
See below for some comments. More generally,
The default implementation of DbDataReader.GetColumnSchemaAsync() simply invokes the synchronous version and returns a completed task.
This is true, but I still don't see why we can't have hiding methods (with new) returning NpgsqlDbColumn, and corresponding overriding methods which simply call these methods... As @Brar said, this is the general ADO.NET practice, and it allows those referencing NpgsqlConnection directly to get the Npgsql-specific NpgsqlDbColumn instead of DbColumn. Am I missing something?
But I suggest we generally hold off on this until we get an SDK with the proper support...
|
@roji Good news! I will take care of that during the week-end. |
016e9a4 to
4755f42
Compare
|
@roji Rebased! |
|
For FillAsync, there's dotnet/runtime#22109 for discussing at the System.Data level... I don't think we should do anything here until that's decided. |
ae49742 to
3fb6414
Compare
|
@manandre let me know when this is ready for reviewing. |
|
Ready for reviewing! |
70ad037 to
0782664
Compare
0782664 to
c51f6f1
Compare
Add GetSchemaTableAsync Add FillAsync Remove await using as not supported in dotnet 5.0 preview 2 Align on new API proposal Merge sync and async SchemaTests Align on new API proposal (bis) Add async ReaderSchemaTests Avoid business logic duplication between sync and async Align new test after rebase Align on approved API Align API on nullability annotations of the sync equivalents
72b3e76 to
45f0f96
Compare
|
|
||
| var values = new object[count]; | ||
|
|
||
| while (async ? await dataReader.ReadAsync(cancellationToken) : dataReader.Read()) |
There was a problem hiding this comment.
Can directly call the Read overload which accepts an async flag (like you did with NpgslqCommand.ExecuteReader above)
There was a problem hiding this comment.
We can do that, but we would lose the TryFastRead optimization path... Should we create a new Read method which accepts an async flag and supports this optimization path ?
There was a problem hiding this comment.
That's a good point, thanks. This code is used only in completely low-perf scenarios - reading back the database schema - so I don't think we should care about the fast path. Refactoring to a new Read method with an async flag and the fast path could be a bit tricky, since we want to avoid applying the NoSynchronizationContextScope if the fast path is successful...
To summarize, I would spend any time on this. I'm OK both with keeping your code as is (with the conditional operator), or with giving up on the fast path and calling the existing Read with the async flag - up to you.
There was a problem hiding this comment.
OK, as everything else looks great I'll just go ahead and merge as-is.
7f69170 to
acd274d
Compare
Closes #2976