1

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.

New contributor
Aidan Gatenbee is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
7
  • There is only 5 lines of Code or so in the link, post code here with a minimal reproducable example ;)
    – Christoph
    Commented Jul 2 at 18:47
  • @Christoph there should be multiple files in the Repl that work together. Let me know if you can't see them. Commented Jul 2 at 18:55
  • Where does wojtek.Create come from?
    – Christoph
    Commented Jul 2 at 19:07
  • @Christoph I'll try making the create case-specifc, but I was trying to make it so I could pass in any struct and have GORM create it regardless of type. Thanks for the insight Commented Jul 2 at 19:08
  • On which create does excalty it happens on the last one ?
    – Christoph
    Commented Jul 2 at 19:09

1 Answer 1

0
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

New contributor
Aidan Gatenbee is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.