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

calling a favorite from within a favorite #101

Open
elig0n opened this issue Oct 9, 2020 · 4 comments
Open

calling a favorite from within a favorite #101

elig0n opened this issue Oct 9, 2020 · 4 comments

Comments

@elig0n
Copy link
Contributor

elig0n commented Oct 9, 2020

I would like to call another favorite from one favorite. i.e.

[favorite_queries]
test = 'SELECT * FROM database WHERE id = "$1"'
test2 = '\f test "$1"'

but I get:

litecli> \f test2 12
unrecognized token: "\"

Can this be done ?

@zzl0
Copy link
Contributor

zzl0 commented Oct 10, 2020

Thanks for your feedback. The current design is that the favorite query should be a SQL query.

Could you please explain why you need this? The example above doesn't make sense to me, since you can just run \f test 12 instead. If you want to give it another name, could you copy the SQL and give it a new name?

@elig0n
Copy link
Contributor Author

elig0n commented Oct 12, 2020

That wasn't a very good example indeed.
The main need would be to combine & reuse several queries to show up several queries' results all at once.

e.g.

q1 = 'SELECT id FROM database WHERE id = "$1" '
q2 = 'SELECT percentage, (quantity * 8), (distance-6) FROM database WHERE id = "$1" AND owner = "$2" '
...
complex1 = '\f q1 "$1"; \f q2 "$1" "$2"; '

Consider that I have some rather long recursive queries in favorites that I would like to display with some other favorite queries like in the above example so repeatedly typing \f ... ; \f .... ; ...; to see combined results gets tiresome. It would spare typing arguments several times and so on . Yes I can do the concatenations inside the queries themselves and clone queries several time but I thought that this feature can come handy and add to versatility.

@zzl0
Copy link
Contributor

zzl0 commented Oct 13, 2020

Thanks for the detailed explanation. I understand why you need this feature, but I hesitate to add it to litecli. It's like introduce variables to the configuration, it may result in complex queries (e.g. the q1 can be a combination of other favorite queries as well). I am not sure if it's worth doing this in litecli, since we can use programming language to implement complex query requirements.

Hi @amjith, what do you think about this feature?

@elig0n
Copy link
Contributor Author

elig0n commented Oct 13, 2020

I thought maybe you can do instead shell-like "aliases" so the entire set of litecli commands can be mixed together and called at once via a nickname. This would allow for example setting a specific table format before viewing a result of a favorite query, or set a custom pager or prompt.
i.e:
\alias aliasname '\T vertical; \P bat ; \f q1 arg1;'

As of right now using backslash-commands in favorites results in
unrecognized token: "\"

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

No branches or pull requests

2 participants