Skip to content
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

Incorrect encoding of ScaledDecimal query parameters #5

Open
rko281 opened this issue Dec 18, 2019 · 0 comments
Open

Incorrect encoding of ScaledDecimal query parameters #5

rko281 opened this issue Dec 18, 2019 · 0 comments

Comments

@rko281
Copy link
Contributor

rko281 commented Dec 18, 2019

Encoding of ScaledDecimal in MySQLBindParameter>>decimalBytes drops first digit of parameter value. Test case (where c is a connected MySQLDriver):

c query: 'drop table if exists decimal_test'.
c query: 'create table decimal_test (d decimal(10,2))'.
r := c prepare: 'insert into decimal_test(d) values(?)'.
s := (MySQLDriverStatement onConnection: c) stmtId: r prepareOkay stmtHandlerId; cursoredFetch: false; yourself.
s addBinding: 123.45s2.
s execute.
(c query: 'select * from decimal_test') rows first at: 1  " '23.45' "

Issue can be resolved as follows:

decimalBytes
	"For scaled decimal"
	ByteArray streamContents: [:strm |
		MySQLHelper encodeLcs: (paramValue abs printString allButLast:2) asByteArray on: strm.
		^ strm contents]
estebanlm added a commit that referenced this issue Mar 26, 2020
Fixes and Tests for Issues #5, #6 and #7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant