-
Notifications
You must be signed in to change notification settings - Fork 12
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
Cli act tests #1260
Cli act tests #1260
Conversation
Ok this is ready to go. There are still some tests we need with roundtripping all data types, kgw, etc., but for a beta this should be enough. |
2c04f9d
to
15c8798
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. @Yaiba probably should look though.
cmd/kwil-cli/cmds/exec-action.go
Outdated
execActionLong = `TODO: fill me out` | ||
|
||
execActionExample = `TODO: fill me out` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was wondering how this compared to database execute
etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So @Yaiba pointed out that our old version of database execute simply doesn't work with some of the new things supported within the engine. Namely, it requires all named parameters, rather than positional (which doesn't work for a lot of the things Gavin is doing with extension methods).
Furthermore, the old execute got pretty overloaded. Now that we have ad-hoc INSERT/UPDATE/DELETE, it had to also handle that (at least that's what I felt was most clear, since execute
is definitely what I would expect to use to do that).
So I sort've took this as a chance to fix that. Now, it is clear what to use for actions and SQL. It can still use named params if you want, but positional is the default. The same command that handles executing an action once also handles it with CSV values.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have another commit coming that adds docs for this, as well as a few other things. Since this is already reviewed, we can merge this and then Ill add the other later, since it has a lot of stuff (found a lot of bugs/edge cases)
core/types/results.go
Outdated
if !wrote { | ||
// if it didnt write a value, do not add the empty pointer to the slice |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This means "leave the nil pointer in the slice" or, equivalently, "do not insert a non-nil pointer to the zero value for T"? I didn't know what an "empty pointer" was describing at first.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think thats a bad comment, will fix.
It should say: "if convertScalar did not write to val, we should not add the new pointer to the slice"
will take a quick scan |
|
||
for _, arg := range args { | ||
// trim off any leading '$' | ||
arg = strings.TrimPrefix(arg, "$") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to point it out that this is unlikely to happen, if user pass $xx
(without single quote) to the cli, it'll be expanded by SHELL.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They often times will need to wrap it in single quotes though. For example, if they are passing an array, they have to do:
'param:int[]=[1,2]'
# or
'$param:int[]=[1,2]'
# regardless, they need single quotes
So IMO we should keep it
tests := []testcase{ | ||
// scalars | ||
{"username:text=satoshi", "username", "satoshi", false}, | ||
{`username:text="satoshi"`, "username", "satoshi", false}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should only support single quote, to avoid the confusion if user want to insert a text like $xxx
, because the SHELL will expand the value
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is still the case though. For example:
$ ab='hello!'; kwil-cli query 'select $a' -p a:text="$ab"
| |
+--------+
| hello! |
The double quotes will only get parsed if a user wraps the entire param in them:
ab='hello!'; kwil-cli query 'select $a' -p 'a:text="$ab"'
| |
+-----+
| $ab |
@@ -75,6 +85,28 @@ func makeActionToExecutable(namespace string, act *Action) *executable { | |||
for _, stmt := range stmtFns { | |||
err := stmt(exec2, func(row *row) error { | |||
row.columns = returnColNames | |||
|
|||
// we will ensure that the return values match the expected return types |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
lgtm, only issue I have is parsing 'text' type in cli I mentioned at #1260 (comment) |
new commands for executing sql, actions
e2baa35
to
6c98867
Compare
I ended up including some other changes in this PR. It's all in the last commit, so if you would like me to pop it off into a separate PR so that it is easier to review, I'm happy to. It doesn't include much new stuff except tests, bug fixes, and docs for the new CLI commands. |
6c98867
to
b8ca56a
Compare
many encoding, engine, and CLI fixes ran tidy fix lint
b8ca56a
to
32f9204
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Send it
Still some work to do on this but putting it up for a discussion