mirror of
https://github.com/aclindsa/moneygo.git
synced 2024-12-26 15:42:27 -05:00
Ensure transactions returned are distinct
This commit is contained in:
parent
6f73c51b12
commit
b670e67ebb
@ -558,7 +558,7 @@ func GetAccountTransactions(user *User, accountid int64, sort string, page uint6
|
|||||||
}
|
}
|
||||||
atl.Account = account
|
atl.Account = account
|
||||||
|
|
||||||
sql := "SELECT transactions.* from transactions INNER JOIN splits ON transactions.TransactionId = splits.TransactionId WHERE transactions.UserId=? AND splits.AccountId=?" + sqlsort + " LIMIT ?" + sqloffset
|
sql := "SELECT DISTINCT transactions.* FROM transactions INNER JOIN splits ON transactions.TransactionId = splits.TransactionId WHERE transactions.UserId=? AND splits.AccountId=?" + sqlsort + " LIMIT ?" + sqloffset
|
||||||
_, err = transaction.Select(&transactions, sql, user.UserId, accountid, limit)
|
_, err = transaction.Select(&transactions, sql, user.UserId, accountid, limit)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
transaction.Rollback()
|
transaction.Rollback()
|
||||||
@ -567,7 +567,7 @@ func GetAccountTransactions(user *User, accountid int64, sort string, page uint6
|
|||||||
atl.Transactions = &transactions
|
atl.Transactions = &transactions
|
||||||
|
|
||||||
for i := range transactions {
|
for i := range transactions {
|
||||||
_, err = transaction.Select(&transactions[i].Splits, "SELECT * from splits where TransactionId=?", transactions[i].TransactionId)
|
_, err = transaction.Select(&transactions[i].Splits, "SELECT * FROM splits where TransactionId=?", transactions[i].TransactionId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
transaction.Rollback()
|
transaction.Rollback()
|
||||||
return nil, err
|
return nil, err
|
||||||
|
Loading…
Reference in New Issue
Block a user