-
-
Notifications
You must be signed in to change notification settings - Fork 14
Add basic SELECT concept/exercise #223
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
base: main
Are you sure you want to change the base?
Add basic SELECT concept/exercise #223
Conversation
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW it's worth noting that this will fail on Mac with the default/older bash.
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And/or instructions for running the tests in Docker?
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I might give it a try, if I can spin up a Windows VM somehow without buying a license.
IsaacG
left a comment
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.
| 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And jq is not standardly installed:
if ! command -v jq >/dev/null; then
echo "Required tool 'jq' is not installed" >&2
exit 1
fi
Incorporates ideas from #217, #218 and #219.