From fdeb2412ece2e4767bdd92584d7be188bd63ca47 Mon Sep 17 00:00:00 2001 From: Jack Christensen Date: Thu, 18 Jul 2013 08:39:37 -0500 Subject: [PATCH] Add example for SelectFunc fixes #6 --- connection_test.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/connection_test.go b/connection_test.go index 46c37613..393d35f8 100644 --- a/connection_test.go +++ b/connection_test.go @@ -2,6 +2,7 @@ package pgx_test import ( "bytes" + "fmt" "github.com/JackC/pgx" "strings" "testing" @@ -202,6 +203,26 @@ func TestSelectFuncFailure(t *testing.T) { } } +func Example_connectionSelectFunc() { + conn := getSharedConnection() + + onDataRow := func(r *pgx.DataRowReader) error { + fmt.Println(r.ReadValue()) + return nil + } + + err := conn.SelectFunc("select generate_series(1,$1)", onDataRow, 5) + if err != nil { + fmt.Println(err) + } + // Output: + // 1 + // 2 + // 3 + // 4 + // 5 +} + func TestSelectRows(t *testing.T) { conn := getSharedConnection()