Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty structs #5

Open
stbenjam opened this issue Feb 14, 2022 · 5 comments
Open

Empty structs #5

stbenjam opened this issue Feb 14, 2022 · 5 comments
Assignees

Comments

@stbenjam
Copy link

Your Question

I'm having an odd issue using GORM with BigQuery. I've pared things down to a very, very simple .Find, and unmarshalling into a struct:

    q.Table("Tags").
        Select("ROW_NUMBER() OVER() id, *").
        Find(&tags)

My Tags struct looks like:

type Tag struct {
    ID int `json:"id" gorm:"column:id"`

    Phase string `json:"phase" gorm:"column:phase"`
}

Logs show it got results from the DB:

[4734.504ms] [rows:10] SELECT ROW_NUMBER() OVER() id, * FROM `Tags` LIMIT 10

And my tags array has 10 entries, but all fields in the structs have zero values. I have no problem using the native BigQuery client, but I need to use GORM on this project since we have some filtering layer for an API built on top of it.

Any idea what's wrong?

The document you expected this should be explained

gorm bigquery driver docs

Expected answer

What I'm doing wrong

@stbenjam
Copy link
Author

Some additional info: if I use .Rows() instead of .Find(), and look at rows.Columns(), it's empty - [].

@freehere107
Copy link

freehere107 commented Feb 16, 2022

@stbenjam Is the current library available? Currently, I execute the create statement without any return, not even a log

@plindbe2
Copy link

I second this issue. I will stay on older versions for now. I've traced it down to when the go sql module is calling bigQueryRows.Columns() it is returning an empty list. Looking at the google code, the RowIterator.Schema has a comment saying "The schema of the table. Available after the first call to Next." which is getting used but the Next hasn't been called yet so it's empty. I believe that previously somehow the query was happening before it gets to this point when it calls Columns. I may try to debug further if I can find the time.

@plindbe2
Copy link

Hello Again. I've submitted a pull request here to fix this issue. Please take a look and let me know if there are any issues:

#8

@MAJA-Lin
Copy link

MAJA-Lin commented May 24, 2023

Hi, I saw the pull request #8 had been merged for a long time.
Does the PR fix this issue / can this issue be closed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants