[5.1.x] Query gets built with ambiguous columns

I have the following tables (one has LRA prefix, while the other one is LRD):

public class LRAContenitore
{
    [PrimaryKey]
    [AutoIncrement]
    [Alias("IDACONTENITORE")]                   
    public int Id { get; set; }

    // other fields..
    [Alias("DATAMODIFICA")]
    public DateTime DataModifica { get; set; }

    [Default(1)]
    [Alias("VERSIONERECORD")]
    public int VersioneRecord { get; set; }
}

public class LRDContenitore
{
    [PrimaryKey]
    [AutoIncrement]
    [Alias("IDDCONTENITORE")]                
    public int Id { get; set; }
    
    // other fields..
    [Alias("DATAMODIFICA")]
    public DateTime DataModifica { get; set; }
 
    [Default(1)]
    [Alias("VERSIONERECORD")]
    public int VersioneRecord { get; set; }
}

I write the following query:

var q = _db.From<LRAContenitore>()
           .Join<LRAContenitore, LRDContenitore>((contenitori, contenitore) => contenitori.ContenitoreId == contenitore.Id)
           .Where<LRAContenitore>(x => x.RichiestaId == AIdRichiesta)
           .OrderBy<LRDContenitore>(x => x.Ordine);

int count = await _db.RowCountAsync(q);
var result = await _db.SelectAsync(q); // the query crashes here, because RowCountAsync altered the SqlExpression.

The generated query is the following:

SELECT "IDACONTENITORE"
     , "BARCODE"
     , "ARICHIESTAID"
     , "DCONTENITOREID"
     , "DPRIORITAID"
     , "DATAORAPRELIEVO"
     , "DATAORAPRIMOCHECKIN"
     , "DDEVICEIDPRIMOCHECKIN"
     , "DATAORACREATOUNMATCHED"
     , "UNMATCHED"
     , "DATAORARICONCILIATOUNMATCHED"
     , "STATO"
     , "DTIPOCONVALIDAID"
     , "DATAORAVALIDAZIONE"
     , "DATAORAESECUZIONE"
     , "DATAORAULTIMARIPETIZIONE"
     , "RIPETIZIONECITRATO"
     , "DATAORARICHIESTAVETRINOAUTO"
     , "DATAORARICHIESTAVETRINOMAN"
     , "COMMENTO"
     , "COMMENTOINTERNO"
     , "COMMENTOREFERTO"
     , "VALIDAZIONEAUTOMATICA"
     , "DATAMODIFICA" -- Ambiguous
     , "VERSIONERECORD" -- Ambiguous
  FROM "LRACONTENITORI"
       INNER JOIN "LRDCONTENITORI" ON("LRACONTENITORI"."DCONTENITOREID" = "LRDCONTENITORI"."IDDCONTENITORE")
  WHERE("LRACONTENITORI"."ARICHIESTAID" = 1)
ORDER BY "LRDCONTENITORI"."ORDINE";

The columns DATAMODIFICA and VERSIONERECORD are present on both tables so that generate and “ambiuous column error”.

I expect those 2 columns (or every column) to be prefixed by LRACONTENITORI, that is the type of the query in this case.

Verified on both 5.1.0 and 5.1.1 MyGet release (as of 25/07 13:17 UTC).

If i call RowCountAsync after the query, everything works right. This means that RowCountAsync modifies my SqlExpression as a side-effect.

Some queries do mutate the SqlExpression, if you want to share the same expression use q.Clone() to create a different copy.