Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

No documentation of failure states (or it is hard to find if it exists?)

Đang mở
#161 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
25/100
Loại issue
Tài liệu
Độ rõ ràng
Cần làm rõ
Mức độ hoạt động
Đình trệ
Công nghệ
csharp
Lĩnh vực
documentation

Hướng nghiên cứu

Bắt đầu với docs/index.md và Readme.md, sau đó kiểm tra các chú thích và phần triển khai của InsertAsync trong src/Dapper.Contrib/SqlMapperExtensions.Async.cs. Xác minh các trường hợp biên được liệt kê của InsertAsync và UpdateAsync, bao gồm hành vi phụ thuộc vào cơ sở dữ liệu và các giá trị trả về, đồng thời ghi lại các kết quả và ngoại lệ đã được xác nhận.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

It is not clear from the documentation, nor from the code comments, nor from the actual code, what happens in several cases.

The comment from InsertAsync, as seen in SqlMapperExentsions.Async.cs

    /// <summary>
    /// Inserts an entity into table "Ts" asynchronously using Task and returns identity id.
    /// </summary>
    /// <typeparam name="T">The type being inserted.</typeparam>
    /// <param name="connection">Open SqlConnection</param>
    /// <param name="entityToInsert">Entity to insert</param>
    /// <param name="transaction">The transaction to run under, null (the default) if none</param>
    /// <param name="commandTimeout">Number of seconds before command execution timeout</param>
    /// <param name="sqlAdapter">The specific ISqlAdapter to use, auto-detected based on connection if null</param>
    /// <returns>Identity of inserted entity</returns>

Steps to reproduce:

Expected outcome:

Learn how to handle edge cases that might be encountered when using Dapper.Contrib

Actual outcome:

I currently lack clarity on the following:

  1. InsertAsync, return value when Task<int> cannot represent key in database

    • What is the "Identity" returned when the table uses long and has more than INTMAX entities? [1]
    • What is the "Identity" returned when the key is a GUID or hashed string?
    • What is the "Identity" returned after inserting an IEnumerable<Entity>?
  2. InsertAsync, single entity, non-zero key in key-incrementing table

    • Insert nothing and return zero?
    • Insert nothing and throw?
      • If so, what?
    • Insert entity as if the key was zero, return the key of the new row?
    • Behavior depends on underlying database?
  3. InsertAsync, single entity, non-zero key already in table

    • Retain existing entity and return zero?
    • Retain existing entity and throw exception?
      • If so, which one?
    • Insert entity as if the key was zero, return the key of the new row?
    • Retain existing entity, returning its key?
      • If so, any way to learn you didn't insert?
    • Overwrite existing entity, returning the key?
    • Behavior depends on underlying database?
  4. InsertAsync, multiple entities, some keys already in table

    • Insert none and return zero?
    • Insert none and throw exception?
      • If so, which one?
    • Insert new entities only and retain existing entities, returning count of delta?
      • if so - any way to learn which ones were not inserted?
    • Insert all, overwriting existing entities, returning count of all entities in original list?
    • Behavior depends on underlying database?
  5. InsertAsync, single or multiple insert, table not found

    (The entity class name does not correspond to any table names, the [Table("name")] attribute is not present)

    • Return zero?
    • Throw exception?
      • If so, which exception?
    • Wildcard option: Create that table and populate it?
    • Behavior depends on underlying database?
  6. InsertAsync, single or multiple insert, column not found

    (Entity has field that is not marked [Write(false)], column does not exist in database)

    • Write correct fields, return as normal?
    • Write nothing and return zero?
    • Write nothing and throw?
      • If so, which exception?
    • Wildcard option: Create that column?
    • Behavior depends on underlying database?
  7. InsertAsync, single or multiple insert, field not found

    (Entity is missing a field representing a column that exists in the table)

    • Write other fields, leaving empty field as null/zero/empty string, return as normal?
    • Write nothing and return zero?
    • Write nothing and throw?
      • If so, which exception?
    • Behavior depends on underlying database?
  8. UpdateAsync

    (Just about all the same questions except reverse the "entity alread exists" logic)

    • No such ID in table
    • Missing fields
    • Extra fields
    • No such table
  9. other problems

    (connection bad, connection loss or timeout, transaction in bad state)

    • Surely that's a throw, right?
    • I mean, it has to be?
    • But which exception?

[1] My company works with physical goods rather than at internet scale so we aren't reaching there any time soon (I believe our deepest table only has 3'000'000 entities) but somebody is going to run into that limit, especially if they run at internet-scale and e.g. store log messages in their database.

Ngôn ngữ chính
C#
Star
293
Fork
108
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của DapperLib/Dapper.Contrib

Tất cả issue của DapperLib/Dapper.Contrib

Issue tương tự

Thêm issue về C#

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.