Add basic SELECT concept/exercise#223
Conversation
There was a problem hiding this comment.
Are hints needed for this one? I'm open to suggestions...
Co-authored-by: Isaac Good <IsaacG@users.noreply.github.com>
| @@ -0,0 +1,15 @@ | |||
| #!/usr/bin/env bash | |||
| db_file=$1 | |||
| mapfile -t slugs < <(jq -r 'keys[]' test_data.json) | |||
There was a problem hiding this comment.
FWIW it's worth noting that this will fail on Mac with the default/older bash.
There was a problem hiding this comment.
If you want to write a guard for that:
if (( BASH_VERSINFO[0] < 5 )); then
echo "get a modern bash from Homebrew" >&2
exit 1
fiThere was a problem hiding this comment.
And jq is not standardly installed:
if ! command -v jq >/dev/null; then
echo "Required tool 'jq' is not installed" >&2
exit 1
fiThere was a problem hiding this comment.
I guess it would be nice, for users that want to run the tests locally. But I would recommend against anything Mac-specific like "Homebrew" in the error message.
There was a problem hiding this comment.
Any Linux system ought to have bash5 😄 I don't think the exact message matters much, thought for Mac users (the primary target of that message) a nudge towards Homebrew could be handy.
There was a problem hiding this comment.
Of course, Windows users would need to do a lot more to run the tests, like install a bash-compatible environment such as cygwin or mingw, and then ensure jq is installed in the environment. Maybe it would make sense to update sqlite/exercises/shared/.docs/tests.md accordingly, as well as adding the guards in the script?
There was a problem hiding this comment.
Homebrew is for Linux too. I prefer it for some packages (like exercism) because it usually provides quicker access to new versions.
There was a problem hiding this comment.
And/or instructions for running the tests in Docker?
There was a problem hiding this comment.
Since we have installation instructions for Windows, it's a bad look if the first concept exercise can't run on Windows.
I fired up a Windows VM and installed sqlite (via chocolatey: did you want a PR with those instructions?) -- the sqlite3 cli's .shell command uses cmd, so we'd want a batch file equivalent of the shell script.
Anybody want to take that on?
There was a problem hiding this comment.
I might give it a try, if I can spin up a Windows VM somehow without buying a license.
| 844110220987 Appliances Culinary Depot BlendPro High-Speed Personal Blender 3.1 16 | ||
| ``` | ||
|
|
||
| In addition to `=` and `BETWEEN...AND`, the `WHERE` clause supports a wide range of expressions, including comparison (`<`, `<=`, `>`, `>=`), pattern matching (`LIKE`, `GLOB`, `REGEXP`, `MATCH`), and checking for membership in a list (`IN`, `NOT IN`). |
There was a problem hiding this comment.
Some of the pattern matching operators are probably specific to sqlite. Did you want to stay more db-neutral?
There was a problem hiding this comment.
I don't really have a strong opinion here. I guess it would be nice to stay as generic as possible, but the concept docs do provide links to SQLite specific docs.
There was a problem hiding this comment.
This is the SQLite track, not a generic SQL track. I think SQLite specific things are completely fine, and probably even preferred.
| @@ -0,0 +1,127 @@ | |||
| # Introduction | |||
There was a problem hiding this comment.
I assume this is the same as the concept introduction document. You might want to use a template. When you make changes to the concept doc, you don't have to make the same changes here but just do bin/configlet generate
There was a problem hiding this comment.
It's close, but not an exact copy:
127a128,132
>
> In addition to `=` and `BETWEEN...AND`, the `WHERE` clause supports a wide range of expressions, including comparison (`<`, `<=`, `>`, `>=`), pattern matching (`LIKE`, `GLOB`, `REGEXP`, `MATCH`), and checking for membership in a list (`IN`, `NOT IN`).
> See [SQL Language Expressions](sql-expr) for the complete documentation.
>
> [sql-expr]: https://sqlite.org/lang_expr.html
| @@ -0,0 +1,15 @@ | |||
| #!/usr/bin/env bash | |||
| db_file=$1 | |||
| mapfile -t slugs < <(jq -r 'keys[]' test_data.json) | |||
There was a problem hiding this comment.
If you want to write a guard for that:
if (( BASH_VERSINFO[0] < 5 )); then
echo "get a modern bash from Homebrew" >&2
exit 1
fi| @@ -0,0 +1,15 @@ | |||
| #!/usr/bin/env bash | |||
| db_file=$1 | |||
| mapfile -t slugs < <(jq -r 'keys[]' test_data.json) | |||
There was a problem hiding this comment.
And jq is not standardly installed:
if ! command -v jq >/dev/null; then
echo "Required tool 'jq' is not installed" >&2
exit 1
fi|
I was checking it out in Windows, in a git-bash environment:
I haven't really thought about a powershell translation of the results script though. |
Co-authored-by: Glenn Jackman <glenn.jackman@gmail.com>
Incorporates ideas from #217, #218 and #219.