From 9a33dacd1727ba1f9292cdf6165d3bb72459321a Mon Sep 17 00:00:00 2001 From: Todd Blanchard Date: Tue, 13 Jul 2021 04:23:40 -0700 Subject: [PATCH 01/16] Adds NeoCSV as a dependency and provides asCSV and asJSON for MySQLRow. Also nicer column indexing allowing int or name. --- BaselineOfMySQL/BaselineOfMySQL.class.st | 8 +++++-- MySQL-Core/MySQLNetworkSession.class.st | 10 ++++++++ MySQL-Core/MysqlDriverSpec.class.st | 2 +- MySQL-Core/MysqlField.class.st | 11 +++++++++ MySQL-Core/MysqlQueryRowData.class.st | 29 +++++++++++++++++++++++- MySQL-Core/MysqlResultSet.class.st | 13 +++++++++++ 6 files changed, 69 insertions(+), 4 deletions(-) diff --git a/BaselineOfMySQL/BaselineOfMySQL.class.st b/BaselineOfMySQL/BaselineOfMySQL.class.st index 32ea836..7f97f45 100644 --- a/BaselineOfMySQL/BaselineOfMySQL.class.st +++ b/BaselineOfMySQL/BaselineOfMySQL.class.st @@ -36,7 +36,11 @@ BaselineOfMySQL >> setUpDependencies: spec [ spec baseline: 'NeoJSON' with: [ spec repository: 'github://svenvc/NeoJSON:master/repository' ]; project: 'NeoJSON-Core' copyFrom: 'NeoJSON' with: [ spec loads: 'core' ]. - + + spec + baseline: 'NeoCSV' with: [ spec repository: 'github://svenvc/NeoCSV:master/repository' ]; + project: 'NeoCSV-Core' copyFrom: 'NeoCSV' with: [ spec loads: 'core' ]. + spec baseline: 'ZTimestamp' with: [ spec repository: 'github://svenvc/ztimestamp:master/repository' ]. @@ -52,7 +56,7 @@ BaselineOfMySQL >> setUpDependencies: spec [ BaselineOfMySQL >> setUpPackages: spec [ spec - package: 'MySQL-Core' with: [ spec requires: #('NeoJSON-Core' 'ZTimestamp') ]; + package: 'MySQL-Core' with: [ spec requires: #('NeoJSON-Core' 'NeoCSV-CORE' 'ZTimestamp') ]; group: 'core' with: 'MySQL-Core'. spec diff --git a/MySQL-Core/MySQLNetworkSession.class.st b/MySQL-Core/MySQLNetworkSession.class.st index 2e8b5a9..0bea0bd 100644 --- a/MySQL-Core/MySQLNetworkSession.class.st +++ b/MySQL-Core/MySQLNetworkSession.class.st @@ -95,6 +95,16 @@ MySQLNetworkSession >> stream: aStream [ ] +{ #category : #accessing } +MySQLNetworkSession >> timeout [ + ^theStream timeout +] + +{ #category : #accessing } +MySQLNetworkSession >> timeout: seconds [ + theStream timeout: seconds +] + { #category : #accessing } MySQLNetworkSession >> toHost: host andPort: port [ | aStream | diff --git a/MySQL-Core/MysqlDriverSpec.class.st b/MySQL-Core/MysqlDriverSpec.class.st index 432812d..08baded 100644 --- a/MySQL-Core/MysqlDriverSpec.class.st +++ b/MySQL-Core/MysqlDriverSpec.class.st @@ -57,7 +57,7 @@ MySQLDriverSpec >> password: userPassword [ { #category : #accessing } MySQLDriverSpec >> port [ - ^ port + ^ port ifNil: [ port := 3306 ] ] { #category : #accessing } diff --git a/MySQL-Core/MysqlField.class.st b/MySQL-Core/MysqlField.class.st index 69522e3..5f791b3 100644 --- a/MySQL-Core/MysqlField.class.st +++ b/MySQL-Core/MysqlField.class.st @@ -138,6 +138,17 @@ MySQLField >> parse [ ] +{ #category : #accessing } +MySQLField >> printOn: aStream [ + super printOn: aStream. + aStream + nextPutAll: ' ('; + nextPutAll: table; + nextPut: $.; + nextPutAll: self name; + nextPutAll: ')' +] + { #category : #accessing } MySQLField >> table [ ^ table diff --git a/MySQL-Core/MysqlQueryRowData.class.st b/MySQL-Core/MysqlQueryRowData.class.st index 88322b2..1c10b47 100644 --- a/MySQL-Core/MysqlQueryRowData.class.st +++ b/MySQL-Core/MysqlQueryRowData.class.st @@ -11,9 +11,25 @@ Class { #category : #'MySQL-Core-Packet-RowData' } +{ #category : #accessing } +MySQLQueryRowData >> asDictionary [ + | pairs | + pairs := OrderedCollection new: fields size. + fields doWithIndex: [ :f :i | pairs add: (f name -> (self atIndex: i)) ]. + ^pairs asDictionary +] + { #category : #accessing } MySQLQueryRowData >> at: indx [ - ^ self atIndex: indx + ^ indx isInteger + ifTrue: [self atIndex: indx] + ifFalse: [ self atFieldNamed: indx ] +] + +{ #category : #accessing } +MySQLQueryRowData >> atFieldNamed: aName [ + ^ self atIndex: (self indexOfFieldNamed: aName) + ] { #category : #accessing } @@ -27,6 +43,11 @@ MySQLQueryRowData >> columnCount: aCount [ ] +{ #category : #enumerating } +MySQLQueryRowData >> do: aBlock [ + ^columns do: aBlock +] + { #category : #accessing } MySQLQueryRowData >> fields [ ^ fields @@ -37,6 +58,12 @@ MySQLQueryRowData >> fields: anObject [ fields := anObject ] +{ #category : #accessing } +MySQLQueryRowData >> indexOfFieldNamed: aName [ + self fields doWithIndex: [ :f :idx | f name = aName ifTrue: [ ^idx ] ]. + ^0 +] + { #category : #accessing } MySQLQueryRowData >> last [ ^ columns atIndex: (columns size) diff --git a/MySQL-Core/MysqlResultSet.class.st b/MySQL-Core/MysqlResultSet.class.st index e794c50..de30981 100644 --- a/MySQL-Core/MysqlResultSet.class.st +++ b/MySQL-Core/MysqlResultSet.class.st @@ -16,6 +16,19 @@ Class { #category : #'MySQL-Core-Packet-Results' } +{ #category : #converting } +MySQLResultSet >> asCSV [ + ^String streamContents: [ :writeStream | + (NeoCSVWriter on: writeStream) + writeHeader: (self fields collect: [:ea | ea name]); + nextPutAll: rows ] +] + +{ #category : #converting } +MySQLResultSet >> asJSON [ + ^NeoJSONWriter toString: (self rows collect: [ :ea | ea asDictionary ]) +] + { #category : #testing } MySQLResultSet >> atEnd [ From af02103491c8dbee56e2b45736595eef184f0c3c Mon Sep 17 00:00:00 2001 From: Gabriel Omar Cotelli Date: Tue, 13 Jul 2021 08:36:28 -0300 Subject: [PATCH 02/16] Fix execution permissions of script --- scripts/setup-RDBMS.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 scripts/setup-RDBMS.sh diff --git a/scripts/setup-RDBMS.sh b/scripts/setup-RDBMS.sh old mode 100644 new mode 100755 From 1dc955dd15a0b76e9436245f56284239068f70cb Mon Sep 17 00:00:00 2001 From: Gabriel Omar Cotelli Date: Tue, 13 Jul 2021 08:43:24 -0300 Subject: [PATCH 03/16] Update build infra --- .github/workflows/build.yml | 10 +++++----- .smalltalk.ston | 3 +-- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 760e28e..056be89 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -20,15 +20,15 @@ jobs: - name: Set up Smalltalk CI uses: hpi-swa/setup-smalltalkCI@v1 with: - smalltalk-version: ${{ matrix.smalltalk }} + smalltalk-image: ${{ matrix.smalltalk }} - name: Load Image and Run Tests run: smalltalkci -s ${{ matrix.smalltalk }} - timeout-minutes: 15 env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} RDBMS: ${{ matrix.rdbms }} - - run: echo "::set-env name=SCI_COVERAGE_FILE_LOCATION::${HOME}/.smalltalkCI/_builds/coveralls_results.json" + timeout-minutes: 15 - name: Upload coverage to Codecov - uses: codecov/codecov-action@v1.0.6 + uses: codecov/codecov-action@v1 with: + name: ${{matrix.os}}-${{matrix.smalltalk}}-${{ matrix.rdbms }} token: ${{ secrets.CODECOV_TOKEN }} - file: ${{ env.SCI_COVERAGE_FILE_LOCATION }} diff --git a/.smalltalk.ston b/.smalltalk.ston index 6129be9..8f0249d 100644 --- a/.smalltalk.ston +++ b/.smalltalk.ston @@ -10,8 +10,7 @@ SmalltalkCISpec { #testing : { #coverage : { #packages : [ 'MySQL*' ], - #service: #codecov, - #auto_upload: false + #format: #lcov } } } From 4e90b740dddc381792b7c261bfe9dbb3f20cfd83 Mon Sep 17 00:00:00 2001 From: Todd Blanchard Date: Tue, 13 Jul 2021 04:53:27 -0700 Subject: [PATCH 04/16] Fix reference to NeoCSV --- BaselineOfMySQL/BaselineOfMySQL.class.st | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/BaselineOfMySQL/BaselineOfMySQL.class.st b/BaselineOfMySQL/BaselineOfMySQL.class.st index 7f97f45..3aa9b79 100644 --- a/BaselineOfMySQL/BaselineOfMySQL.class.st +++ b/BaselineOfMySQL/BaselineOfMySQL.class.st @@ -39,7 +39,7 @@ BaselineOfMySQL >> setUpDependencies: spec [ spec baseline: 'NeoCSV' with: [ spec repository: 'github://svenvc/NeoCSV:master/repository' ]; - project: 'NeoCSV-Core' copyFrom: 'NeoCSV' with: [ spec loads: 'core' ]. + project: 'Neo-CSV-Core' copyFrom: 'NeoCSV' with: [ spec loads: 'core' ]. spec baseline: 'ZTimestamp' @@ -56,7 +56,7 @@ BaselineOfMySQL >> setUpDependencies: spec [ BaselineOfMySQL >> setUpPackages: spec [ spec - package: 'MySQL-Core' with: [ spec requires: #('NeoJSON-Core' 'NeoCSV-CORE' 'ZTimestamp') ]; + package: 'MySQL-Core' with: [ spec requires: #('NeoJSON-Core' 'Neo-CSV-Core' 'ZTimestamp') ]; group: 'core' with: 'MySQL-Core'. spec From 86d53e323a32997eedb0eae1c39c3b4d4d4c756c Mon Sep 17 00:00:00 2001 From: Gabriel Omar Cotelli Date: Tue, 13 Jul 2021 09:23:38 -0300 Subject: [PATCH 05/16] Fix smalltakCI Spec --- .github/workflows/build.yml | 2 +- .smalltalk.ston | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 056be89..3a97c99 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -3,7 +3,7 @@ name: Build on: [push,pull_request] jobs: - build: + build: runs-on: ubuntu-latest strategy: fail-fast: false diff --git a/.smalltalk.ston b/.smalltalk.ston index 8f0249d..e5fd22d 100644 --- a/.smalltalk.ston +++ b/.smalltalk.ston @@ -8,10 +8,9 @@ SmalltalkCISpec { } ], #testing : { - #coverage : { + #coverage : { #packages : [ 'MySQL*' ], #format: #lcov - } } } } From 10c639a3749be6d3ebd58a6ed1201eeb890b54de Mon Sep 17 00:00:00 2001 From: Gabriel Omar Cotelli Date: Tue, 13 Jul 2021 10:09:48 -0300 Subject: [PATCH 06/16] Fix casing in file names to match the class names --- .../{MysqlCommandsTest.class.st => MySQLCommandsTest.class.st} | 0 .../{MysqlDriverTest.class.st => MySQLDriverTest.class.st} | 0 ...ltiStatementTest.class.st => MySQLMultiStatementTest.class.st} | 0 ...ysqlQueryStatusTest.class.st => MySQLQueryStatusTest.class.st} | 0 .../{MysqlTestCase.class.st => MySQLTestCase.class.st} | 0 .../{MysqlTestFixture.class.st => MySQLTestFixture.class.st} | 0 .../{MysqlTestResource.class.st => MySQLTestResource.class.st} | 0 .../{MysqlHelperTest.class.st => MySQLHelperTest.class.st} | 0 .../{Mysql323Scramble.class.st => MySQL323Scramble.class.st} | 0 MySQL-Core/{MysqlBindError.class.st => MySQLBindError.class.st} | 0 MySQL-Core/{MysqlClientAuth.class.st => MySQLClientAuth.class.st} | 0 MySQL-Core/{MysqlCommand.class.st => MySQLCommand.class.st} | 0 .../{MysqlComplexResult.class.st => MySQLComplexResult.class.st} | 0 MySQL-Core/{MysqlDriver.class.st => MySQLDriver.class.st} | 0 .../{MysqlDriverError.class.st => MySQLDriverError.class.st} | 0 MySQL-Core/{MysqlDriverSpec.class.st => MySQLDriverSpec.class.st} | 0 MySQL-Core/{MysqlEof.class.st => MySQLEof.class.st} | 0 MySQL-Core/{MysqlError.class.st => MySQLError.class.st} | 0 MySQL-Core/{MysqlField.class.st => MySQLField.class.st} | 0 MySQL-Core/{MysqlHandshake.class.st => MySQLHandshake.class.st} | 0 MySQL-Core/{MysqlHelper.class.st => MySQLHelper.class.st} | 0 ...validPacketError.class.st => MySQLInvalidPacketError.class.st} | 0 ...qlInvalidRowAccess.class.st => MySQLInvalidRowAccess.class.st} | 0 ...NameLookupFailure.class.st => MySQLNameLookupFailure.class.st} | 0 ...NoConnectionError.class.st => MySQLNoConnectionError.class.st} | 0 MySQL-Core/{MysqlOkay.class.st => MySQLOkay.class.st} | 0 MySQL-Core/{MysqlPacket.class.st => MySQLPacket.class.st} | 0 .../{MysqlPrepareOkay.class.st => MySQLPrepareOkay.class.st} | 0 .../{MysqlQueryRowData.class.st => MySQLQueryRowData.class.st} | 0 MySQL-Core/{MysqlResult.class.st => MySQLResult.class.st} | 0 MySQL-Core/{MysqlResultSet.class.st => MySQLResultSet.class.st} | 0 ...ysqlResultSetHeader.class.st => MySQLResultSetHeader.class.st} | 0 MySQL-Core/{MysqlRowData.class.st => MySQLRowData.class.st} | 0 .../{MysqlServerStatus.class.st => MySQLServerStatus.class.st} | 0 .../{MysqlStringRowData.class.st => MySQLStringRowData.class.st} | 0 MySQL-Core/{MysqlTypes.class.st => MySQLTypes.class.st} | 0 ...portedAuthError.class.st => MySQLUnsuportedAuthError.class.st} | 0 ...tocolError.class.st => MySQLUnsupportedProtocolError.class.st} | 0 38 files changed, 0 insertions(+), 0 deletions(-) rename MySQL-Core-Tests-Integration/{MysqlCommandsTest.class.st => MySQLCommandsTest.class.st} (100%) rename MySQL-Core-Tests-Integration/{MysqlDriverTest.class.st => MySQLDriverTest.class.st} (100%) rename MySQL-Core-Tests-Integration/{MysqlMultiStatementTest.class.st => MySQLMultiStatementTest.class.st} (100%) rename MySQL-Core-Tests-Integration/{MysqlQueryStatusTest.class.st => MySQLQueryStatusTest.class.st} (100%) rename MySQL-Core-Tests-Integration/{MysqlTestCase.class.st => MySQLTestCase.class.st} (100%) rename MySQL-Core-Tests-Integration/{MysqlTestFixture.class.st => MySQLTestFixture.class.st} (100%) rename MySQL-Core-Tests-Integration/{MysqlTestResource.class.st => MySQLTestResource.class.st} (100%) rename MySQL-Core-Tests/{MysqlHelperTest.class.st => MySQLHelperTest.class.st} (100%) rename MySQL-Core/{Mysql323Scramble.class.st => MySQL323Scramble.class.st} (100%) rename MySQL-Core/{MysqlBindError.class.st => MySQLBindError.class.st} (100%) rename MySQL-Core/{MysqlClientAuth.class.st => MySQLClientAuth.class.st} (100%) rename MySQL-Core/{MysqlCommand.class.st => MySQLCommand.class.st} (100%) rename MySQL-Core/{MysqlComplexResult.class.st => MySQLComplexResult.class.st} (100%) rename MySQL-Core/{MysqlDriver.class.st => MySQLDriver.class.st} (100%) rename MySQL-Core/{MysqlDriverError.class.st => MySQLDriverError.class.st} (100%) rename MySQL-Core/{MysqlDriverSpec.class.st => MySQLDriverSpec.class.st} (100%) rename MySQL-Core/{MysqlEof.class.st => MySQLEof.class.st} (100%) rename MySQL-Core/{MysqlError.class.st => MySQLError.class.st} (100%) rename MySQL-Core/{MysqlField.class.st => MySQLField.class.st} (100%) rename MySQL-Core/{MysqlHandshake.class.st => MySQLHandshake.class.st} (100%) rename MySQL-Core/{MysqlHelper.class.st => MySQLHelper.class.st} (100%) rename MySQL-Core/{MysqlInvalidPacketError.class.st => MySQLInvalidPacketError.class.st} (100%) rename MySQL-Core/{MysqlInvalidRowAccess.class.st => MySQLInvalidRowAccess.class.st} (100%) rename MySQL-Core/{MysqlNameLookupFailure.class.st => MySQLNameLookupFailure.class.st} (100%) rename MySQL-Core/{MysqlNoConnectionError.class.st => MySQLNoConnectionError.class.st} (100%) rename MySQL-Core/{MysqlOkay.class.st => MySQLOkay.class.st} (100%) rename MySQL-Core/{MysqlPacket.class.st => MySQLPacket.class.st} (100%) rename MySQL-Core/{MysqlPrepareOkay.class.st => MySQLPrepareOkay.class.st} (100%) rename MySQL-Core/{MysqlQueryRowData.class.st => MySQLQueryRowData.class.st} (100%) rename MySQL-Core/{MysqlResult.class.st => MySQLResult.class.st} (100%) rename MySQL-Core/{MysqlResultSet.class.st => MySQLResultSet.class.st} (100%) rename MySQL-Core/{MysqlResultSetHeader.class.st => MySQLResultSetHeader.class.st} (100%) rename MySQL-Core/{MysqlRowData.class.st => MySQLRowData.class.st} (100%) rename MySQL-Core/{MysqlServerStatus.class.st => MySQLServerStatus.class.st} (100%) rename MySQL-Core/{MysqlStringRowData.class.st => MySQLStringRowData.class.st} (100%) rename MySQL-Core/{MysqlTypes.class.st => MySQLTypes.class.st} (100%) rename MySQL-Core/{MysqlUnsuportedAuthError.class.st => MySQLUnsuportedAuthError.class.st} (100%) rename MySQL-Core/{MysqlUnsupportedProtocolError.class.st => MySQLUnsupportedProtocolError.class.st} (100%) diff --git a/MySQL-Core-Tests-Integration/MysqlCommandsTest.class.st b/MySQL-Core-Tests-Integration/MySQLCommandsTest.class.st similarity index 100% rename from MySQL-Core-Tests-Integration/MysqlCommandsTest.class.st rename to MySQL-Core-Tests-Integration/MySQLCommandsTest.class.st diff --git a/MySQL-Core-Tests-Integration/MysqlDriverTest.class.st b/MySQL-Core-Tests-Integration/MySQLDriverTest.class.st similarity index 100% rename from MySQL-Core-Tests-Integration/MysqlDriverTest.class.st rename to MySQL-Core-Tests-Integration/MySQLDriverTest.class.st diff --git a/MySQL-Core-Tests-Integration/MysqlMultiStatementTest.class.st b/MySQL-Core-Tests-Integration/MySQLMultiStatementTest.class.st similarity index 100% rename from MySQL-Core-Tests-Integration/MysqlMultiStatementTest.class.st rename to MySQL-Core-Tests-Integration/MySQLMultiStatementTest.class.st diff --git a/MySQL-Core-Tests-Integration/MysqlQueryStatusTest.class.st b/MySQL-Core-Tests-Integration/MySQLQueryStatusTest.class.st similarity index 100% rename from MySQL-Core-Tests-Integration/MysqlQueryStatusTest.class.st rename to MySQL-Core-Tests-Integration/MySQLQueryStatusTest.class.st diff --git a/MySQL-Core-Tests-Integration/MysqlTestCase.class.st b/MySQL-Core-Tests-Integration/MySQLTestCase.class.st similarity index 100% rename from MySQL-Core-Tests-Integration/MysqlTestCase.class.st rename to MySQL-Core-Tests-Integration/MySQLTestCase.class.st diff --git a/MySQL-Core-Tests-Integration/MysqlTestFixture.class.st b/MySQL-Core-Tests-Integration/MySQLTestFixture.class.st similarity index 100% rename from MySQL-Core-Tests-Integration/MysqlTestFixture.class.st rename to MySQL-Core-Tests-Integration/MySQLTestFixture.class.st diff --git a/MySQL-Core-Tests-Integration/MysqlTestResource.class.st b/MySQL-Core-Tests-Integration/MySQLTestResource.class.st similarity index 100% rename from MySQL-Core-Tests-Integration/MysqlTestResource.class.st rename to MySQL-Core-Tests-Integration/MySQLTestResource.class.st diff --git a/MySQL-Core-Tests/MysqlHelperTest.class.st b/MySQL-Core-Tests/MySQLHelperTest.class.st similarity index 100% rename from MySQL-Core-Tests/MysqlHelperTest.class.st rename to MySQL-Core-Tests/MySQLHelperTest.class.st diff --git a/MySQL-Core/Mysql323Scramble.class.st b/MySQL-Core/MySQL323Scramble.class.st similarity index 100% rename from MySQL-Core/Mysql323Scramble.class.st rename to MySQL-Core/MySQL323Scramble.class.st diff --git a/MySQL-Core/MysqlBindError.class.st b/MySQL-Core/MySQLBindError.class.st similarity index 100% rename from MySQL-Core/MysqlBindError.class.st rename to MySQL-Core/MySQLBindError.class.st diff --git a/MySQL-Core/MysqlClientAuth.class.st b/MySQL-Core/MySQLClientAuth.class.st similarity index 100% rename from MySQL-Core/MysqlClientAuth.class.st rename to MySQL-Core/MySQLClientAuth.class.st diff --git a/MySQL-Core/MysqlCommand.class.st b/MySQL-Core/MySQLCommand.class.st similarity index 100% rename from MySQL-Core/MysqlCommand.class.st rename to MySQL-Core/MySQLCommand.class.st diff --git a/MySQL-Core/MysqlComplexResult.class.st b/MySQL-Core/MySQLComplexResult.class.st similarity index 100% rename from MySQL-Core/MysqlComplexResult.class.st rename to MySQL-Core/MySQLComplexResult.class.st diff --git a/MySQL-Core/MysqlDriver.class.st b/MySQL-Core/MySQLDriver.class.st similarity index 100% rename from MySQL-Core/MysqlDriver.class.st rename to MySQL-Core/MySQLDriver.class.st diff --git a/MySQL-Core/MysqlDriverError.class.st b/MySQL-Core/MySQLDriverError.class.st similarity index 100% rename from MySQL-Core/MysqlDriverError.class.st rename to MySQL-Core/MySQLDriverError.class.st diff --git a/MySQL-Core/MysqlDriverSpec.class.st b/MySQL-Core/MySQLDriverSpec.class.st similarity index 100% rename from MySQL-Core/MysqlDriverSpec.class.st rename to MySQL-Core/MySQLDriverSpec.class.st diff --git a/MySQL-Core/MysqlEof.class.st b/MySQL-Core/MySQLEof.class.st similarity index 100% rename from MySQL-Core/MysqlEof.class.st rename to MySQL-Core/MySQLEof.class.st diff --git a/MySQL-Core/MysqlError.class.st b/MySQL-Core/MySQLError.class.st similarity index 100% rename from MySQL-Core/MysqlError.class.st rename to MySQL-Core/MySQLError.class.st diff --git a/MySQL-Core/MysqlField.class.st b/MySQL-Core/MySQLField.class.st similarity index 100% rename from MySQL-Core/MysqlField.class.st rename to MySQL-Core/MySQLField.class.st diff --git a/MySQL-Core/MysqlHandshake.class.st b/MySQL-Core/MySQLHandshake.class.st similarity index 100% rename from MySQL-Core/MysqlHandshake.class.st rename to MySQL-Core/MySQLHandshake.class.st diff --git a/MySQL-Core/MysqlHelper.class.st b/MySQL-Core/MySQLHelper.class.st similarity index 100% rename from MySQL-Core/MysqlHelper.class.st rename to MySQL-Core/MySQLHelper.class.st diff --git a/MySQL-Core/MysqlInvalidPacketError.class.st b/MySQL-Core/MySQLInvalidPacketError.class.st similarity index 100% rename from MySQL-Core/MysqlInvalidPacketError.class.st rename to MySQL-Core/MySQLInvalidPacketError.class.st diff --git a/MySQL-Core/MysqlInvalidRowAccess.class.st b/MySQL-Core/MySQLInvalidRowAccess.class.st similarity index 100% rename from MySQL-Core/MysqlInvalidRowAccess.class.st rename to MySQL-Core/MySQLInvalidRowAccess.class.st diff --git a/MySQL-Core/MysqlNameLookupFailure.class.st b/MySQL-Core/MySQLNameLookupFailure.class.st similarity index 100% rename from MySQL-Core/MysqlNameLookupFailure.class.st rename to MySQL-Core/MySQLNameLookupFailure.class.st diff --git a/MySQL-Core/MysqlNoConnectionError.class.st b/MySQL-Core/MySQLNoConnectionError.class.st similarity index 100% rename from MySQL-Core/MysqlNoConnectionError.class.st rename to MySQL-Core/MySQLNoConnectionError.class.st diff --git a/MySQL-Core/MysqlOkay.class.st b/MySQL-Core/MySQLOkay.class.st similarity index 100% rename from MySQL-Core/MysqlOkay.class.st rename to MySQL-Core/MySQLOkay.class.st diff --git a/MySQL-Core/MysqlPacket.class.st b/MySQL-Core/MySQLPacket.class.st similarity index 100% rename from MySQL-Core/MysqlPacket.class.st rename to MySQL-Core/MySQLPacket.class.st diff --git a/MySQL-Core/MysqlPrepareOkay.class.st b/MySQL-Core/MySQLPrepareOkay.class.st similarity index 100% rename from MySQL-Core/MysqlPrepareOkay.class.st rename to MySQL-Core/MySQLPrepareOkay.class.st diff --git a/MySQL-Core/MysqlQueryRowData.class.st b/MySQL-Core/MySQLQueryRowData.class.st similarity index 100% rename from MySQL-Core/MysqlQueryRowData.class.st rename to MySQL-Core/MySQLQueryRowData.class.st diff --git a/MySQL-Core/MysqlResult.class.st b/MySQL-Core/MySQLResult.class.st similarity index 100% rename from MySQL-Core/MysqlResult.class.st rename to MySQL-Core/MySQLResult.class.st diff --git a/MySQL-Core/MysqlResultSet.class.st b/MySQL-Core/MySQLResultSet.class.st similarity index 100% rename from MySQL-Core/MysqlResultSet.class.st rename to MySQL-Core/MySQLResultSet.class.st diff --git a/MySQL-Core/MysqlResultSetHeader.class.st b/MySQL-Core/MySQLResultSetHeader.class.st similarity index 100% rename from MySQL-Core/MysqlResultSetHeader.class.st rename to MySQL-Core/MySQLResultSetHeader.class.st diff --git a/MySQL-Core/MysqlRowData.class.st b/MySQL-Core/MySQLRowData.class.st similarity index 100% rename from MySQL-Core/MysqlRowData.class.st rename to MySQL-Core/MySQLRowData.class.st diff --git a/MySQL-Core/MysqlServerStatus.class.st b/MySQL-Core/MySQLServerStatus.class.st similarity index 100% rename from MySQL-Core/MysqlServerStatus.class.st rename to MySQL-Core/MySQLServerStatus.class.st diff --git a/MySQL-Core/MysqlStringRowData.class.st b/MySQL-Core/MySQLStringRowData.class.st similarity index 100% rename from MySQL-Core/MysqlStringRowData.class.st rename to MySQL-Core/MySQLStringRowData.class.st diff --git a/MySQL-Core/MysqlTypes.class.st b/MySQL-Core/MySQLTypes.class.st similarity index 100% rename from MySQL-Core/MysqlTypes.class.st rename to MySQL-Core/MySQLTypes.class.st diff --git a/MySQL-Core/MysqlUnsuportedAuthError.class.st b/MySQL-Core/MySQLUnsuportedAuthError.class.st similarity index 100% rename from MySQL-Core/MysqlUnsuportedAuthError.class.st rename to MySQL-Core/MySQLUnsuportedAuthError.class.st diff --git a/MySQL-Core/MysqlUnsupportedProtocolError.class.st b/MySQL-Core/MySQLUnsupportedProtocolError.class.st similarity index 100% rename from MySQL-Core/MysqlUnsupportedProtocolError.class.st rename to MySQL-Core/MySQLUnsupportedProtocolError.class.st From c6fc24ebac407794f27cadd9e8191a609c756155 Mon Sep 17 00:00:00 2001 From: Todd Blanchard Date: Tue, 13 Jul 2021 12:36:00 -0700 Subject: [PATCH 07/16] Move CSV into its own target as an extension to allow optional loading. --- BaselineOfMySQL/BaselineOfMySQL.class.st | 6 +++++- MySQL-CSV/MySQLResultSet.extension.st | 9 +++++++++ MySQL-CSV/package.st | 1 + MySQL-Core/MySQLResultSet.class.st | 8 -------- MySQL-Glorp/MySQLDatabaseDriver.class.st | 5 +++++ 5 files changed, 20 insertions(+), 9 deletions(-) create mode 100644 MySQL-CSV/MySQLResultSet.extension.st create mode 100644 MySQL-CSV/package.st diff --git a/BaselineOfMySQL/BaselineOfMySQL.class.st b/BaselineOfMySQL/BaselineOfMySQL.class.st index 3aa9b79..41bbb91 100644 --- a/BaselineOfMySQL/BaselineOfMySQL.class.st +++ b/BaselineOfMySQL/BaselineOfMySQL.class.st @@ -56,8 +56,12 @@ BaselineOfMySQL >> setUpDependencies: spec [ BaselineOfMySQL >> setUpPackages: spec [ spec - package: 'MySQL-Core' with: [ spec requires: #('NeoJSON-Core' 'Neo-CSV-Core' 'ZTimestamp') ]; + package: 'MySQL-Core' with: [ spec requires: #('NeoJSON-Core' 'ZTimestamp') ]; group: 'core' with: 'MySQL-Core'. + + spec + package: 'MySQL-CSV' with: [ spec requires: #('MySQL-Core' 'Neo-CSV-Core') ]; + group: 'csv' with: 'MySQL-CSV'. spec package: 'MySQL-Glorp' with: [ spec requires: #('MySQL-Core' 'Glorp-Deployment') ]; diff --git a/MySQL-CSV/MySQLResultSet.extension.st b/MySQL-CSV/MySQLResultSet.extension.st new file mode 100644 index 0000000..596ed51 --- /dev/null +++ b/MySQL-CSV/MySQLResultSet.extension.st @@ -0,0 +1,9 @@ +Extension { #name : #MySQLResultSet } + +{ #category : #'*MySQL-CSV' } +MySQLResultSet >> asCSV [ + ^String streamContents: [ :writeStream | + (NeoCSVWriter on: writeStream) + writeHeader: (self fields collect: [:ea | ea name]); + nextPutAll: rows ] +] diff --git a/MySQL-CSV/package.st b/MySQL-CSV/package.st new file mode 100644 index 0000000..4da620b --- /dev/null +++ b/MySQL-CSV/package.st @@ -0,0 +1 @@ +Package { #name : #'MySQL-CSV' } diff --git a/MySQL-Core/MySQLResultSet.class.st b/MySQL-Core/MySQLResultSet.class.st index de30981..e113311 100644 --- a/MySQL-Core/MySQLResultSet.class.st +++ b/MySQL-Core/MySQLResultSet.class.st @@ -16,14 +16,6 @@ Class { #category : #'MySQL-Core-Packet-Results' } -{ #category : #converting } -MySQLResultSet >> asCSV [ - ^String streamContents: [ :writeStream | - (NeoCSVWriter on: writeStream) - writeHeader: (self fields collect: [:ea | ea name]); - nextPutAll: rows ] -] - { #category : #converting } MySQLResultSet >> asJSON [ ^NeoJSONWriter toString: (self rows collect: [ :ea | ea asDictionary ]) diff --git a/MySQL-Glorp/MySQLDatabaseDriver.class.st b/MySQL-Glorp/MySQLDatabaseDriver.class.st index e192589..78eaeb6 100644 --- a/MySQL-Glorp/MySQLDatabaseDriver.class.st +++ b/MySQL-Glorp/MySQLDatabaseDriver.class.st @@ -1,3 +1,8 @@ +" +I am a Glorp database driver implementation for using MySQL with Glorp. + +The Glorp database driver provides a unifying common interface for interacting with SQL databases. +" Class { #name : #MySQLDatabaseDriver, #superclass : #DatabaseDriver, From 7d46beb5458d8b42d29afdd05f9725d54fc614b7 Mon Sep 17 00:00:00 2001 From: Todd Blanchard Date: Wed, 14 Jul 2021 10:40:47 -0700 Subject: [PATCH 08/16] Lets see if this works... --- BaselineOfMySQL/BaselineOfMySQL.class.st | 17 +- .../MySQLStatementReadCSVTest.class.st | 332 ++++++++++++++++++ MySQL-CSV-Tests/package.st | 1 + .../MySQLStatementReadTest.class.st | 3 +- MySQL-Core/MySQLBinaryRowData.class.st | 5 + 5 files changed, 354 insertions(+), 4 deletions(-) create mode 100644 MySQL-CSV-Tests/MySQLStatementReadCSVTest.class.st create mode 100644 MySQL-CSV-Tests/package.st diff --git a/BaselineOfMySQL/BaselineOfMySQL.class.st b/BaselineOfMySQL/BaselineOfMySQL.class.st index 41bbb91..97b8e86 100644 --- a/BaselineOfMySQL/BaselineOfMySQL.class.st +++ b/BaselineOfMySQL/BaselineOfMySQL.class.st @@ -55,17 +55,28 @@ BaselineOfMySQL >> setUpDependencies: spec [ { #category : #baselines } BaselineOfMySQL >> setUpPackages: spec [ + "Usually group names are capitalized, however this baselie has used group names of all lower case. + For consistency we have capitalized the group names and kept the lower case names as aliases for compatibility. + New projects should use the capitalized names and existing projects should convert to capitalized names as soon + as convenient as the lower case names will eventually be removd." + spec package: 'MySQL-Core' with: [ spec requires: #('NeoJSON-Core' 'ZTimestamp') ]; - group: 'core' with: 'MySQL-Core'. + group: 'Core' with: 'MySQL-Core'. + + spec group: 'core' with: [ spec requires: #('Core') ]. spec package: 'MySQL-CSV' with: [ spec requires: #('MySQL-Core' 'Neo-CSV-Core') ]; - group: 'csv' with: 'MySQL-CSV'. + group: 'CSV' with: 'MySQL-CSV'. + + spec group: 'csv' with: [ spec requires: #( 'CSV' ) ]. spec package: 'MySQL-Glorp' with: [ spec requires: #('MySQL-Core' 'Glorp-Deployment') ]; - group: 'glorp' with: 'MySQL-Glorp'. + group: 'MySQL-Glorp' with: 'MySQL-Glorp'. + + spec group: 'glorp' with: [ spec requires: #( 'MySQL-Glorp' ) ]. spec package: 'MySQL-Core-Tests' with: [ spec requires: 'MySQL-Core' ]; diff --git a/MySQL-CSV-Tests/MySQLStatementReadCSVTest.class.st b/MySQL-CSV-Tests/MySQLStatementReadCSVTest.class.st new file mode 100644 index 0000000..e2fef4a --- /dev/null +++ b/MySQL-CSV-Tests/MySQLStatementReadCSVTest.class.st @@ -0,0 +1,332 @@ +Class { + #name : #MySQLStatementReadCSVTest, + #superclass : #MySQLTestCase, + #category : #'MySQL-CSV-Tests' +} + +{ #category : #accessing } +MySQLStatementReadCSVTest >> scenarios [ +^ ' +- should read results of integer types + - tinyint, smallint, mediumint, (long)int, bigint +- should read results of real types + - float, double, real (approx values) +- should read results of real types + - decimal, numeric (exact values) +- should read results of date types + - date, time, datetime, timestamp, year +- should read results of char types + - char, varchar +- should read results of binary types + - binary, varbinary +- should read results of blob types + - tinyblob, blob, mediumblob longblob +- should read results of text types + - tinytext, text, mediumtext, longtext +' + +] + +{ #category : #tests } +MySQLStatementReadCSVTest >> testReadBlobTypes [ + | prep stmtId params resp stmt csv | + self + withFixtures: #(#blobs ) + do: + [ :conn | + prep := conn prepare: 'select * from testBlobs where id < ? order by id'. + stmtId := prep prepareOkay stmtHandlerId. + params := Array with: (MySQLBindParameter withValue: 5). + stmt := MySQLDriverStatement onConnection: conn. + stmt + stmtId: stmtId; + params: params. + resp := stmt execute. + self assert: resp isResultSet. + csv := resp asCSV. + + self assert: resp rows size equals: 2. + self assert: csv lines first equals: '"id","tinyblobValue","blobValue","mediumblobValue","longblobValue"'. + self assert: csv lines second equals: '"1","0123456789","0123456789","0123456789","0123456789"'. + self assert: csv lines third equals: '"2","1234567890","","","1234567890"'. + + self assert: (resp rows first atIndex: 2) equals: '0123456789' asByteArray. + self assert: (resp rows first atIndex: 3) equals: '0123456789' asByteArray. + self assert: (resp rows first atIndex: 4) equals: '0123456789' asByteArray. + self assert: (resp rows first atIndex: 5) equals: '0123456789' asByteArray. + self assert: (resp rows second atIndex: 2) equals: '1234567890' asByteArray. + self assert: (resp rows second atIndex: 3) isNil. + self assert: (resp rows second atIndex: 4) isNil. + self assert: (resp rows second atIndex: 5) equals: '1234567890' asByteArray ] +] + +{ #category : #tests } +MySQLStatementReadCSVTest >> testReadCharTypes [ + | prep stmtId params resp stmt csv | + self withFixtures: #(#chars) do: [:conn | + prep := conn prepare: 'select * from testChars where id < ? order by id'. + stmtId := prep prepareOkay stmtHandlerId.. + params := Array with: (MySQLBindParameter withValue: 5). + + stmt := MySQLDriverStatement onConnection: conn. + stmt stmtId: stmtId; params: params. + + resp := stmt execute. + self assert: resp isResultSet. + csv := resp asCSV. + self assert: csv lines size equals: 3. + self assert: csv lines first equals: '"id","charValue","varcharValue"'. + self assert: csv lines second equals: '"1","smalltalk","An awesome programming environment"'. + self assert: csv lines third equals: '"2","lisp","So is this one"' ] + +] + +{ #category : #tests } +MySQLStatementReadCSVTest >> testReadIntegerTypes [ + | prep stmtId params resp stmt csv | + self withFixtures: #(#integers) do: [:conn | + prep := conn prepare: 'select * from testIntegers order by id'. + stmtId := prep prepareOkay stmtHandlerId. + params := #(). + + stmt := MySQLDriverStatement onConnection: conn. + stmt stmtId: stmtId; params: params. + + resp := stmt execute. + self assert: resp isResultSet. + csv := resp asCSV. + self assert: resp rows size equals: 5. + self assert: csv lines size equals: 6. + self assert: csv lines first equals: '"id","tinyintValue","smallintValue","mediumintValue","intValue","bigintValue"'. + self assert: csv lines second equals: '"1","0","300","40000","100000","6000000000"'. + self assert: csv lines last equals: '"5","-101","-301","-40001","-100001","-6000000001"'. + ] +] + +{ #category : #tests } +MySQLStatementReadCSVTest >> testReadIntegerTypesNeg [ + | prep stmtId params resp stmt csv | + self withFixtures: #(#integers) do: [:conn | + prep := conn prepare: 'select * from testIntegers where tinyintValue < ? order by id'. + stmtId := prep prepareOkay stmtHandlerId. + + params := MySQLBindParameter + listOfSize: prep prepareOkay numParams + forDescriptors: prep paramDescriptors. + params first bindValue: -100. + + + stmt := MySQLDriverStatement onConnection: conn. + stmt stmtId: stmtId; params: params. + + resp := stmt execute. + self assert: resp isResultSet. + csv := resp asCSV. + + self assert: resp rows size equals: 1. + self assert: csv lines size equals: 2. + self assert: csv lines first equals: '"id","tinyintValue","smallintValue","mediumintValue","intValue","bigintValue"'. + self assert: csv lines last equals: '"5","-101","-301","-40001","-100001","-6000000001"' + ] +] + +{ #category : #tests } +MySQLStatementReadCSVTest >> testReadIntegerTypesNull [ + | prep stmtId params resp stmt csv | + self + withFixtures: #(#integers ) + do: + [ :conn | + prep := conn prepare: 'select * from testIntegers order by id'. + stmtId := prep prepareOkay stmtHandlerId. + params := #(). + stmt := MySQLDriverStatement onConnection: conn. + stmt + stmtId: stmtId; + params: params. + resp := stmt execute. + self assert: resp isResultSet. + csv := resp asCSV. + + self assert: resp rows size = 5. + self assert: csv lines size equals: 6. + self assert: csv lines first equals: '"id","tinyintValue","smallintValue","mediumintValue","intValue","bigintValue"'. + self assert: csv lines fourth equals: '"3","2","","","","6000000002"'. + self assert: (resp rows third atIndex: 4) isNil. + self assert: (resp rows third atIndex: 6) equals: 6000000002. + self assert: (resp rows fourth atIndex: 4) equals: 40003. + self assert: (resp rows fourth atIndex: 6) isNil ] +] + +{ #category : #tests } +MySQLStatementReadCSVTest >> testReadRealTypes [ + | prep stmtId params resp stmt csv | + self withFixtures: #(#reals) do: [:conn | + prep := conn prepare: 'select * from testReals order by id'. + stmtId := prep prepareOkay stmtHandlerId. + params := #(). + + stmt := MySQLDriverStatement onConnection: conn. + stmt stmtId: stmtId; params: params. + + resp := stmt execute. + self assert: resp isResultSet. + csv := resp asCSV. + self assert: resp rows size equals: 3. + self assert: csv lines size equals: 4. + self assert: csv lines first equals: '"id","floatValue","doubleValue","realValue","decimalValue","numericValue"'. + self assert: csv lines second equals: '"1","1.100000023841858","11.11","222.222","3333.333333s6","4444.444444s6"'. + self assert: ((resp rows first atIndex: 2) closeTo: 1.1). + self assert: ((resp rows first atIndex: 3) closeTo: 11.11). + self assert: ((resp rows first atIndex: 4) closeTo: 222.222). + self assert: (resp rows first atIndex: 5) = ((3333333333 / 1000000) asScaledDecimal: 6). + self assert: (resp rows first atIndex: 6) = (((4444444444 / 1000000) asScaledDecimal: 6)). + ] +] + +{ #category : #tests } +MySQLStatementReadCSVTest >> testReadRealTypesNeg [ + | prep stmtId params resp stmt csv | + self withFixtures: #(#reals) do: [:conn | + prep := conn prepare: 'select * from testReals order by id'. + stmtId := prep prepareOkay stmtHandlerId.. + params := #(). + + stmt := MySQLDriverStatement onConnection: conn. + stmt stmtId: stmtId; params: params. + + resp := stmt execute. + self assert: resp isResultSet. + csv := resp asCSV. + self assert: resp rows size equals: 3. + self assert: csv lines size equals: 4. + self assert: csv lines first equals: '"id","floatValue","doubleValue","realValue","decimalValue","numericValue"'. + self assert: csv lines fourth equals: '"3","-1.100000023841858","-11.11","-222.222","-3333.333333s6","-4444.444444s6"'. + self assert: ((resp rows third atIndex: 2) closeTo: -1.1). + self assert: ((resp rows third atIndex: 3) closeTo: -11.11). + self assert: ((resp rows third atIndex: 4) closeTo: -222.222). + self assert: (resp rows third atIndex: 5) = ((-3333333333 / 1000000) asScaledDecimal: 6). + self assert: (resp rows third atIndex: 6) = ((-4444444444 / 1000000) asScaledDecimal: 6). + ] +] + +{ #category : #tests } +MySQLStatementReadCSVTest >> testReadRealTypesNull [ + | prep stmtId params resp stmt csv | + self + withFixtures: #(#reals ) + do: + [ :conn | + prep := conn prepare: 'select * from testReals order by id'. + stmtId := prep prepareOkay stmtHandlerId. + params := #(). + stmt := MySQLDriverStatement onConnection: conn. + stmt + stmtId: stmtId; + params: params. + resp := stmt execute. + self assert: resp isResultSet. + csv := resp asCSV. + self assert: resp rows size equals: 3. + self assert: csv lines size equals: 4. + self assert: csv lines first equals: '"id","floatValue","doubleValue","realValue","decimalValue","numericValue"'. + self assert: csv lines third equals: '"2","","","","","-5555.555555s6"'. + self assert: (resp rows second atIndex: 2) isNil. + self assert: (resp rows second atIndex: 3) isNil. + self assert: (resp rows second atIndex: 4) isNil. + self assert: (resp rows second atIndex: 5) isNil. + self assert: (resp rows second atIndex: 6) = (-5555555555 / 1000000 asScaledDecimal: 6) ] +] + +{ #category : #tests } +MySQLStatementReadCSVTest >> testReadTimeTypes [ + | prep stmtId params resp stmt csv | + self withFixtures: #(#times) do: [:conn | + prep := conn prepare: 'select * from testTimes order by id'. + stmtId := prep prepareOkay stmtHandlerId.. + params := #(). + + stmt := MySQLDriverStatement onConnection: conn. + stmt stmtId: stmtId; params: params. + + resp := stmt execute. + self assert: resp isResultSet. + csv := resp asCSV. + self assert: resp rows size equals: 4. + self assert: csv lines size equals: 5. + self assert: csv lines first equals: '"id","dateValue","timeValue","datetimeValue","timestampValue","yearValue"'. + self assert: csv lines second equals: '"1","1 July 2011","6:35:23 pm","2011-07-02T10:12:45+00:00","1980-01-12T00:45:56+00:00","1999"'. + self assert: (resp rows first atIndex: 2) equals: (Date fromString: '07-01-2011'). + self assert: (resp rows first atIndex: 3) equals: (Time fromString: '18:35:23'). + self assert: (resp rows first atIndex: 4) equals: + (DateAndTime + localTimeZone: TimeZone default; + fromString: '2011-07-02T10:12:45.000000000'). + self assert: (resp rows first atIndex: 5) equals: + (DateAndTime + localTimeZone: TimeZone default; + fromString: '01-12-1980 00:45:56-00:00'). + self assert: (resp rows first atIndex: 6) equals: 1999. + + self assert: (resp rows second atIndex: 2) equals: (Date fromString: '06-01-2011'). + self assert: (resp rows second atIndex: 3) equals: (Duration fromString: '03:17:34:22'). + self assert: (resp rows second atIndex: 4) equals: + (DateAndTime + localTimeZone: TimeZone default; + fromString: '2011-06-02T09:11:44.000000'). + self assert: (resp rows second atIndex: 5) equals: + (DateAndTime + localTimeZone: TimeZone default; + fromString: '02-13-1980 01:44:55')] + +] + +{ #category : #tests } +MySQLStatementReadCSVTest >> testReadTimeTypesNeg [ + | prep stmtId params resp stmt csv | + self withFixtures: #(#times) do: [:conn | + prep := conn prepare: 'select * from testTimes order by id'. + stmtId := prep prepareOkay stmtHandlerId.. + params := #(). + + stmt := MySQLDriverStatement onConnection: conn. + stmt stmtId: stmtId; params: params. + + resp := stmt execute. + self assert: resp isResultSet. + csv := resp asCSV. + self assert: resp rows size equals: 4. + self assert: csv lines size equals: 5. + self assert: csv lines first equals: '"id","dateValue","timeValue","datetimeValue","timestampValue","yearValue"'. + self assert: csv lines fifth equals: '"4","","-0:16:33:21","","1980-03-14T02:43:54+00:00","2002"'. + self assert: (resp rows fourth atIndex: 3) equals: (Duration fromString: '-00:16:33:21')] + +] + +{ #category : #tests } +MySQLStatementReadCSVTest >> testReadTimeTypesNull [ + | prep stmtId params resp stmt csv | + self + withFixtures: #(#times ) + do: + [ :conn | + prep := conn prepare: 'select * from testTimes order by id'. + stmtId := prep prepareOkay stmtHandlerId. + params := #(). + stmt := MySQLDriverStatement onConnection: conn. + stmt + stmtId: stmtId; + params: params. + resp := stmt execute. + self assert: resp isResultSet. + csv := resp asCSV. + self assert: resp rows size equals: 4. + self assert: csv lines size equals: 5. + self assert: csv lines first equals: '"id","dateValue","timeValue","datetimeValue","timestampValue","yearValue"'. + self assert: csv lines fourth equals: '"3","","","","",""'. + self assert: (resp rows third atIndex: 2) isNil. + self assert: (resp rows third atIndex: 3) isNil. + self assert: (resp rows third atIndex: 4) isNil. + self assert: (resp rows third atIndex: 5) isNil. + self assert: (resp rows fourth atIndex: 5) isNotNil ] +] diff --git a/MySQL-CSV-Tests/package.st b/MySQL-CSV-Tests/package.st new file mode 100644 index 0000000..fe09840 --- /dev/null +++ b/MySQL-CSV-Tests/package.st @@ -0,0 +1 @@ +Package { #name : #'MySQL-CSV-Tests' } diff --git a/MySQL-Core-Tests-Integration/MySQLStatementReadTest.class.st b/MySQL-Core-Tests-Integration/MySQLStatementReadTest.class.st index ca54e10..c062a32 100644 --- a/MySQL-Core-Tests-Integration/MySQLStatementReadTest.class.st +++ b/MySQL-Core-Tests-Integration/MySQLStatementReadTest.class.st @@ -293,5 +293,6 @@ MySQLStatementReadTest >> testReadTimeTypesNull [ self assert: (resp rows third atIndex: 2) isNil. self assert: (resp rows third atIndex: 3) isNil. self assert: (resp rows third atIndex: 4) isNil. - self assert: (resp rows third atIndex: 5) isNotNil ] + self assert: (resp rows third atIndex: 5) isNil. + self assert: (resp rows fourth atIndex: 5) isNotNil ] ] diff --git a/MySQL-Core/MySQLBinaryRowData.class.st b/MySQL-Core/MySQLBinaryRowData.class.st index f076bb1..a407d2f 100644 --- a/MySQL-Core/MySQLBinaryRowData.class.st +++ b/MySQL-Core/MySQLBinaryRowData.class.st @@ -25,6 +25,11 @@ MySQLBinaryRowData >> columnDescriptors: fieldList [ ] +{ #category : #enumerating } +MySQLBinaryRowData >> do: aBlock [ + ^columnValues do: aBlock +] + { #category : #testing } MySQLBinaryRowData >> isColumnNullAt: index [ | byteIndex bitsToShift bitMask | From c34107571821764eb746ad051f18d178c196130b Mon Sep 17 00:00:00 2001 From: Todd Blanchard Date: Wed, 14 Jul 2021 11:45:58 -0700 Subject: [PATCH 09/16] Another try... --- BaselineOfMySQL/BaselineOfMySQL.class.st | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/BaselineOfMySQL/BaselineOfMySQL.class.st b/BaselineOfMySQL/BaselineOfMySQL.class.st index 97b8e86..28ae66d 100644 --- a/BaselineOfMySQL/BaselineOfMySQL.class.st +++ b/BaselineOfMySQL/BaselineOfMySQL.class.st @@ -18,9 +18,11 @@ BaselineOfMySQL >> baseline: spec [ setUpPackages: spec. spec group: 'CI' with: #('Tests' 'Glorp-Tests'); - group: 'Development' with: #('Tests' 'glorp'); + group: 'CI-CSV' with: #('CI' 'CSV' 'CSV-Tests'); + group: 'Development' with: #('Tests' 'Glorp'); + group: 'Development-CSV' with: #('Development' 'CSV' 'CSV=Tests'); group: 'default' with: #('all'); - group: 'all' with: #('core' 'Tests') + group: 'all' with: #('Core' 'Tests' 'CSV' 'CSV-Tests') ] ] @@ -64,19 +66,25 @@ BaselineOfMySQL >> setUpPackages: spec [ package: 'MySQL-Core' with: [ spec requires: #('NeoJSON-Core' 'ZTimestamp') ]; group: 'Core' with: 'MySQL-Core'. - spec group: 'core' with: [ spec requires: #('Core') ]. + spec + package: 'MySQL-Core' with: [ spec requires: #('NeoJSON-Core' 'ZTimestamp') ]; + group: 'core' with: 'MySQL-Core'. spec package: 'MySQL-CSV' with: [ spec requires: #('MySQL-Core' 'Neo-CSV-Core') ]; group: 'CSV' with: 'MySQL-CSV'. - spec group: 'csv' with: [ spec requires: #( 'CSV' ) ]. + spec + package: 'MySQL-CSV' with: [ spec requires: #('MySQL-Core' 'Neo-CSV-Core') ]; + group: 'csv' with: 'MySQL-CSV'. spec package: 'MySQL-Glorp' with: [ spec requires: #('MySQL-Core' 'Glorp-Deployment') ]; group: 'MySQL-Glorp' with: 'MySQL-Glorp'. - spec group: 'glorp' with: [ spec requires: #( 'MySQL-Glorp' ) ]. + spec + package: 'MySQL-Glorp' with: [ spec requires: #('MySQL-Core' 'Glorp-Deployment') ]; + group: 'glorp' with: 'MySQL-Glorp'. spec package: 'MySQL-Core-Tests' with: [ spec requires: 'MySQL-Core' ]; From 63e927861ad7ec3336a1b5934df99a996cf1fd2e Mon Sep 17 00:00:00 2001 From: Todd Blanchard Date: Wed, 14 Jul 2021 11:59:52 -0700 Subject: [PATCH 10/16] Still fiddling with packages... --- BaselineOfMySQL/BaselineOfMySQL.class.st | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/BaselineOfMySQL/BaselineOfMySQL.class.st b/BaselineOfMySQL/BaselineOfMySQL.class.st index 28ae66d..4109c47 100644 --- a/BaselineOfMySQL/BaselineOfMySQL.class.st +++ b/BaselineOfMySQL/BaselineOfMySQL.class.st @@ -64,26 +64,17 @@ BaselineOfMySQL >> setUpPackages: spec [ spec package: 'MySQL-Core' with: [ spec requires: #('NeoJSON-Core' 'ZTimestamp') ]; - group: 'Core' with: 'MySQL-Core'. - - spec - package: 'MySQL-Core' with: [ spec requires: #('NeoJSON-Core' 'ZTimestamp') ]; + group: 'Core' with: 'MySQL-Core'; group: 'core' with: 'MySQL-Core'. spec package: 'MySQL-CSV' with: [ spec requires: #('MySQL-Core' 'Neo-CSV-Core') ]; - group: 'CSV' with: 'MySQL-CSV'. - - spec - package: 'MySQL-CSV' with: [ spec requires: #('MySQL-Core' 'Neo-CSV-Core') ]; + group: 'CSV' with: 'MySQL-CSV'; group: 'csv' with: 'MySQL-CSV'. spec package: 'MySQL-Glorp' with: [ spec requires: #('MySQL-Core' 'Glorp-Deployment') ]; - group: 'MySQL-Glorp' with: 'MySQL-Glorp'. - - spec - package: 'MySQL-Glorp' with: [ spec requires: #('MySQL-Core' 'Glorp-Deployment') ]; + group: 'Glorp' with: 'MySQL-Glorp'; group: 'glorp' with: 'MySQL-Glorp'. spec From e884e3014831376b99eeae85650d04cf3d2aa389 Mon Sep 17 00:00:00 2001 From: Todd Blanchard Date: Wed, 14 Jul 2021 14:13:50 -0700 Subject: [PATCH 11/16] Back to a working state I hope --- BaselineOfMySQL/BaselineOfMySQL.class.st | 28 +++++------------------- 1 file changed, 5 insertions(+), 23 deletions(-) diff --git a/BaselineOfMySQL/BaselineOfMySQL.class.st b/BaselineOfMySQL/BaselineOfMySQL.class.st index 4109c47..f3db983 100644 --- a/BaselineOfMySQL/BaselineOfMySQL.class.st +++ b/BaselineOfMySQL/BaselineOfMySQL.class.st @@ -18,11 +18,9 @@ BaselineOfMySQL >> baseline: spec [ setUpPackages: spec. spec group: 'CI' with: #('Tests' 'Glorp-Tests'); - group: 'CI-CSV' with: #('CI' 'CSV' 'CSV-Tests'); - group: 'Development' with: #('Tests' 'Glorp'); - group: 'Development-CSV' with: #('Development' 'CSV' 'CSV=Tests'); + group: 'Development' with: #('Tests' 'glorp'); group: 'default' with: #('all'); - group: 'all' with: #('Core' 'Tests' 'CSV' 'CSV-Tests') + group: 'all' with: #('Core' 'Tests') ] ] @@ -38,11 +36,7 @@ BaselineOfMySQL >> setUpDependencies: spec [ spec baseline: 'NeoJSON' with: [ spec repository: 'github://svenvc/NeoJSON:master/repository' ]; project: 'NeoJSON-Core' copyFrom: 'NeoJSON' with: [ spec loads: 'core' ]. - - spec - baseline: 'NeoCSV' with: [ spec repository: 'github://svenvc/NeoCSV:master/repository' ]; - project: 'Neo-CSV-Core' copyFrom: 'NeoCSV' with: [ spec loads: 'core' ]. - + spec baseline: 'ZTimestamp' with: [ spec repository: 'github://svenvc/ztimestamp:master/repository' ]. @@ -57,25 +51,13 @@ BaselineOfMySQL >> setUpDependencies: spec [ { #category : #baselines } BaselineOfMySQL >> setUpPackages: spec [ - "Usually group names are capitalized, however this baselie has used group names of all lower case. - For consistency we have capitalized the group names and kept the lower case names as aliases for compatibility. - New projects should use the capitalized names and existing projects should convert to capitalized names as soon - as convenient as the lower case names will eventually be removd." - spec package: 'MySQL-Core' with: [ spec requires: #('NeoJSON-Core' 'ZTimestamp') ]; - group: 'Core' with: 'MySQL-Core'; - group: 'core' with: 'MySQL-Core'. - - spec - package: 'MySQL-CSV' with: [ spec requires: #('MySQL-Core' 'Neo-CSV-Core') ]; - group: 'CSV' with: 'MySQL-CSV'; - group: 'csv' with: 'MySQL-CSV'. + group: 'Core' with: 'MySQL-Core'. spec package: 'MySQL-Glorp' with: [ spec requires: #('MySQL-Core' 'Glorp-Deployment') ]; - group: 'Glorp' with: 'MySQL-Glorp'; - group: 'glorp' with: 'MySQL-Glorp'. + group: 'Glorp' with: 'MySQL-Glorp'. spec package: 'MySQL-Core-Tests' with: [ spec requires: 'MySQL-Core' ]; From 65fae54ab6844b406470907be6331f60590e398b Mon Sep 17 00:00:00 2001 From: Todd Blanchard Date: Wed, 14 Jul 2021 14:16:49 -0700 Subject: [PATCH 12/16] Change glorp group to MySQL-Glorp --- BaselineOfMySQL/BaselineOfMySQL.class.st | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BaselineOfMySQL/BaselineOfMySQL.class.st b/BaselineOfMySQL/BaselineOfMySQL.class.st index f3db983..ab401de 100644 --- a/BaselineOfMySQL/BaselineOfMySQL.class.st +++ b/BaselineOfMySQL/BaselineOfMySQL.class.st @@ -57,7 +57,7 @@ BaselineOfMySQL >> setUpPackages: spec [ spec package: 'MySQL-Glorp' with: [ spec requires: #('MySQL-Core' 'Glorp-Deployment') ]; - group: 'Glorp' with: 'MySQL-Glorp'. + group: 'MySQL-Glorp' with: 'MySQL-Glorp'. spec package: 'MySQL-Core-Tests' with: [ spec requires: 'MySQL-Core' ]; From 23ac2d46d8ac012e3b25c4804430725914be6e7f Mon Sep 17 00:00:00 2001 From: Todd Blanchard Date: Wed, 14 Jul 2021 14:18:43 -0700 Subject: [PATCH 13/16] Glorp -> MySQL-Glorp --- BaselineOfMySQL/BaselineOfMySQL.class.st | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BaselineOfMySQL/BaselineOfMySQL.class.st b/BaselineOfMySQL/BaselineOfMySQL.class.st index ab401de..476be98 100644 --- a/BaselineOfMySQL/BaselineOfMySQL.class.st +++ b/BaselineOfMySQL/BaselineOfMySQL.class.st @@ -18,7 +18,7 @@ BaselineOfMySQL >> baseline: spec [ setUpPackages: spec. spec group: 'CI' with: #('Tests' 'Glorp-Tests'); - group: 'Development' with: #('Tests' 'glorp'); + group: 'Development' with: #('Tests' 'MySQL-Glorp'); group: 'default' with: #('all'); group: 'all' with: #('Core' 'Tests') ] From c3739d06016d140b7f2ab5073f7134b850486dd5 Mon Sep 17 00:00:00 2001 From: Todd Blanchard Date: Wed, 14 Jul 2021 14:23:49 -0700 Subject: [PATCH 14/16] Back to glorp --- BaselineOfMySQL/BaselineOfMySQL.class.st | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/BaselineOfMySQL/BaselineOfMySQL.class.st b/BaselineOfMySQL/BaselineOfMySQL.class.st index 476be98..03488a7 100644 --- a/BaselineOfMySQL/BaselineOfMySQL.class.st +++ b/BaselineOfMySQL/BaselineOfMySQL.class.st @@ -18,7 +18,7 @@ BaselineOfMySQL >> baseline: spec [ setUpPackages: spec. spec group: 'CI' with: #('Tests' 'Glorp-Tests'); - group: 'Development' with: #('Tests' 'MySQL-Glorp'); + group: 'Development' with: #('Tests' 'glorp'); group: 'default' with: #('all'); group: 'all' with: #('Core' 'Tests') ] @@ -57,7 +57,7 @@ BaselineOfMySQL >> setUpPackages: spec [ spec package: 'MySQL-Glorp' with: [ spec requires: #('MySQL-Core' 'Glorp-Deployment') ]; - group: 'MySQL-Glorp' with: 'MySQL-Glorp'. + group: 'glorp' with: 'MySQL-Glorp'. spec package: 'MySQL-Core-Tests' with: [ spec requires: 'MySQL-Core' ]; From 0b3f747a9679003dc87a745b0de2f2b3b4ee6072 Mon Sep 17 00:00:00 2001 From: Todd Blanchard Date: Wed, 14 Jul 2021 14:31:00 -0700 Subject: [PATCH 15/16] Fix test --- MySQL-Core-Tests-Integration/MySQLStatementReadTest.class.st | 1 - 1 file changed, 1 deletion(-) diff --git a/MySQL-Core-Tests-Integration/MySQLStatementReadTest.class.st b/MySQL-Core-Tests-Integration/MySQLStatementReadTest.class.st index c062a32..99f83cd 100644 --- a/MySQL-Core-Tests-Integration/MySQLStatementReadTest.class.st +++ b/MySQL-Core-Tests-Integration/MySQLStatementReadTest.class.st @@ -293,6 +293,5 @@ MySQLStatementReadTest >> testReadTimeTypesNull [ self assert: (resp rows third atIndex: 2) isNil. self assert: (resp rows third atIndex: 3) isNil. self assert: (resp rows third atIndex: 4) isNil. - self assert: (resp rows third atIndex: 5) isNil. self assert: (resp rows fourth atIndex: 5) isNotNil ] ] From 814918a41ca98fbf404f075ebe66b4f5374924f4 Mon Sep 17 00:00:00 2001 From: Todd Blanchard Date: Wed, 14 Jul 2021 14:32:40 -0700 Subject: [PATCH 16/16] Remove CSV from repository - not worth this level of complexity --- .../MySQLStatementReadCSVTest.class.st | 332 ------------------ MySQL-CSV-Tests/package.st | 1 - MySQL-CSV/MySQLResultSet.extension.st | 9 - MySQL-CSV/package.st | 1 - 4 files changed, 343 deletions(-) delete mode 100644 MySQL-CSV-Tests/MySQLStatementReadCSVTest.class.st delete mode 100644 MySQL-CSV-Tests/package.st delete mode 100644 MySQL-CSV/MySQLResultSet.extension.st delete mode 100644 MySQL-CSV/package.st diff --git a/MySQL-CSV-Tests/MySQLStatementReadCSVTest.class.st b/MySQL-CSV-Tests/MySQLStatementReadCSVTest.class.st deleted file mode 100644 index e2fef4a..0000000 --- a/MySQL-CSV-Tests/MySQLStatementReadCSVTest.class.st +++ /dev/null @@ -1,332 +0,0 @@ -Class { - #name : #MySQLStatementReadCSVTest, - #superclass : #MySQLTestCase, - #category : #'MySQL-CSV-Tests' -} - -{ #category : #accessing } -MySQLStatementReadCSVTest >> scenarios [ -^ ' -- should read results of integer types - - tinyint, smallint, mediumint, (long)int, bigint -- should read results of real types - - float, double, real (approx values) -- should read results of real types - - decimal, numeric (exact values) -- should read results of date types - - date, time, datetime, timestamp, year -- should read results of char types - - char, varchar -- should read results of binary types - - binary, varbinary -- should read results of blob types - - tinyblob, blob, mediumblob longblob -- should read results of text types - - tinytext, text, mediumtext, longtext -' - -] - -{ #category : #tests } -MySQLStatementReadCSVTest >> testReadBlobTypes [ - | prep stmtId params resp stmt csv | - self - withFixtures: #(#blobs ) - do: - [ :conn | - prep := conn prepare: 'select * from testBlobs where id < ? order by id'. - stmtId := prep prepareOkay stmtHandlerId. - params := Array with: (MySQLBindParameter withValue: 5). - stmt := MySQLDriverStatement onConnection: conn. - stmt - stmtId: stmtId; - params: params. - resp := stmt execute. - self assert: resp isResultSet. - csv := resp asCSV. - - self assert: resp rows size equals: 2. - self assert: csv lines first equals: '"id","tinyblobValue","blobValue","mediumblobValue","longblobValue"'. - self assert: csv lines second equals: '"1","0123456789","0123456789","0123456789","0123456789"'. - self assert: csv lines third equals: '"2","1234567890","","","1234567890"'. - - self assert: (resp rows first atIndex: 2) equals: '0123456789' asByteArray. - self assert: (resp rows first atIndex: 3) equals: '0123456789' asByteArray. - self assert: (resp rows first atIndex: 4) equals: '0123456789' asByteArray. - self assert: (resp rows first atIndex: 5) equals: '0123456789' asByteArray. - self assert: (resp rows second atIndex: 2) equals: '1234567890' asByteArray. - self assert: (resp rows second atIndex: 3) isNil. - self assert: (resp rows second atIndex: 4) isNil. - self assert: (resp rows second atIndex: 5) equals: '1234567890' asByteArray ] -] - -{ #category : #tests } -MySQLStatementReadCSVTest >> testReadCharTypes [ - | prep stmtId params resp stmt csv | - self withFixtures: #(#chars) do: [:conn | - prep := conn prepare: 'select * from testChars where id < ? order by id'. - stmtId := prep prepareOkay stmtHandlerId.. - params := Array with: (MySQLBindParameter withValue: 5). - - stmt := MySQLDriverStatement onConnection: conn. - stmt stmtId: stmtId; params: params. - - resp := stmt execute. - self assert: resp isResultSet. - csv := resp asCSV. - self assert: csv lines size equals: 3. - self assert: csv lines first equals: '"id","charValue","varcharValue"'. - self assert: csv lines second equals: '"1","smalltalk","An awesome programming environment"'. - self assert: csv lines third equals: '"2","lisp","So is this one"' ] - -] - -{ #category : #tests } -MySQLStatementReadCSVTest >> testReadIntegerTypes [ - | prep stmtId params resp stmt csv | - self withFixtures: #(#integers) do: [:conn | - prep := conn prepare: 'select * from testIntegers order by id'. - stmtId := prep prepareOkay stmtHandlerId. - params := #(). - - stmt := MySQLDriverStatement onConnection: conn. - stmt stmtId: stmtId; params: params. - - resp := stmt execute. - self assert: resp isResultSet. - csv := resp asCSV. - self assert: resp rows size equals: 5. - self assert: csv lines size equals: 6. - self assert: csv lines first equals: '"id","tinyintValue","smallintValue","mediumintValue","intValue","bigintValue"'. - self assert: csv lines second equals: '"1","0","300","40000","100000","6000000000"'. - self assert: csv lines last equals: '"5","-101","-301","-40001","-100001","-6000000001"'. - ] -] - -{ #category : #tests } -MySQLStatementReadCSVTest >> testReadIntegerTypesNeg [ - | prep stmtId params resp stmt csv | - self withFixtures: #(#integers) do: [:conn | - prep := conn prepare: 'select * from testIntegers where tinyintValue < ? order by id'. - stmtId := prep prepareOkay stmtHandlerId. - - params := MySQLBindParameter - listOfSize: prep prepareOkay numParams - forDescriptors: prep paramDescriptors. - params first bindValue: -100. - - - stmt := MySQLDriverStatement onConnection: conn. - stmt stmtId: stmtId; params: params. - - resp := stmt execute. - self assert: resp isResultSet. - csv := resp asCSV. - - self assert: resp rows size equals: 1. - self assert: csv lines size equals: 2. - self assert: csv lines first equals: '"id","tinyintValue","smallintValue","mediumintValue","intValue","bigintValue"'. - self assert: csv lines last equals: '"5","-101","-301","-40001","-100001","-6000000001"' - ] -] - -{ #category : #tests } -MySQLStatementReadCSVTest >> testReadIntegerTypesNull [ - | prep stmtId params resp stmt csv | - self - withFixtures: #(#integers ) - do: - [ :conn | - prep := conn prepare: 'select * from testIntegers order by id'. - stmtId := prep prepareOkay stmtHandlerId. - params := #(). - stmt := MySQLDriverStatement onConnection: conn. - stmt - stmtId: stmtId; - params: params. - resp := stmt execute. - self assert: resp isResultSet. - csv := resp asCSV. - - self assert: resp rows size = 5. - self assert: csv lines size equals: 6. - self assert: csv lines first equals: '"id","tinyintValue","smallintValue","mediumintValue","intValue","bigintValue"'. - self assert: csv lines fourth equals: '"3","2","","","","6000000002"'. - self assert: (resp rows third atIndex: 4) isNil. - self assert: (resp rows third atIndex: 6) equals: 6000000002. - self assert: (resp rows fourth atIndex: 4) equals: 40003. - self assert: (resp rows fourth atIndex: 6) isNil ] -] - -{ #category : #tests } -MySQLStatementReadCSVTest >> testReadRealTypes [ - | prep stmtId params resp stmt csv | - self withFixtures: #(#reals) do: [:conn | - prep := conn prepare: 'select * from testReals order by id'. - stmtId := prep prepareOkay stmtHandlerId. - params := #(). - - stmt := MySQLDriverStatement onConnection: conn. - stmt stmtId: stmtId; params: params. - - resp := stmt execute. - self assert: resp isResultSet. - csv := resp asCSV. - self assert: resp rows size equals: 3. - self assert: csv lines size equals: 4. - self assert: csv lines first equals: '"id","floatValue","doubleValue","realValue","decimalValue","numericValue"'. - self assert: csv lines second equals: '"1","1.100000023841858","11.11","222.222","3333.333333s6","4444.444444s6"'. - self assert: ((resp rows first atIndex: 2) closeTo: 1.1). - self assert: ((resp rows first atIndex: 3) closeTo: 11.11). - self assert: ((resp rows first atIndex: 4) closeTo: 222.222). - self assert: (resp rows first atIndex: 5) = ((3333333333 / 1000000) asScaledDecimal: 6). - self assert: (resp rows first atIndex: 6) = (((4444444444 / 1000000) asScaledDecimal: 6)). - ] -] - -{ #category : #tests } -MySQLStatementReadCSVTest >> testReadRealTypesNeg [ - | prep stmtId params resp stmt csv | - self withFixtures: #(#reals) do: [:conn | - prep := conn prepare: 'select * from testReals order by id'. - stmtId := prep prepareOkay stmtHandlerId.. - params := #(). - - stmt := MySQLDriverStatement onConnection: conn. - stmt stmtId: stmtId; params: params. - - resp := stmt execute. - self assert: resp isResultSet. - csv := resp asCSV. - self assert: resp rows size equals: 3. - self assert: csv lines size equals: 4. - self assert: csv lines first equals: '"id","floatValue","doubleValue","realValue","decimalValue","numericValue"'. - self assert: csv lines fourth equals: '"3","-1.100000023841858","-11.11","-222.222","-3333.333333s6","-4444.444444s6"'. - self assert: ((resp rows third atIndex: 2) closeTo: -1.1). - self assert: ((resp rows third atIndex: 3) closeTo: -11.11). - self assert: ((resp rows third atIndex: 4) closeTo: -222.222). - self assert: (resp rows third atIndex: 5) = ((-3333333333 / 1000000) asScaledDecimal: 6). - self assert: (resp rows third atIndex: 6) = ((-4444444444 / 1000000) asScaledDecimal: 6). - ] -] - -{ #category : #tests } -MySQLStatementReadCSVTest >> testReadRealTypesNull [ - | prep stmtId params resp stmt csv | - self - withFixtures: #(#reals ) - do: - [ :conn | - prep := conn prepare: 'select * from testReals order by id'. - stmtId := prep prepareOkay stmtHandlerId. - params := #(). - stmt := MySQLDriverStatement onConnection: conn. - stmt - stmtId: stmtId; - params: params. - resp := stmt execute. - self assert: resp isResultSet. - csv := resp asCSV. - self assert: resp rows size equals: 3. - self assert: csv lines size equals: 4. - self assert: csv lines first equals: '"id","floatValue","doubleValue","realValue","decimalValue","numericValue"'. - self assert: csv lines third equals: '"2","","","","","-5555.555555s6"'. - self assert: (resp rows second atIndex: 2) isNil. - self assert: (resp rows second atIndex: 3) isNil. - self assert: (resp rows second atIndex: 4) isNil. - self assert: (resp rows second atIndex: 5) isNil. - self assert: (resp rows second atIndex: 6) = (-5555555555 / 1000000 asScaledDecimal: 6) ] -] - -{ #category : #tests } -MySQLStatementReadCSVTest >> testReadTimeTypes [ - | prep stmtId params resp stmt csv | - self withFixtures: #(#times) do: [:conn | - prep := conn prepare: 'select * from testTimes order by id'. - stmtId := prep prepareOkay stmtHandlerId.. - params := #(). - - stmt := MySQLDriverStatement onConnection: conn. - stmt stmtId: stmtId; params: params. - - resp := stmt execute. - self assert: resp isResultSet. - csv := resp asCSV. - self assert: resp rows size equals: 4. - self assert: csv lines size equals: 5. - self assert: csv lines first equals: '"id","dateValue","timeValue","datetimeValue","timestampValue","yearValue"'. - self assert: csv lines second equals: '"1","1 July 2011","6:35:23 pm","2011-07-02T10:12:45+00:00","1980-01-12T00:45:56+00:00","1999"'. - self assert: (resp rows first atIndex: 2) equals: (Date fromString: '07-01-2011'). - self assert: (resp rows first atIndex: 3) equals: (Time fromString: '18:35:23'). - self assert: (resp rows first atIndex: 4) equals: - (DateAndTime - localTimeZone: TimeZone default; - fromString: '2011-07-02T10:12:45.000000000'). - self assert: (resp rows first atIndex: 5) equals: - (DateAndTime - localTimeZone: TimeZone default; - fromString: '01-12-1980 00:45:56-00:00'). - self assert: (resp rows first atIndex: 6) equals: 1999. - - self assert: (resp rows second atIndex: 2) equals: (Date fromString: '06-01-2011'). - self assert: (resp rows second atIndex: 3) equals: (Duration fromString: '03:17:34:22'). - self assert: (resp rows second atIndex: 4) equals: - (DateAndTime - localTimeZone: TimeZone default; - fromString: '2011-06-02T09:11:44.000000'). - self assert: (resp rows second atIndex: 5) equals: - (DateAndTime - localTimeZone: TimeZone default; - fromString: '02-13-1980 01:44:55')] - -] - -{ #category : #tests } -MySQLStatementReadCSVTest >> testReadTimeTypesNeg [ - | prep stmtId params resp stmt csv | - self withFixtures: #(#times) do: [:conn | - prep := conn prepare: 'select * from testTimes order by id'. - stmtId := prep prepareOkay stmtHandlerId.. - params := #(). - - stmt := MySQLDriverStatement onConnection: conn. - stmt stmtId: stmtId; params: params. - - resp := stmt execute. - self assert: resp isResultSet. - csv := resp asCSV. - self assert: resp rows size equals: 4. - self assert: csv lines size equals: 5. - self assert: csv lines first equals: '"id","dateValue","timeValue","datetimeValue","timestampValue","yearValue"'. - self assert: csv lines fifth equals: '"4","","-0:16:33:21","","1980-03-14T02:43:54+00:00","2002"'. - self assert: (resp rows fourth atIndex: 3) equals: (Duration fromString: '-00:16:33:21')] - -] - -{ #category : #tests } -MySQLStatementReadCSVTest >> testReadTimeTypesNull [ - | prep stmtId params resp stmt csv | - self - withFixtures: #(#times ) - do: - [ :conn | - prep := conn prepare: 'select * from testTimes order by id'. - stmtId := prep prepareOkay stmtHandlerId. - params := #(). - stmt := MySQLDriverStatement onConnection: conn. - stmt - stmtId: stmtId; - params: params. - resp := stmt execute. - self assert: resp isResultSet. - csv := resp asCSV. - self assert: resp rows size equals: 4. - self assert: csv lines size equals: 5. - self assert: csv lines first equals: '"id","dateValue","timeValue","datetimeValue","timestampValue","yearValue"'. - self assert: csv lines fourth equals: '"3","","","","",""'. - self assert: (resp rows third atIndex: 2) isNil. - self assert: (resp rows third atIndex: 3) isNil. - self assert: (resp rows third atIndex: 4) isNil. - self assert: (resp rows third atIndex: 5) isNil. - self assert: (resp rows fourth atIndex: 5) isNotNil ] -] diff --git a/MySQL-CSV-Tests/package.st b/MySQL-CSV-Tests/package.st deleted file mode 100644 index fe09840..0000000 --- a/MySQL-CSV-Tests/package.st +++ /dev/null @@ -1 +0,0 @@ -Package { #name : #'MySQL-CSV-Tests' } diff --git a/MySQL-CSV/MySQLResultSet.extension.st b/MySQL-CSV/MySQLResultSet.extension.st deleted file mode 100644 index 596ed51..0000000 --- a/MySQL-CSV/MySQLResultSet.extension.st +++ /dev/null @@ -1,9 +0,0 @@ -Extension { #name : #MySQLResultSet } - -{ #category : #'*MySQL-CSV' } -MySQLResultSet >> asCSV [ - ^String streamContents: [ :writeStream | - (NeoCSVWriter on: writeStream) - writeHeader: (self fields collect: [:ea | ea name]); - nextPutAll: rows ] -] diff --git a/MySQL-CSV/package.st b/MySQL-CSV/package.st deleted file mode 100644 index 4da620b..0000000 --- a/MySQL-CSV/package.st +++ /dev/null @@ -1 +0,0 @@ -Package { #name : #'MySQL-CSV' }