Skip to content

Add basic SELECT concept/exercise - #223

Merged
IsaacG merged 11 commits into
exercism:mainfrom
blackk-foxx:feature/select-concept-exercise
Oct 29, 2026
Merged

IsaacG merged 11 commits into
exercism:mainfrom
blackk-foxx:feature/select-concept-exercise

Conversation

@blackk-foxx

Copy link
Copy Markdown
Contributor

Incorporates ideas from #217, #218 and #219.

Copy link
Copy Markdown
Contributor Author

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...

Comment thread concepts/select/about.md Resolved
Comment thread concepts/select/about.md Resolved
Comment thread concepts/select/about.md Resolved
Comment thread concepts/select/about.md Resolved
Comment thread concepts/select/about.md Resolved
Comment thread concepts/select/about.md Resolved
@blackk-foxx
blackk-foxx requested a review from IsaacG December 17, 2025 20:05
Comment thread config.json Resolved
@@ -0,0 +1,15 @@
#!/usr/bin/env bash
db_file=$1
mapfile -t slugs < <(jq -r 'keys[]' test_data.json)

Copy link
Copy Markdown
Member

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.

Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Contributor

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

@blackk-foxx blackk-foxx Dec 23, 2025 •

Copy link
Copy Markdown
Contributor Author

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.

Copy link
Copy Markdown
Member

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.

Copy link
Copy Markdown
Contributor

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.

Copy link
Copy Markdown
Contributor Author

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?

Copy link
Copy Markdown
Contributor

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?

Copy link
Copy Markdown
Contributor Author

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't look like anyone is too keen on translating bash to batch. Except for the guard to test for the existence of jq, I'd say carry on.

@IsaacG IsaacG left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@glennj @vaeng Any things/feedback before we merge this?

Comment thread concepts/select/about.md Resolved
@@ -0,0 +1,127 @@
# Introduction

Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Contributor Author

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you intend to reconcile the differences?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't planning to. But I'm open to suggestions.

@@ -0,0 +1,15 @@
#!/usr/bin/env bash
db_file=$1
mapfile -t slugs < <(jq -r 'keys[]' test_data.json)

Copy link
Copy Markdown
Contributor

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)

Copy link
Copy Markdown
Contributor

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

@glennj

glennj commented Jan 19, 2026

Copy link
Copy Markdown
Contributor

I was checking it out in Windows, in a git-bash environment:

  • had to install jq from jqlang.org
  • had to change this line
    mapfile -t slugs < <(jq -r 'keys[]' test_data.json | sed 's/\r$//')
    I suppose the jq build for windows was adding carriage returns 'cuz it's windows. Annoying.
  • Then the exemplar ran successfully (after fixing the quoting bug)

I haven't really thought about a powershell translation of the results script though.

Co-authored-by: Glenn Jackman <glenn.jackman@gmail.com>
@IsaacG

IsaacG commented Oct 23, 2026

Copy link
Copy Markdown
Member

@Glenn @blackk-foxx What's the status here?

@blackk-foxx

Copy link
Copy Markdown
Contributor Author

@glennj, I addressed your change request. Anything else?

@glennj glennj left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, let's close this out.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be removed if it is empty?

@IsaacG
IsaacG merged commit 4f26956 into exercism:main Oct 29, 2026
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

Successfully merging this pull request may close these issues.

3 participants