-
Notifications
You must be signed in to change notification settings - Fork 52
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
Error when using RETURNING from PostgreSQL #15
Comments
I can confirm this bug. I noticed it yesterday. My exception was "Received result when none was expected" Using the latest version of hugsql, and funcool/clojure.jdbc adapter. |
This happens because statements executed with However, I'm going to keep this open. The HugSQL docs should indicate this, I should add a test to show this, and I'm thinking about adding a command type that would indicate this. Also, this is tangentially related to issue #8. |
@csummers great!. I can confirm that it solves the problem. All I had to do was change my query to something like this:
Thanks! |
As of the 0.4.0, there is a |
Excellent!... I will update my code and let you know if I something doesn't work!... Keep the good work!! |
Just came across this issue and wanted to suggest adding an example to the Insert examples of how to insert with dynamic columns (ie: the |
Thanks for the suggestion. I could add a couple of examples to this effect. I think a likely scenario instead of the separate fields and values vectors would use a hashmap of |
That would be really nice. The |
Hi @sthomp, I use that pattern
|
Thanks @rcanepa I'm also doing something similar |
needed to update the list and item execute query meta data to be :? if they are returning anything. reference: layerware/hugsql#15 (comment)
* WIP: functional testing - mocking out tests and then working on implementing them leveraging migratus to avoid state issues * initial workup of mocking requests and scaffolding out test - wrote a mocking function for dealing with requests generation for passing to handlers. initially pulled in ring-mock, but for now my own cs-http-request-mock is more suited to what i need - lein test and cider test aren't both using the test profile so i'm manually defining the test db for now in the core test file - my first list creation test is working well with my mock funtion - i've defined mock tests for the other crud operations with comments, will tackle those next * bugfix: create queries were returning id of 0 needed to update the list and item execute query meta data to be :? if they are returning anything. reference: layerware/hugsql#15 (comment) * testing update: - full ci pipeline test runs can be run with the test profile and specific database; and driven by a run-tests.sh shell script - removed pieces trying to manipulate the db path already defined once cider is running; i'll just be ok with cider tests running in the dev profile - updated base-mock to allow for params or route-params if defined - added uuid->str function for use in tests - wrote and have working tests for list deletion and item creation * tests update: - added read-item query to get the details of a single item - utility function to convert from hugsql clojure map uuid to java uuid format - reworded tests to assert truthiness when they pass - wrote check, uncheck, and item delete tests - updated tests to not only check for a successful 302 but verified values or deletion as well * update the docs for queries returning an id * refactor helper functions into a util namespace * test refactor: created util functions for generating test lists and items returning maps of needed ids in the desired formats. used new functions in tests and referenced the keys in the returned maps. this is a lot more readable and changing the logic can be done in a single place now as long as the data returned is a map which contains at least the expected keys. * test pipeline update: - updated to circleci v2 - added in container setup for postgres test * setting db name at image load * set db_url for test in ci file * update circle ci file with db config * ci update / fix: - pull out pg vars - make lein use test profile * ci update: - bumping up postgres - removing db url as it's redundant * ci debug * ci debug * debug ci * debug ci * debug ci * ci debug * debug ci * ci debug * ci debug * ci debug * post debug: cleaning up ci file * ci update: add test run and uberjar build back in * build / deploy update: - converted deploy process to v2.0 - due to no heroku integration yet had to follow the docs here: https://circleci.com/docs/2.0/deployment_integrations/#heroku - minor ci fix - updated run-tests for local use which properly sets up and cleans up * fix working directory issue * deploy fix: added checkout step * minor test comment update
@csummers Is this feature supposed to work for |
Works with upsert using INSERT ON CONFLICT statement as well, if there was any doubt. |
Hey,
I am having troubles to define an insert query which should return the new record id. I defined the query this way:
When I execute the query through HugSQL I get a BatchUpdateException, however, If I execute the query on psql it pass without problems (returning the record's id). This is the error stacktrace:
Any thoughts on what could I be missing?
The text was updated successfully, but these errors were encountered: