Fix the typo in the SQL (#26)

* - Ensure the correct ID is returned from the Max statements as the NullInt64 was not working as expected
- Check before creating the nextAccountDataID

* - Set the pos output var correctly and fix typo in the SQL

Co-authored-by: alexf@example.com <alexf@example.com>
This commit is contained in:
alexfca 2021-11-08 11:24:02 +11:00 committed by GitHub
parent 6d27770a69
commit 66cfcca1cb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -67,7 +67,7 @@ const selectAccountDataInRangeSQL = "" +
"select * from c where c._cn = @x1 " + "select * from c where c._cn = @x1 " +
"and c.mx_syncapi_account_data_type.user_id = @x2 " + "and c.mx_syncapi_account_data_type.user_id = @x2 " +
"and c.mx_syncapi_account_data_type.id > @x3 " + "and c.mx_syncapi_account_data_type.id > @x3 " +
"and c.mx_syncapi_account_data_type.id < @x4 " + "and c.mx_syncapi_account_data_type.id <= @x4 " +
"order by c.mx_syncapi_account_data_type.id " "order by c.mx_syncapi_account_data_type.id "
// "SELECT MAX(id) FROM syncapi_account_data_type" // "SELECT MAX(id) FROM syncapi_account_data_type"
@ -137,6 +137,7 @@ func (s *accountDataStatements) InsertAccountData(
dbData, _ := getAccountDataType(s, ctx, s.getPartitionKey(), cosmosDocId) dbData, _ := getAccountDataType(s, ctx, s.getPartitionKey(), cosmosDocId)
if dbData != nil { if dbData != nil {
pos = types.StreamPosition(dbData.AccountDataType.ID)
dbData.SetUpdateTime() dbData.SetUpdateTime()
} else { } else {
pos, err = s.streamIDStatements.nextAccountDataID(ctx, txn) pos, err = s.streamIDStatements.nextAccountDataID(ctx, txn)