示例#1
0
				var i int
				err := explainConn.QueryRow("SELECT $1::int", 1).Scan(&i)
				Ω(err).ShouldNot(HaveOccurred())

				Expect(logger).To(gbytes.Say("Result"))
				Expect(logger).To(gbytes.Say("cost="))
				Expect(logger).To(gbytes.Say("SELECT"))
			})
		})

		Describe("Exec()", func() {
			It("EXPLAINs the query", func() {
				_, err := explainConn.Exec("SELECT $1::int", 1)
				Ω(err).ShouldNot(HaveOccurred())

				Ω(underlyingConn.ExecCallCount()).Should(Equal(1))
				Ω(underlyingConn.QueryCallCount()).Should(Equal(1))

				query, args := underlyingConn.ExecArgsForCall(0)
				Ω(query).Should(Equal("SELECT $1::int"))
				Ω(args).Should(Equal(varargs(1)))

				query, args = underlyingConn.QueryArgsForCall(0)
				Ω(query).Should(Equal("EXPLAIN SELECT $1::int"))
				Ω(args).Should(Equal(varargs(1)))
			})

			It("logs the output of the explain", func() {
				_, err := explainConn.Exec("SELECT $1::int", 1)
				Ω(err).ShouldNot(HaveOccurred())
示例#2
0
				var i int
				err := explainConn.QueryRow("SELECT $1::int", 1).Scan(&i)
				Expect(err).NotTo(HaveOccurred())

				Expect(logger).To(gbytes.Say("Result"))
				Expect(logger).To(gbytes.Say("cost="))
				Expect(logger).To(gbytes.Say("SELECT"))
			})
		})

		Describe("Exec()", func() {
			It("EXPLAINs the query", func() {
				_, err := explainConn.Exec("SELECT $1::int", 1)
				Expect(err).NotTo(HaveOccurred())

				Expect(underlyingConn.ExecCallCount()).To(Equal(1))
				Expect(underlyingConn.QueryCallCount()).To(Equal(1))

				query, args := underlyingConn.ExecArgsForCall(0)
				Expect(query).To(Equal("SELECT $1::int"))
				Expect(args).To(Equal(varargs(1)))

				query, args = underlyingConn.QueryArgsForCall(0)
				Expect(query).To(Equal("EXPLAIN SELECT $1::int"))
				Expect(args).To(Equal(varargs(1)))
			})

			It("logs the output of the explain", func() {
				_, err := explainConn.Exec("SELECT $1::int", 1)
				Expect(err).NotTo(HaveOccurred())