@@ -11,7 +11,7 @@ import (
1111
1212// Insert a row in the DB, it is assumed the table exists, you can do a
1313// check before with HasTable()
14- func (l * Loader ) Insert (tableName string , primaryKey map [string ]string , data map [string ]string , ordinal uint64 , reversibleBlockNum * uint64 ) error {
14+ func (l * Loader ) Insert (tableName string , primaryKey map [string ]string , data map [string ]string , reversibleBlockNum * uint64 ) error {
1515 uniqueID := createRowUniqueID (primaryKey )
1616
1717 if l .tracer .Enabled () {
@@ -59,7 +59,7 @@ func (l *Loader) Insert(tableName string, primaryKey map[string]string, data map
5959 }
6060 }
6161
62- entry .Set (uniqueID , l .newInsertOperation (table , primaryKey , data , ordinal , reversibleBlockNum ))
62+ entry .Set (uniqueID , l .newInsertOperation (table , primaryKey , data , l . NextBatchOrdinal () , reversibleBlockNum ))
6363 l .entriesCount ++
6464 return nil
6565}
@@ -101,7 +101,7 @@ func (l *Loader) GetPrimaryKey(tableName string, pk string) (map[string]string,
101101
102102// Upsert a row in the DB, it is assumed the table exists, you can do a
103103// check before with HasTable().
104- func (l * Loader ) Upsert (tableName string , primaryKey map [string ]string , data map [string ]string , ordinal uint64 , reversibleBlockNum * uint64 ) error {
104+ func (l * Loader ) Upsert (tableName string , primaryKey map [string ]string , data map [string ]string , reversibleBlockNum * uint64 ) error {
105105 if l .dialect .OnlyInserts () {
106106 return fmt .Errorf ("update operation is not supported by the current database" )
107107 }
@@ -147,7 +147,7 @@ func (l *Loader) Upsert(tableName string, primaryKey map[string]string, data map
147147 l .logger .Debug ("primary key entry already exist for table, merging columns together" , zap .String ("primary_key" , uniqueID ), zap .String ("table_name" , tableName ))
148148 }
149149
150- op .mergeOperation (ordinal , data )
150+ op .mergeOperation (data )
151151 entry .Set (uniqueID , op )
152152 return nil
153153 } else {
@@ -165,13 +165,13 @@ func (l *Loader) Upsert(tableName string, primaryKey map[string]string, data map
165165 }
166166 }
167167
168- entry .Set (uniqueID , l .newUpsertOperation (table , primaryKey , data , ordinal , reversibleBlockNum ))
168+ entry .Set (uniqueID , l .newUpsertOperation (table , primaryKey , data , l . NextBatchOrdinal () , reversibleBlockNum ))
169169 return nil
170170}
171171
172172// Update a row in the DB, it is assumed the table exists, you can do a
173173// check before with HasTable()
174- func (l * Loader ) Update (tableName string , primaryKey map [string ]string , data map [string ]string , ordinal uint64 , reversibleBlockNum * uint64 ) error {
174+ func (l * Loader ) Update (tableName string , primaryKey map [string ]string , data map [string ]string , reversibleBlockNum * uint64 ) error {
175175 if l .dialect .OnlyInserts () {
176176 return fmt .Errorf ("update operation is not supported by the current database" )
177177 }
@@ -216,7 +216,7 @@ func (l *Loader) Update(tableName string, primaryKey map[string]string, data map
216216 l .logger .Debug ("primary key entry already exist for table, merging fields together" , zap .String ("primary_key" , uniqueID ), zap .String ("table_name" , tableName ))
217217 }
218218
219- op .mergeOperation (ordinal , data )
219+ op .mergeOperation (data )
220220 entry .Set (uniqueID , op )
221221 return nil
222222 } else {
@@ -227,13 +227,13 @@ func (l *Loader) Update(tableName string, primaryKey map[string]string, data map
227227 l .logger .Debug ("primary key entry never existed for table, adding update operation" , zap .String ("primary_key" , uniqueID ), zap .String ("table_name" , tableName ))
228228 }
229229
230- entry .Set (uniqueID , l .newUpdateOperation (table , primaryKey , data , ordinal , reversibleBlockNum ))
230+ entry .Set (uniqueID , l .newUpdateOperation (table , primaryKey , data , l . NextBatchOrdinal () , reversibleBlockNum ))
231231 return nil
232232}
233233
234234// Delete a row in the DB, it is assumed the table exists, you can do a
235235// check before with HasTable()
236- func (l * Loader ) Delete (tableName string , primaryKey map [string ]string , ordinal uint64 , reversibleBlockNum * uint64 ) error {
236+ func (l * Loader ) Delete (tableName string , primaryKey map [string ]string , reversibleBlockNum * uint64 ) error {
237237 if l .dialect .OnlyInserts () {
238238 return fmt .Errorf ("delete operation is not supported by the current database" )
239239 }
@@ -274,6 +274,6 @@ func (l *Loader) Delete(tableName string, primaryKey map[string]string, ordinal
274274 l .logger .Debug ("adding deleting operation" , zap .String ("primary_key" , uniqueID ), zap .String ("table_name" , tableName ))
275275 }
276276
277- entry .Set (uniqueID , l .newDeleteOperation (table , primaryKey , ordinal , reversibleBlockNum ))
277+ entry .Set (uniqueID , l .newDeleteOperation (table , primaryKey , l . NextBatchOrdinal () , reversibleBlockNum ))
278278 return nil
279279}
0 commit comments