-
Notifications
You must be signed in to change notification settings - Fork 156
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
Fixes insert command #72
Conversation
I think the argument is probably an int like the others, reporting the number of modified rows. But I don't know, this part is undocumented. |
No, it's not 😄 ! The arguments indicate the number of arguments we pass to values. What we get is |
This is strange, tests are passing for me locally. Maybe restart? |
Okay, I'm back. I forgot to mention that I also thought that was the case and this was the first thing I tried: val Insert: Regex = """INSERT (\d+)""".r Then I discovered that it was failing when I was inserting two values: val insertCmd: Command[String ~ String] =
sql"""
INSERT INTO brands
VALUES ($varchar, $varchar)
""".command This was the error I was getting:
Then I realized that it returns the number of arguments in the same way so I added other patterns: val Insert1: Regex = """INSERT (\d+)""".r
val Insert2: Regex = """INSERT (\d+ \d+)""".r
val Insert2: Regex = """INSERT (\d+ \d+ \d+)""".r This does work but as you can see it gets ugly quickly, and I don't know how to write such a regex for an arbitrary number of arguments. After some Googleing I couldn't figure it out so I wrote a match-all after the INSERT clause since the result doesn't seem relevant anyway. Hope that clarifies things a bit! :) |
Hey @tpolecat , It turns out I was wrong. The pattern is always something like https://www.postgresql.org/message-id/4AD5F063.8050708@iol.ie I fixed the pattern now and can confirm it works well. |
This isn't going to work if oids are turned on but I'll open an issue and we can follow up. Thanks! |
Insertions like the one below are now working:
I decided to ignore the parameters in the
Completion
pattern match but I'm not sure if that's correct, I'm not very familiar with the protocol.