Skip to content
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

[ysql] Add SQL helper options #136

Open
preaction opened this issue Nov 25, 2015 · 3 comments
Open

[ysql] Add SQL helper options #136

preaction opened this issue Nov 25, 2015 · 3 comments
Labels

Comments

@preaction
Copy link
Owner

It would be really nice if ysql could write our SQL for us. There are lots of very common things that should be a lot easier to do, like:

$ ysql prod --select users | ysql dev --insert users
# Equivalent to:
$ ysql prod 'SELECT * FROM users' | ysql dev 'INSERT INTO users ( <columns> ) VALUES ( <values> )'

The typing saved, especially on the --insert, is enormous!

@preaction
Copy link
Owner Author

Using SQL::Abstract would make this easy even!

@preaction
Copy link
Owner Author

We should have:

  • --select <table>
  • --insert <table>
  • --where <clause>
  • --sort <column>
  • --update <table>
  • --delete <table>

preaction added a commit that referenced this issue Nov 25, 2015
The `--select <table>` query helper quickly creates a 'SELECT * FROM
<table>' query for you, in a lot less typing.

The `--insert <table>` query helper is even better: For each document on
STDIN, it creates the right `INSERT INTO <table> (<fields>) VALUES
(<values>)` query. This removes the need to use the somewhat clumsy
interpolation syntax to do something simple like inserting entire
documents.

Uses the SQL::Abstract module to do the dirty work.

Refs #136
preaction added a commit that referenced this issue Nov 25, 2015
Now we can add some basic filtering when using the query helpers.

Refs #136
preaction added a commit that referenced this issue Nov 25, 2015
This adds the ability to sort to a `--select` query.

Refs #136
@preaction
Copy link
Owner Author

Still need to do --update and --delete. Delete is straightforward, but update is not: We have to better support placeholders in these things for update to work with any usefulness.

preaction added a commit that referenced this issue Nov 26, 2015
The `--delete` helper option allows us to generate `DELETE FROM` queries,
optionally with a `WHERE` clause (the `--where` option).

Refs #136
preaction added a commit that referenced this issue Nov 26, 2015
The --select helper allows the --where and --order-by, so we should make
sure to mention that in the synopsis and in the documentation.

Refs #136
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant