-
Notifications
You must be signed in to change notification settings - Fork 1
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
Database insert function taking Phel map #4
Comments
Return value of That would be more inline with other tools also, |
Clojure JDBC library function https://cljdoc.org/d/com.github.seancorfield/next.jdbc/1.3.981/api/next.jdbc.sql#insert! would be a good role model I think. "Given a connectable object, a table name, and a data hash map, inserts the data as a single row in the database and attempts to return a map of generated keys.". |
@jasalt Currently, phel-pdo is positioned as a simple PDO wrapper library. PDO does not take on the role of building SQL, which is essentially what it does. The ability to pass a table name and map and insert is in the ORM category, so it may be better suited to be implemented as an ORM library in a separate library. What do you think? |
@smeghead right, I see there some SQL generation / driver wrapping separation made between next.jdbc and honeysql (by same author) but those projects have long history already. With that and possible PDP vs JDBC differences etc, I don't disagree that this library should possibly have more narrow focus compared to next.jdbc to get started with. |
With this earlier Maybe a separate minimal "ORM library" would include some functions such as in |
Also noted some differences between JDBC and PDO when mimicking the next.jdbc |
@jasalt The |
@smeghead yes, I indeed skipped that after not finding a similar feature as with parameter escaping with statements. Looking at next-jdbc, there's check for Otherwise legal table names would need to be queried before actual query is made which seems to get complicated as there doesn't seem to be a standard query for getting table info. |
It would be nice to have a simple function that inserts a map representing column names with their row values into DB. I'm not fully sure how it should be secured against injection attacks and such but prepared statements seem to offer some protection. Quick example how it might work:
It does not allow re-using same statement over multiple calls and does not set types explicitly (if needed?) but maybe it could be split up into parts that would simplify the insertion process while helping with security.
The text was updated successfully, but these errors were encountered: