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

Handle bulk inserts #4

Open
michaelgmiller opened this issue Aug 11, 2017 · 8 comments
Open

Handle bulk inserts #4

michaelgmiller opened this issue Aug 11, 2017 · 8 comments

Comments

@michaelgmiller
Copy link

Is it possible to setup a DAO to do bulk insert queries a la COPY FROM ?

@jonbodner
Copy link
Owner

Hrm, I'm assuming that you want to pass in a slice of slices or a slice of structs with the data. No, you can't walk a slice of slices or structs right now, but I have some thoughts on how to approach this issue. And I'm always happy to take submissions :-)

Let me think about this some more and see about adding in support for this functionality.

@michaelgmiller
Copy link
Author

Yup, exactly, I'd like to be able to pass in a slice of structs! If it were Uber performing using binary COPY FROM, that'd be even better :). Don't have a ton of time, but if you have a clear idea about how to implement this, I can try to help.

@jonbodner
Copy link
Owner

Sorry for the delay in responding. My thought is to introduce the ability to specify a function that can transform the value of a placeholder. These could process the value either before it is converted to a prepared statement (which would allow dynamic SQL to be injected), or after it is converted (which would allow a value to be changed just before it is inserted).

My concern is that the pre-processing function is a bit of a footgun; if you inject the wrong SQL, you can set yourself up for injection, which Proteus is designed to avoid. I'm trying to figure out if there is a way to make it safe. If there isn't, I would fall back to supporting some built-in functions for building things like lists of structs properly, but they would be added on an as-requested basis.

@katherinewallace
Copy link

+1 this would be very useful

@jonbodner
Copy link
Owner

I will have some time to work on this in a couple of weeks. Is that ok? I’ll see what I can do then.

@katherinewallace
Copy link

I see this issue is still open. Is there any update on this?

@jonbodner
Copy link
Owner

Sorry, no change in status right now. I don't have time to make Proteus updates right now, but I'm hoping to get back to it in the near future. Do you have any thoughts on how you would like the feature to work? I'm still thinking of what a good implementation would be, especially given Go's lack of batch updates in the standard sql support.

@katherinewallace
Copy link

Let me take a look, and I'll let you know if I have ideas. I've been using Proteus a good amount, and would definitely find this very valuable.

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

3 participants