From c3d7a625b108002e47ddd923b9a77aa6b1ae7d5d Mon Sep 17 00:00:00 2001 From: Norm Green Date: Wed, 27 Oct 2021 16:14:33 -0700 Subject: [PATCH] Fix issue 1: Timestamp conversion fail with legacy streams --- src/GemConnectForPostgres_Tests_methods.gs | 12 ++++++------ src/GemConnectForPostgres_methods.gs | 18 +++++++++--------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/GemConnectForPostgres_Tests_methods.gs b/src/GemConnectForPostgres_Tests_methods.gs index 8396bfd..581f635 100644 --- a/src/GemConnectForPostgres_Tests_methods.gs +++ b/src/GemConnectForPostgres_Tests_methods.gs @@ -435,7 +435,7 @@ PostgresTestCase sqlForCreateTableNamed: 'table1' columnTypes: { 'character(3)' " | ws | - ws := WriteStream on: String new. + ws := AppendStream on: String new. ws nextPutAll: 'CREATE TABLE '; nextPutAll: aName; @@ -477,7 +477,7 @@ PostgresTestCase sqlForDeleteFromTable: 'table1' column: 'column1' value: 'abc' " |ws| -ws := WriteStream on: String new. +ws := AppendStream on: String new. ^ ws nextPutAll: 'DELETE FROM ' ; nextPutAll: aName ; nextPutAll: ' WHERE '; @@ -511,7 +511,7 @@ PostgresTestCase sqlForInsertValue: 'abc' intoTableNamed: 'table1' " | ws | - ws := WriteStream on: String new. + ws := AppendStream on: String new. ^ ws nextPutAll: 'INSERT INTO '; nextPutAll: aName; @@ -528,7 +528,7 @@ PostgresTestCase sqlForInsertValue: 'abc' intoTableNamed: 'table1' " | ws | - ws := WriteStream on: String new. + ws := AppendStream on: String new. ws nextPutAll: 'INSERT INTO '; nextPutAll: aName; @@ -572,7 +572,7 @@ PostgresTestCase sqlForUpdateTable: 'table1' column: 'column1' oldValue: 'abc' n " |ws| -ws := WriteStream on: String new. +ws := AppendStream on: String new. ^ ws nextPutAll: 'UPDATE ' ; nextPutAll: aName ; nextPutAll: ' SET '; @@ -1002,7 +1002,7 @@ method: PostgresTestCase tableNameExists: aTableName | ws | -ws := WriteStream on: String new. +ws := AppendStream on: String new. ws nextPutAll: 'SELECT EXISTS (SELECT 1 FROM information_schema.tables WHERE table_name = '; nextPut: $' ; nextPutAll: aTableName ; diff --git a/src/GemConnectForPostgres_methods.gs b/src/GemConnectForPostgres_methods.gs index 1173666..825e803 100644 --- a/src/GemConnectForPostgres_methods.gs +++ b/src/GemConnectForPostgres_methods.gs @@ -15,7 +15,7 @@ byteArrayToPostgresString: aByteArray escaped: isEscaped "Convert a multi-byte string to code point literals understood by Postgres." | ws | - ws := WriteStream on: String new. + ws := AppendStream on: String new. ws nextPutAll: '\x'; nextPutAll: aByteArray asHexString . @@ -63,7 +63,7 @@ U&'\+xxxxxx' " ^ isEscaped ifTrue:[ | ws | - ws := WriteStream on: String new. + ws := AppendStream on: String new. ws nextPutAll: 'CONCAT('. 1 to: aMbString size do: @@ -143,7 +143,7 @@ U&'\+xxxxxx' " | ws | - ws := WriteStream on: String new. + ws := AppendStream on: String new. ws nextPutAll: 'CONCAT('. 1 to: aMbString size do: @@ -197,7 +197,7 @@ U&'\+xxxxxx' ^isEscaped ifTrue: [| ws | - ws := WriteStream on: String new. + ws := AppendStream on: String new. ws nextPutAll: 'CONCAT('. 1 to: aMbString size do: @@ -518,7 +518,7 @@ postgresBinDirectory "Derive the bin directory from the library path" "GsLibpq postgresBinDirectory" -^((ReadStream on: self libraryPath) upToAll: '/lib/') addAll: '/bin/' ; yourself +^((ReadStreamPortable on: self libraryPath) upToAll: '/lib/') addAll: '/bin/' ; yourself % category: 'Read Me' classmethod: GsLibpq @@ -2839,7 +2839,7 @@ createInstanceOf: aClass fromFloatString: aString "This code is needed to make Postgres 'money' type map correctly to ScaledDecimal. The $$ and $, characters need to be removed" | rs str | - rs := ReadStream on: aString. + rs := ReadStreamPortable on: aString. rs skipSeparators. rs peek == $$ ifTrue: "We have a currency " @@ -2921,7 +2921,7 @@ GsPostgresResult dateAndTimeFromTimestampTz: '2017-08-25 04:50:00-07' | rs year month day hour minute second tzoffset sign negate haveMicro micro | negate := false. tzoffset := 0. - rs := ReadStream on: aString. + rs := ReadStreamPortable on: aString. year := (rs upTo: $-) asInteger. month := (rs upTo: $-) asInteger. day := (rs upTo: Character space) asInteger. @@ -2970,7 +2970,7 @@ GsPostgresResult dateTimeFromTimestampDiscardTz: '2017-08-25 04:50:12.222-07' | rs year month day hour minute second ms tmp haveMs | haveMs := false. - rs := ReadStream on: aString. + rs := ReadStreamPortable on: aString. year := (rs upTo: $-) asInteger. month := (rs upTo: $-) asInteger. day := (rs upTo: Character space) asInteger. @@ -3341,7 +3341,7 @@ timeFromPostgresTimeString: aString Note: Postgres times with timezones are not supported and the timezone is discarded." | rs secs micro | -rs := ReadStream on: aString. +rs := ReadStreamPortable on: aString. secs :=(rs upTo: $: ) asInteger * 3600. "hours" secs := secs + ((rs upTo: $: ) asInteger * 60). "minutes" "Stop at $+ or $- which is the start of the time zone offset, if any. Otherwise read to the end to get the second"