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

Can't use nextval('my_sequence') in insert statement #46

Open
gdulus opened this issue Sep 22, 2014 · 4 comments
Open

Can't use nextval('my_sequence') in insert statement #46

gdulus opened this issue Sep 22, 2014 · 4 comments

Comments

@gdulus
Copy link

gdulus commented Sep 22, 2014

When use "action" : "insert" nextval cant be used (wrong type exception)

@Zwergal
Copy link
Contributor

Zwergal commented Sep 23, 2014

I'll have a look at this and try to reproduce the issue.

@Zwergal
Copy link
Contributor

Zwergal commented Sep 27, 2014

Ok, the issue here is, that this module can only handle JSON Datatypes with the insert command. So you can only send the nextval command as a string which results in a query like INSERT INTO test (id, name) VALUES ('nextval('my_sequence')', 'foo');. A workaround would be to use the raw command for this insert like:

{
  "action" : "raw",
  "command" : "INSERT INTO test (id, name) VALUES (nextval('test_seq'), 'bla')"
};

We need to think about a solution how one can use this special commands within the INSERT command. Any ideas?

@gdulus
Copy link
Author

gdulus commented Sep 28, 2014

I am using you library from clojure and for me something like list
'(nextval "my_sequence") would be natural. You can detect type, then
evaluate first element if thats known function and use rest as a
parameters. But thats clojure kimd of approach i would use.
On Sep 27, 2014 7:00 PM, "Zwergal" [email protected] wrote:

Ok, the issue here is, that this module can only handle JSON Datatypes
with the insert command. So you can only send the nextval command as a
string which results in a query like INSERT INTO test (id, name) VALUES
('nextval('my_sequence')', 'foo');. A workaround would be to use the raw
command for this insert like:

{
"action" : "raw",
"command" : "INSERT INTO test (id, name) VALUES (nextval('test_seq'), 'bla')"
};

We need to think about a solution how one can use this special commands
within the INSERT command. Any ideas?


Reply to this email directly or view it on GitHub
#46 (comment)
.

@Narigo
Copy link
Member

Narigo commented Oct 23, 2014

I don't think it's possible to get this into the "action" : "insert" command as it would definitely make a string out of that. We would need / use something like $nextVal like MongoDB does for passing these special functions. So I'll tag this as feature request, but not sure whether we'll do that soon. Please use the raw format as a workaround until then... :)

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

No branches or pull requests

3 participants