Skip to content

Commit e6f224e

Browse files
Adding comment and removing unused function
1 parent 7c56711 commit e6f224e

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

oracle/create.go

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -814,19 +814,6 @@ func handleSingleRowReturning(db *gorm.DB) {
814814
}
815815
}
816816

817-
// Simplified RETURNING clause addition for single row operations
818-
func addReturningClause(db *gorm.DB, fields []*schema.Field) {
819-
if len(fields) == 0 {
820-
return
821-
}
822-
823-
columns := make([]clause.Column, len(fields))
824-
for idx, field := range fields {
825-
columns[idx] = clause.Column{Name: field.DBName}
826-
}
827-
db.Statement.AddClauseIfNotExists(clause.Returning{Columns: columns})
828-
}
829-
830817
// Handle bulk RETURNING results for PL/SQL operations
831818
func getBulkReturningValues(db *gorm.DB, rowCount int) {
832819
if db.Statement.Schema == nil {
@@ -946,6 +933,11 @@ func handleLastInsertId(db *gorm.DB, result sql.Result) {
946933
}
947934
}
948935
}
936+
937+
// This replaces expressions (clause.Expr) in bulk insert values
938+
// with appropriate NULL placeholders based on the column's data type. This ensures that
939+
// PL/SQL array binding remains consistent and avoids unsupported expressions during
940+
// FORALL bulk operations.
949941
func sanitizeCreateValuesForBulkArrays(stmt *gorm.Statement, cv *clause.Values) {
950942
for r := range cv.Values {
951943
for c, col := range cv.Columns {
@@ -955,7 +947,7 @@ func sanitizeCreateValuesForBulkArrays(stmt *gorm.Statement, cv *clause.Values)
955947
if f := findFieldByDBName(stmt.Schema, col.Name); f != nil {
956948
switch f.DataType {
957949
case schema.Int, schema.Uint:
958-
cv.Values[r][c] = sql.NullInt64{} // NULL
950+
cv.Values[r][c] = sql.NullInt64{}
959951
case schema.Float:
960952
cv.Values[r][c] = sql.NullFloat64{}
961953
case schema.String:

0 commit comments

Comments
 (0)