Skip to content
This repository was archived by the owner on Jan 13, 2025. It is now read-only.

Introduce ZIO SQL "driver" interface #22

Closed
jdegoes opened this issue May 19, 2020 · 3 comments
Closed

Introduce ZIO SQL "driver" interface #22

jdegoes opened this issue May 19, 2020 · 3 comments
Assignees

Comments

@jdegoes
Copy link
Collaborator

jdegoes commented May 19, 2020

The ZIO SQL driver interface will have:

  • select
  • deleteFrom
  • update
  • insert

and, possibly in the future, DDL.

These will return ZIO effects or ZIO streams, as appropriate.

This is expected to be a lightweight project at the top-level, on which JDBC / etc. projects will depend to expose CRUD functionality atop the core SQL query data model.

@jdegoes jdegoes self-assigned this May 19, 2020
@jdegoes
Copy link
Collaborator Author

jdegoes commented Sep 8, 2020

This is partially implemented. We have to figure out whether or not to combine the ReadExecutor / etc. interfaces into a single interface, or keep them separate.

@phderome
Copy link

phderome commented Sep 8, 2020

note for insert. returning clause returning data to caller should be supported. See for example https://mariadb.com/kb/en/insertreturning/#:~:text=Description-,INSERT%20...,alternatively%2C%20the%20specified%20SELECT%20expression.

Postgres doc: https://www.postgresql.org/docs/9.5/sql-insert.html

quote:

Insert a single row into table distributors, returning the sequence number generated by the DEFAULT clause:

INSERT INTO distributors (did, dname) VALUES (DEFAULT, 'XYZ Widgets')
   RETURNING did;
Increment the sales count of the salesperson who manages the account for Acme Corporation, and record the whole updated row along with current time in a log table:

WITH upd AS (
  UPDATE employees SET sales_count = sales_count + 1 WHERE id =
    (SELECT sales_person FROM accounts WHERE name = 'Acme Corporation')
    RETURNING *
)
INSERT INTO employees_log SELECT *, current_timestamp FROM upd;

@sviezypan
Copy link
Collaborator

Mostly implemented, rest is in the issue #596

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

No branches or pull requests

3 participants