I'm working through writing a Go app backed by a PostgreSQL database (using sqlx). Whenever I'm writing code that interacts with a database, I want to make sure that I'm testing against the real thing -- especially when using plain old SQL statements where dialects can differ between databases. One thing I do in PHP… Continue reading Running Database Integration Tests in Go
Category: PostgreSQL
PostgreSQL’s ROW_TO_JSON and JSON_AGG with JSON Columns
I've hit this a few times and had to remind myself how Postgres behaves when aggregating JSON columns or including them in ROW_TO_JSON. The short answer is that Postgres does the right thing. When a JSON column is included in ROW_TO_JSON or JSON_AGG the resulting values are not nested, encoded JSON. Here's our sample table… Continue reading PostgreSQL’s ROW_TO_JSON and JSON_AGG with JSON Columns
Working with PostgreSQL Arrays in PHP
I recently had to do some work with PostgreSQL arrays in a PHP app. My first question: how do I manage arrays as parameterized values in a query? Turns out there are two ways forward: Array Literals These appear in the Postgres documentation as curly brace surrounded, comma delimited lists: {1,2,3}. A literal like this… Continue reading Working with PostgreSQL Arrays in PHP

