From ba9eadad0de4de0ca7885dba3c8ac2614792e42e Mon Sep 17 00:00:00 2001 From: Scott Fleckenstein Date: Tue, 15 Aug 2017 11:18:40 -0800 Subject: [PATCH 1/2] Move string array handling into proper location --- src/github.com/stellar/horizon/db2/sqx/main.go | 17 +++++++++++++---- .../stellar/horizon/db2/sqx/main_test.go | 2 +- .../stellar/horizon/ingest/ingestion.go | 5 ----- .../stellar/horizon/ingest/ingestion_test.go | 2 +- 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/github.com/stellar/horizon/db2/sqx/main.go b/src/github.com/stellar/horizon/db2/sqx/main.go index bdcc2f02..c09af831 100644 --- a/src/github.com/stellar/horizon/db2/sqx/main.go +++ b/src/github.com/stellar/horizon/db2/sqx/main.go @@ -9,11 +9,20 @@ import ( sq "github.com/Masterminds/squirrel" ) -// StringArray returns a sq.Expr suitable for inclusion in an insert that represents -// the Postgres-compatible array insert. -func StringArray(str []string) interface{} { +// StringArray returns a sq.Expr suitable for inclusion in an insert that +// represents the Postgres-compatible array insert. Strings are quoted. +func StringArray(input []string) interface{} { + quoted := make([]string, len(input)) + + // NOTE (scott): this is naive and janked. We should be using + // https://godoc.org/github.com/lib/pq#Array instead. We should update this + // func code when our version of pq is updated. + for i, str := range input { + quoted[i] = fmt.Sprintf(`"%s"`, str) + } + return sq.Expr( "?::character varying[]", - fmt.Sprintf("{%s}", strings.Join(str, ",")), + fmt.Sprintf("{%s}", strings.Join(quoted, ",")), ) } diff --git a/src/github.com/stellar/horizon/db2/sqx/main_test.go b/src/github.com/stellar/horizon/db2/sqx/main_test.go index c0d60503..f4736301 100644 --- a/src/github.com/stellar/horizon/db2/sqx/main_test.go +++ b/src/github.com/stellar/horizon/db2/sqx/main_test.go @@ -18,5 +18,5 @@ func TestStringArray(t *testing.T) { tt.Assert.Equal("?::character varying[]", sql) tt.Assert.Len(args, 1) - tt.Assert.Equal("{1,2,3}", args[0]) + tt.Assert.Equal(`{"1","2","3"}`, args[0]) } diff --git a/src/github.com/stellar/horizon/ingest/ingestion.go b/src/github.com/stellar/horizon/ingest/ingestion.go index f08fc02f..26ff1d7d 100644 --- a/src/github.com/stellar/horizon/ingest/ingestion.go +++ b/src/github.com/stellar/horizon/ingest/ingestion.go @@ -188,11 +188,6 @@ func (ingest *Ingestion) Start() (err error) { func (ingest *Ingestion) transactionInsertBuilder(id int64, tx *core.Transaction, fee *core.TransactionFee) sq.InsertBuilder { // Enquote empty signatures signatures := tx.Base64Signatures() - for i, sig := range signatures { - if len(sig) == 0 { - signatures[i] = `""` - } - } return ingest.transactions.Values( id, diff --git a/src/github.com/stellar/horizon/ingest/ingestion_test.go b/src/github.com/stellar/horizon/ingest/ingestion_test.go index b51ad88b..296baf52 100644 --- a/src/github.com/stellar/horizon/ingest/ingestion_test.go +++ b/src/github.com/stellar/horizon/ingest/ingestion_test.go @@ -40,7 +40,7 @@ func TestEmptySignature(t *testing.T) { builder := ingestion.transactionInsertBuilder(1, transaction, transactionFee) sql, args, err := builder.ToSql() assert.Equal(t, "INSERT INTO history_transactions (id,transaction_hash,ledger_sequence,application_order,account,account_sequence,fee_paid,operation_count,tx_envelope,tx_result,tx_meta,tx_fee_meta,signatures,time_bounds,memo_type,memo,created_at,updated_at) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?::character varying[],?,?,?,?,?)", sql) - assert.Equal(t, `{8qkkeKaKfsbgInyIkzXJhqJE5/Ufxri2LdxmyKkgkT6I3sPmvrs5cPWQSzEQyhV750IW2ds97xTHqTpOfuZCAg==,""}`, args[12]) + assert.Equal(t, `{"8qkkeKaKfsbgInyIkzXJhqJE5/Ufxri2LdxmyKkgkT6I3sPmvrs5cPWQSzEQyhV750IW2ds97xTHqTpOfuZCAg==",""}`, args[12]) assert.NoError(t, err) err = ingestion.Transaction(1, transaction, transactionFee) From 14555977a6dacbd372dbae8802948ea624ebe1a9 Mon Sep 17 00:00:00 2001 From: Scott Fleckenstein Date: Tue, 15 Aug 2017 16:19:29 -0800 Subject: [PATCH 2/2] Update changelog and bump to v0.11.0 --- CHANGELOG.md | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cbfec680..ff0dda0c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,9 +8,21 @@ bumps. A breaking change will get clearly notified in this log. ## [Unreleased] +## [v0.11.0] - 2017-08-15 + +### Bug fixes + +- The ingestion system can now properly imports envelopes that contain signatures that are zero-length strings. +- BREAKING CHANGE: specifying a `limit` of `0` now triggers an error instead of interpreting the value to mean "use the default limit". +- Requests that ask for more records than the maximum page size now trigger a bad request error, instead of an internal server error. +- Upstream bug fixes to xdr decoding from `github.com/stellar/go`. + ### Changed - BREAKING CHANGE: The payments endpoint now includes `account_merge` operations in the response. +- "Finished Request" log lines now include additional fields: `streaming`, `path`, `ip`, and `host`. +- Responses now include a `Content-Disposition: inline` header. + ## [v0.10.1] - 2017-03-29 @@ -174,7 +186,8 @@ This release contains the initial implementation of the "Abridged History System ### Added - Github releases are created from tagged travis builds automatically -[Unreleased]: https://github.com/stellar/horizon/compare/v0.10.1...master +[Unreleased]: https://github.com/stellar/horizon/compare/v0.11.0...master +[v0.11.0]: https://github.com/stellar/horizon/compare/v0.10.1...v0.11.0 [v0.10.1]: https://github.com/stellar/horizon/compare/v0.10.0...v0.10.1 [v0.10.0]: https://github.com/stellar/horizon/compare/v0.9.1...v0.10.0 [v0.9.1]: https://github.com/stellar/horizon/compare/v0.9.0...v0.9.1