sijms / go-ora

Pure go oracle client
MIT License
767 stars 168 forks source link

Trigger panic when the number of rows in the table is >= 3 #525

Closed CoiaPrant233 closed 3 months ago

CoiaPrant233 commented 4 months ago

See https://github.com/sijms/go-ora/issues/493

sijms commented 3 months ago

this is the code I test. I successfully insert 10 rows in the table

package main

import (
    "database/sql"
    "fmt"
    _ "github.com/sijms/go-ora/v2"
    go_ora "github.com/sijms/go-ora/v2"
    oracle "gitlab.com/CoiaPrant/gorm-oracle"
    "gorm.io/gorm"
    "os"
    "strconv"
)

type Keywords struct {
    Id int64 `gorm:"column:id; primaryKey"`

    Key     string `gorm:"column:key; not null; unique"`
    Value   string `gorm:"column:value; not null"`
    Ignored bool   `gorm:"column:ignored; not null; default:false"`
}

func main() {
    var err error
    db, err := gorm.Open(oracle.Open(os.Getenv("DSN_CLOUD")), &gorm.Config{})
    if err != nil {
        fmt.Println("can't connect: ", err)
        return
    }
    err = db.AutoMigrate(&Keywords{})
    if err != nil {
        fmt.Println("can't migrate: ", err)
        return
    }
    for x := 0; x < 10; x++ {
        model := &Keywords{
            Key:     strconv.Itoa(x + 1),
            Value:   "demo_" + strconv.Itoa(x+1),
            Ignored: false,
        }
        tx := db.Create(model)
        tx.Commit()
        fmt.Println("ID: ", model.Id)
    }
}

it print ID: 0 for all. I think issue in the gitlab.com/CoiaPrant/gorm-oracle

sijms commented 3 months ago

also another issue after dropping the table identity sequence is remain

sijms commented 3 months ago

also fix regression with issue #307

sijms commented 3 months ago

I think the issue is SELECT FOR UPDATE I am fixing it

sijms commented 3 months ago

fixed in v2.8.10