Comments (9)
I haven't implemented it because it is looks inconsistent. The execute api is designed just for side effectfull operations that does not return nothing, and fetch is designed to be used for query like stuff (anything that return a result). The getGeneratedKeys
is very convenient but it is inconsistent in terms of operations in execute
... and can be properly done using RETURNING *
with fetch operation.
The main difference with clojure.java.jdbc
, is that clojure.jdbc
tries to have concise consistent api. I really like clear path for api usage and I'm not very convinced about the .getGeneratedKeys
utility in balance with the api consistency. (e.g I have never used that in my apps).
PS: nice library, thanks for creating it, I have plans to create an adapter for suricatta
. ;)
from clojure.jdbc.
I definitely understand the consistency issue (see the HugSQL tests for examples). Support is really quite the mess! I made distinctions in HugSQL between "returning execute" and "insert w/ .getGeneratedKeys" in part to encourage the usage of RETURNING *
if the user's database supports it. And, I personally use Postgresql and the RETURNING
clause in my own apps.
However, database support for the RETURNING *
clause is widely unsupported. I think support for it is only available in Postgresql and Oracle.
When a user actually needs support for getting an auto-generated ID, lack of support for .getGeneratedKeys leaves him/her with no option in clojure.jdbc except having to wrap their insert queries with a secondary query to fetch the last inserted id. Maybe that's a hurdle users are willing to jump over to use clojure.jdbc, but I suspect the inconvenience might hinder some adoption of the library.
Either way, I respect the choice to keep a consistent API and to make users deal with those trade-offs.
from clojure.jdbc.
Hmm, i will consider adding this as completely undocumented stuff, because I understand the utility of that, but I don't like promote the usage of that.
I'll implement it today as I have planed release a new version with already merged some bugfixes. Thanks!
from clojure.jdbc.
Thanks for considering it. No pressure here.
(I didn't add support for .getGeneratedKeys in HugSQL until version 0.4.0 because of my own uncertainty about how to implement it well. Ultimately, I decided to make it available but have good tests and documentation on all of the inconsistencies--leaving the user to choose what was appropriate for his/her database.)
from clojure.jdbc.
@csummers This is something that you will expecting? 77afb73#diff-33815d1d7b25e739b789ed1020d3856dR102
from clojure.jdbc.
It behaves differently from clojure.java.jdbc just because it returns a vector of results instead of one unique result.
from clojure.jdbc.
That looks reasonable to me.
from clojure.jdbc.
Released 0.8.0
with that change and other bug fixes.
from clojure.jdbc.
Great! I'll incorporate support for this into the next release of HugSQL.
Thanks!
from clojure.jdbc.
Related Issues (20)
- Helpers functions to retrieve database metadata HOT 2
- How to execute! multiple SQL commands over a connection? HOT 2
- Documentation question HOT 1
- jdbc driver :classname in db spec HOT 1
- Which version of hikari-cp should be used with clojure.jdbc? HOT 2
- Remove potemkin dependency HOT 2
- How are Postgres `time` columns being cast to Date type on SELECT? HOT 2
- Various Derby URLs fail in core.jdbc/connection HOT 1
- Why fetch result column-name are lowercased ? HOT 3
- reflection warnings HOT 1
- org.h2.jdbc.JdbcBatchUpdateException HOT 1
- Wrong isolation level constants in documentation HOT 1
- Close connections when using a datasource directly, or don't let it be used directly.
- Docs: consider mentioning :identifiers and :as-rows? options
- Reflection warnings (types.clj, impl.clj)
- Docs: clarify cursor behavior HOT 4
- java.time interop
- Java 7 Requirement? HOT 2
- Lower Case Identifiers HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from clojure.jdbc.