Skip to content

Update操作的时候CanUpdate=false 未生效 #803

Closed

Description

@aprilyush

问题描述及重现步骤:

Update的时候IgnoreColumns和字段上属性 CanUpdate = false没有同时生效,只有IgnoreColumns生效了
实体

    [JsonProperty, Column(DbType = "varchar(30)", CanUpdate = false)]
    public string create_by { get; set; } = string.Empty;

    [JsonProperty, Column(DbType = "datetime", CanUpdate = false)]
    public DateTime create_time { get; set; }

Sqldb.Update<crm_sale_order>().SetSource(dto).IgnoreColumns(s=>new {s.tag_count,s.gateway_count}).ExecuteAffrows();
更新操作执行后create_by 和create_time 的值被更新了 CanUpdate 没有生效

数据库的具体版本

mysql5.7

安装的包

freesql2.5.2

.net framework/. net core? 及具体版本

.net 5

Activity

  1. added
    bug
    on Jun 18, 2021
  2. added a commit that references this issue on Jun 19, 2021
  3. 2881099 commented on Jun 27, 2021

    @2881099
    Collaborator

    CanUpdate = false 目前确实是在不使用 UpdateColumns/IgnoreColumns 时才有效,这个问题在初期就知道,找不到好的解决办法。因为有使用者需要单独用 UpdateColumns/IgnoreColumns 控制 CanUpdate = false 的属性,目前这样等于开放了一个入口操作。反之就不可操作了。

  4. aprilyush commented on Jun 29, 2021

    @aprilyush
    Author

    CanUpdate = false 目前确实是在不使用 UpdateColumns/IgnoreColumns 时才有效,这个问题在初期就知道,找不到好的解决办法。因为有使用者需要单独用 UpdateColumns/IgnoreColumns 控制 CanUpdate = false 的属性,目前这样等于开放了一个入口操作。反之就不可操作了。

    好的 谢谢,麻烦叶大文档标注一下不能同时生效,谢谢啦

  5. added a commit that references this issue on Aug 31, 2021
  6. worldofchu commented on Nov 4, 2021

    @worldofchu

    postgresql 12+
    _tbrepo.Orm.Update().SetSource(tb111).ExecuteAffrows(); 对于 已经设置canupdate false的字段的 也是无效!!!!注意该字段同时设置了 canupdate和caninsert 都为false ,但是查询时候又需要所以 没设置ingore!
    我看到2.6.1 版本说已经修正了此错误!验证了下 还是有这个问题啊 !!!-------ps 当然 我同时设置了 .IsVersion(true)

  7. luoyunchong commented on Nov 7, 2021

    @luoyunchong
    Collaborator

    postgresql 12+ _tbrepo.Orm.Update().SetSource(tb111).ExecuteAffrows(); 对于 已经设置canupdate false的字段的 也是无效!!!!注意该字段同时设置了 canupdate和caninsert 都为false ,但是查询时候又需要所以 没设置ingore! 我看到2.6.1 版本说已经修正了此错误!验证了下 还是有这个问题啊 !!!-------ps 当然 我同时设置了 .IsVersion(true)

    如何重现你的问题。

  8. worldofchu commented on Nov 8, 2021

    @worldofchu

    参见#825 我同时设置了 .IsVersion(true)

  9. worldofchu commented on Nov 8, 2021

    @worldofchu

    postgresql 12+ _tbrepo.Orm.Update().SetSource(tb111).ExecuteAffrows(); 对于 已经设置canupdate false的字段的 也是无效!!!!注意该字段同时设置了 canupdate和caninsert 都为false ,但是查询时候又需要所以 没设置ingore! 我看到2.6.1 版本说已经修正了此错误!验证了下 还是有这个问题啊 !!!-------ps 当然 我同时设置了 .IsVersion(true)

    如何重现你的问题。

    参见#825 我同时设置了 .IsVersion(true)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions