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

Cannot use SQL method with WHERE something > number #17

Open
Impa10r opened this issue Sep 5, 2024 · 0 comments
Open

Cannot use SQL method with WHERE something > number #17

Impa10r opened this issue Sep 5, 2024 · 0 comments

Comments

@Impa10r
Copy link
Contributor

Impa10r commented Sep 5, 2024

This query works using lighting-cli:

$ lightning-cli sql -k query="SELECT * FROM htlcs WHERE expiry > 1;"
{
   "rows": [
      [
         2381,

It also works using JSON-RPC in shell:

$ echo '{"method": "sql", "params": {"query": "SELECT * FROM htlcs WHERE expiry > 1;"}, "id": 1, "jsonrpc": "2.0"}' | nc -U ${PWD}/.lightning/testnet/lightning-rpc
{"jsonrpc":"2.0","id":1,"result":{"rows":[[2456,"2821409x111x0",0,2821429,1000000,"in","c95ad151010e9cc14238bce909e6e8545258fc07d0e00c98a4b5ff90ac049e61","SENT_REMOVE_ACK_REVOCATION"],[2457,"2821

But it DOES NOT work with glightning:

type SQLRequest struct {
	Query string `json:"query"`
}

func (r SQLRequest) Name() string {
	return "sql"
}
....
// this fails with error
// -1:query failed with unrecognized token: "\"
err = lightning.Request(&SQLRequest{
Query: "SELECT * FROM htlcs WHERE expiry > 1;",
}, &response)

glightning is apparently escaping > with \, but I cannot find where.

here is the test repo.

Output:

2024/09/05 16:44:11 Rows: 75
2024/09/05 16:44:11 Rows: 0
2024/09/05 16:44:11 SQLRequest: -1:query failed with 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

1 participant