Search code examples
postgresqlgogo-gormcve

GORM Help w/ Postgres: unsupported data type


I'm trying to read through the CVE List to put all the entries into a central database. When I try to create an entry to this databse, I get an error: 2024/07/02 14:03:13 /x/db.go:68 unsupported data

The required code is here. Replace # in db.go with the correct information for a Postgres server to replicate.

I've double-checked the struct definitions and have used the GORM documentation for many to many and has-many type relationships. The create(object any) method should successfully insert an instance of the struct passed on the Postgres server provided through the other functions.


Solution

  • func create(object any) {
        db.Create(&object)
    }
    

    This function is causing an error as the GORM record insertion logic can't tell what data type is being created. Directly calling db.Create(&vuln) prevents this and appropriately uses GORM functionality