From e4f401f6ecb44a41ff2d40a0a899037d078d5773 Mon Sep 17 00:00:00 2001 From: Jack Christensen Date: Tue, 8 Sep 2015 12:15:16 -0500 Subject: [PATCH] Add documentation for pointer to pointer null mapping --- CHANGELOG.md | 1 + README.md | 1 + doc.go | 12 ++++++++++-- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cd24a1d2..79d3282c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ # Master +* Add null mapping to pointer to pointer (Jonathan Rudenberg) * Add JSON and JSONB type support (Joseph Glanville) # 2.6.0 (September 3, 2015) diff --git a/README.md b/README.md index 8d579e5c..31434a02 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,7 @@ Pgx supports many additional features beyond what is available through database/ * JSON and JSONB support * Maps inet and cidr PostgreSQL types to net.IPNet * Large object support +* Null mapping to Null* struct or pointer to pointer. ## Performance diff --git a/doc.go b/doc.go index 8b6cf2ff..93145107 100644 --- a/doc.go +++ b/doc.go @@ -121,8 +121,16 @@ notification. Null Mapping -pgx includes Null* types in a similar fashion to database/sql that implement the -necessary interfaces to be encoded and scanned. +pgx can map nulls in two ways. The first is Null* types that have a data field +and a valid field. They work in a similar fashion to database/sql. The second +is to use a pointer to a pointer. + + var foo pgx.NullString + var bar *string + err := conn.QueryRow("select foo, bar from widgets where id=$1", 42).Scan(&a, &b) + if err != nil { + return err + } Array Mapping