<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>What's New in Pgx V5 on The Blog of Boban Acimovic</title><link>https://acim.net/series/whats-new-in-pgx-v5/</link><description>Recent content in What's New in Pgx V5 on The Blog of Boban Acimovic</description><generator>Hugo -- gohugo.io</generator><language>en-us</language><copyright>The Blog of Boban Acimovic &amp;copy; 2026</copyright><lastBuildDate>Sun, 16 Jul 2023 00:00:00 +0000</lastBuildDate><atom:link href="https://acim.net/series/whats-new-in-pgx-v5/index.xml" rel="self" type="application/rss+xml"/><item><title>What's new in pgx v5: CollectRows, RowToStructByName, CollectOneRow, RowToStructByPos and ForEachRow</title><link>https://acim.net/blog/pgx-v5-3/</link><pubDate>Sun, 16 Jul 2023 00:00:00 +0000</pubDate><guid>https://acim.net/blog/pgx-v5-3/</guid><description>&lt;p&gt;This is the third part of the &lt;code&gt;pgx v5&lt;/code&gt; series. Let&amp;rsquo;s discuss the new features from the title.&lt;/p&gt;

&lt;h3 class="relative group"&gt;CollectRows and RowToStructByName
 &lt;div id="collectrows-and-rowtostructbyname" class="anchor"&gt;&lt;/div&gt;
 
 &lt;span
 class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"&gt;
 &lt;a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#collectrows-and-rowtostructbyname" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;CollectRows&lt;/code&gt; allow us to fetch an array of rows and set them into a slice of structs. Further, &lt;code&gt;RowToStructByName&lt;/code&gt; is a long awaited feature which allows to store a row into a struct. &lt;a href="https://github.com/jmoiron/sqlx" target="_blank" rel="noopener"&gt;sqlx&lt;/a&gt;
 module became very popular in Go community exactly for this reason, but &lt;code&gt;pgx&lt;/code&gt; now supports something similar. &lt;code&gt;RowToStructByName&lt;/code&gt; is a generic function of the &lt;code&gt;func(row CollectableRow) (T, error)&lt;/code&gt; and it&amp;rsquo;s not the only one of this type, there are also &lt;code&gt;RowTo&lt;/code&gt;, &lt;code&gt;RowToStructByPos&lt;/code&gt; and &lt;code&gt;RowToStructByNameLax&lt;/code&gt;. Under the hood, &lt;code&gt;RowToStructByName&lt;/code&gt; is using reflection so it may be slightly slower than classic way of scanning the rows, but if you don&amp;rsquo;t mind this, it is very easy to use. All field names are going to be mapped to lowercased public struct field names and you may also use &lt;code&gt;db&lt;/code&gt; struct tags if some field name differs from the struct field name. This explanation may sound difficult, but the following example will actually show that it is actually very easy to use.&lt;/p&gt;</description></item><item><title>What's new in pgx v5: QueryRewriter and NamedArgs</title><link>https://acim.net/blog/pgx-v5-2/</link><pubDate>Sat, 15 Jul 2023 00:00:00 +0000</pubDate><guid>https://acim.net/blog/pgx-v5-2/</guid><description>&lt;p&gt;In this second part of the &lt;code&gt;pgx v5&lt;/code&gt; series, we are going to discuss the &lt;code&gt;QueryRewriter&lt;/code&gt; interface and &lt;code&gt;NamedArgs&lt;/code&gt;. Let&amp;rsquo;s first check out the signature of the &lt;code&gt;Exec&lt;/code&gt; method of the &lt;code&gt;pgxpool.Pool&lt;/code&gt; struct.&lt;/p&gt;</description></item><item><title>What's new in pgx v5: Introduction</title><link>https://acim.net/blog/pgx-v5-1/</link><pubDate>Sun, 04 Dec 2022 00:00:00 +0000</pubDate><guid>https://acim.net/blog/pgx-v5-1/</guid><description>&lt;p&gt;Go has very rich standard library which also contains &lt;a href="https://pkg.go.dev/database/sql" target="_blank" rel="noopener"&gt;database/sql&lt;/a&gt;
 module with generic interface over SQL databases. Further, &lt;a href="https://github.com/lib/pq" target="_blank" rel="noopener"&gt;lib/pq&lt;/a&gt;
 &lt;code&gt;PostgreSQL&lt;/code&gt; driver is fully compatible with &lt;code&gt;database/sql&lt;/code&gt; and provides all basic database operations. However, since this is generic implementation over all supported databases, using it is a trade-off not supporting some PostgreSQL specific features. Fans of &lt;code&gt;PostgreSQL&lt;/code&gt; (in further text &lt;code&gt;pg&lt;/code&gt;) may want more and here comes &lt;a href="https://github.com/jackc/pgx" target="_blank" rel="noopener"&gt;pgx&lt;/a&gt;
 in help. &lt;code&gt;pgx&lt;/code&gt; is a very rich &lt;code&gt;pg&lt;/code&gt; driver supporting &lt;code&gt;LISTEN / NOTIFY&lt;/code&gt;, &lt;code&gt;COPY&lt;/code&gt;, type mapping between &lt;code&gt;pg&lt;/code&gt; and &lt;code&gt;Go&lt;/code&gt;, all specific &lt;code&gt;pg&lt;/code&gt; types, wire protocol and much more.&lt;/p&gt;</description></item></channel></rss>