The short version: To turn a set of PostgreSQL rows into an array, wrap a subselect in the ARRAY function: SELECT ARRAY(SELECT description FROM Appointments). It returns one row with one array, holding one element per input row. Wrap that in array_to_string(…, ‘, ‘) to get a comma-separated string, and use AS to give the…
In my last blog post, I introduced the idea of a PostgreSQL array, and showed how we can insert data into a table using either the curly-brace {} syntax, or the ARRAY construction syntax. In this post, I want to talk about PostgreSQL indexes and length — what happens when we retrieve from indexes that exist (and…
If there’s anything that software people know, it’s that changing one part of a program can result in a change in a seemingly unrelated part of the program. That’s why automated testing is so powerful; it can show you when you have made a mistake that you not only didn’t intend, but that you didn’t…