Announcement

Collapse
No announcement yet.

QueryBuilder and deleted

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • QueryBuilder and deleted

    I have noticed that if you build a query with the query builder deleted=0 gets automatically added to the initial select table, but all the other joins need to include 'x.deleted'=>0 in the ->where

    For a left join you have to add it into the join criteria like SQL

    ->leftJoin('MyTable','mt',['mt.id:'=>'ot.myTableId,'mt.deleted'=>false]

    just an FYI as I had some incorrect results until I spotted this.

  • #2
    I can see the base sql generated using the builder, but are the deleted=0 added to joins and leftJoins when linking to an RDPRepositiory? or do we have to explicitly add deleted=0 to the ->where and ->leftJoin phases when filtering against a RDPRepository?

    Comment


    • #3
      When joining not a relation but a table (the first letter is an upper case ), then 'deleted' is needed explicitly. I added an additional note to the docs.

      When using RDBRepository, deleted is applied implicitly. It's possible to bypass it with QueryBuilder withDeleted method.
      Last edited by yuri; 12-09-2022, 11:30 AM.

      Comment

      Working...
      X