Skip to content

Support binding decimals with scale >= 10 to parameters #18

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions MySQL-Core-Tests/MySQLBindParameterDecimalTest.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
Class {
#name : #MySQLBindParameterDecimalTest,
#superclass : #TestCase,
#instVars : [
'theParam'
],
#category : #'MySQL-Core-Tests-Utilities'
}

{ #category : #running }
MySQLBindParameterDecimalTest >> setUp [
super setUp.
theParam := MySQLBindParameter new.

]

{ #category : #accessing }
MySQLBindParameterDecimalTest >> storeBinary [
ByteArray streamContents: [:strm |
theParam storeBinaryOn: strm.
^ strm contents]

]

{ #category : #tests }
MySQLBindParameterDecimalTest >> testParamDecimal [
theParam bindValue: 12.00s2.
self assert: theParam detectParamType equals: MySQLTypes typeDECIMAL
]

{ #category : #tests }
MySQLBindParameterDecimalTest >> testStoreBinaryLargeScale [
theParam bindValue: 1.0s10.
self
assert: self storeBinary
equals: #[12] , '1.0000000000' asByteArray.
theParam bindValue: 1.23456789012s.
self
assert: self storeBinary
equals: #[13] , '1.23456789012' asByteArray
]

{ #category : #tests }
MySQLBindParameterDecimalTest >> testStoreBinarySmallScale [
theParam bindValue: 12.345s.
self assert: self storeBinary equals: #[6] , '12.345' asByteArray.
theParam bindValue: 1.23s.
self assert: self storeBinary equals: #[4] , '1.23' asByteArray
]
9 changes: 6 additions & 3 deletions MySQL-Core/MySQLBindParameter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,12 @@ MySQLBindParameter >> dateTimeBytes [
{ #category : #writes }
MySQLBindParameter >> decimalBytes [
"For scaled decimal"
ByteArray streamContents: [:strm |
MySQLHelper encodeLcs: (paramValue printString allButLast:2) asByteArray on: strm.
^ strm contents]

^ ByteArray
streamContents: [ :strm |
MySQLHelper
encodeLcs: (paramValue printShowingDecimalPlaces: paramValue scale) asByteArray
on: strm ]
]

{ #category : #accessing }
Expand Down
10 changes: 5 additions & 5 deletions MySQL-Core/MySQLOkay.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ MySQLOkay >> hasMoreResults [

]

{ #category : #accessing }
MySQLOkay >> insertId [
^ insertId
]

{ #category : #accessing }
MySQLOkay >> inTransaction [
| autoCommit inTx |
Expand All @@ -35,11 +40,6 @@ MySQLOkay >> inTransaction [

]

{ #category : #accessing }
MySQLOkay >> insertId [
^ insertId
]

{ #category : #testing }
MySQLOkay >> isOkay [
^ true
Expand Down