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

Add Rows and RowsContext methods to SelectStmt #145

Merged
merged 2 commits into from
Sep 11, 2018
Merged

Add Rows and RowsContext methods to SelectStmt #145

merged 2 commits into from
Sep 11, 2018

Conversation

mccolljr
Copy link
Contributor

@mccolljr mccolljr commented Sep 8, 2018

I'm adding dbr to some legacy code right now, and until I have time to refactor some of the code to handle things differently, I've found myself wanting to build the query with dbr but process the rows differently. These are entirely convenience methods that allow fetching rows from a SelectStmt. They do not change any of the internals of dbr.

@taylorchu
Copy link
Contributor

could you describe how you process the rows? Just curious.

@mccolljr
Copy link
Contributor Author

mccolljr commented Sep 9, 2018 via email

dbr.go Outdated

return rows, nil
}

func query(ctx context.Context, runner runner, log EventReceiver, builder Builder, d Dialect, dest interface{}) (int, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you use queryRows in query too?

select_test.go Outdated
count++
}

require.Equal(t, 3, len(want))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be require.Equal(t, len(want), count).

@mccolljr
Copy link
Contributor Author

mccolljr commented Sep 9, 2018 via email

@taylorchu
Copy link
Contributor

It will be fine to return the query in queryRows. It is common to see what query is interpolated eventually.

@mccolljr
Copy link
Contributor Author

I can't believe I missed that in the test - I was rushing before I left the house. I will get these changes made when I have a break today and push.

- queryRows returns interpolated query
- query calls queryRows
- fixed erroneous check in test
@mccolljr
Copy link
Contributor Author

Just got around to making the requested changes, sorry for the delay. Work stuff got in the way today.

@taylorchu taylorchu merged commit 2016a59 into gocraft:master Sep 11, 2018
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

Successfully merging this pull request may close these issues.

2 participants