volatiletech / sqlboiler

Generate a Go ORM tailored to your database schema.
BSD 3-Clause "New" or "Revised" License
6.73k stars 544 forks source link

runtime error: invalid memory address or nil pointer dereference #369

Closed alishaagupta closed 6 years ago

alishaagupta commented 6 years ago

If you're having a generation problem please answer these questions before submitting your issue. Thanks!

What version of SQLBoiler are you using (sqlboiler --version)?

SQLBoiler v2.5.0

If this happened at generation time what was the full SQLBoiler command you used to generate your models? (if not applicable leave blank)

If this happened at runtime what code produced the issue? (if not applicable leave blank)

Data insertion query produced the error .

for i := 0; i <= 99; i++ {

    var p models.HistoricDatum

    // p1.ExchangeName =
    p.Globaltradeid = data.Result[i].ID
    p.Quantity = data.Result[i].Quantity
    p.Price = data.Result[i].Price
    p.Total = data.Result[i].Total
    p.FillType = data.Result[i].Filltype
    p.OrderType = data.Result[i].Ordertype
    p.CreatedOn = data.Result[i].Timestamp

    err := p.Insert(db)

    panic(err.Error())
}

HistoricDatum is the table data has to be inserted in. Only first row is inserted by this query.

What is the output of the command above with the -d flag added to it? (Provided you are comfortable sharing this, it contains a blueprint of your schema)

Please provide a relevant database schema so we can replicate your issue (Provided you are comfortable sharing this)

create table historic_data ( id serial primary key not null , exchange_name varchar (50), globaltradeid numeric, tradeid numeric, created_on varchar (100), quantity NUMERIC, price numeric, total numeric, fill_type varchar (20), order_type varchar (20)

);

Further information. What did you do, what did you expect?

I am fetching json data from an api and storing it in a db . USing the insertion query on the db shows this error. Only frst row is being inserted . I am using a for loop for the whole data, but it shows the error.

aarondl commented 6 years ago

Hey @alishaagupta. This kind of a bug report is really unhelpful :(

I have no idea what could possibly be going on because there's no code to look at, there's no stack trace, there's no way with this little information I can know whether it's your code or something in sqlboiler causing the problem. It's simply insufficient for me to be able to do anything. You'll have to put in more effort into the bug report for me to be able to help.

See all the bold text from the bug report template? These are questions that help you provide relevant details. Leaving out the sqlboiler version for example is immediately detrimental. Try to fill in as many of these details as possible.

Also try to imagine that you are the maintainer of sqlboiler, then imagine what details you would need to fix the bug you've encountered and provide those in a new bug report. I'm closing this one as it's simply insufficient. Sorry!