From ca5544dc1d9d203165b9355a90e00d1bb6c4711f Mon Sep 17 00:00:00 2001 From: Carlos Lopez <27969022+lopezca@users.noreply.github.com> Date: Sun, 3 Mar 2024 13:14:13 -0600 Subject: [PATCH] FIx printOn: message. Guessing `sql` in the original message referes to source, because that's what the sql: setter message uses. --- P3-Tests/P3FormattedStatementTest.class.st | 18 ++++++++++++++++++ P3/P3FormattedStatement.class.st | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/P3-Tests/P3FormattedStatementTest.class.st b/P3-Tests/P3FormattedStatementTest.class.st index 3dc6f2a..b5cc6de 100644 --- a/P3-Tests/P3FormattedStatementTest.class.st +++ b/P3-Tests/P3FormattedStatementTest.class.st @@ -211,6 +211,24 @@ P3FormattedStatementTest >> testNull [ client execute: 'DROP TABLE table1' ] +{ #category : #tests } +P3FormattedStatementTest >> testPrintOn [ +"client format: returns a P3FormattedStatement. Use result to test printOn:" + + | sql p3fs result| + + sql := 'INSERT INTO table1 (id, name) VALUES ($1, $2)'. + + p3fs := client format: sql. + + result := String streamContents: [ :stream | p3fs printOn: stream ]. + + self assert: result contents equals: ('a P3FormattedStatement({1})' format: { sql }) + + + +] + { #category : #tests } P3FormattedStatementTest >> testSimple [ | statement result | diff --git a/P3/P3FormattedStatement.class.st b/P3/P3FormattedStatement.class.st index 613e1ea..48c0fa1 100644 --- a/P3/P3FormattedStatement.class.st +++ b/P3/P3FormattedStatement.class.st @@ -139,7 +139,7 @@ P3FormattedStatement >> printObject: object on: stream [ { #category : #printing } P3FormattedStatement >> printOn: stream [ super printOn: stream. - stream nextPut: $(; << sql; nextPut: $) + stream nextPut: $(; << source; nextPut: $) ] { #category : #'printing-dispatched' }