GithubHelp home page GithubHelp logo

Comments (17)

bgrainger avatar bgrainger commented on June 3, 2024

I would expect your code to work (based on some existing tests) but it's quite possible there's some edge case not being correctly handled yet. Thanks for supplying a concise repro; I'll try to use it to repro the bug you describe soon.

What version of MySQL Server are you running, and on what OS?

from mysqlconnector.

ScottAllSet avatar ScottAllSet commented on June 3, 2024

OS: Mac OSX 10.11.6
MySQL 5.7.13 (current GA) running locally
dotnet core 1.0.0-preview2-003121

I will try on MySQL 5.6 shortly.

from mysqlconnector.

ScottAllSet avatar ScottAllSet commented on June 3, 2024

I just validated that I'm getting the issue with 5.6.31 as well:
https://dev.mysql.com/downloads/file/?id=463211

from mysqlconnector.

ScottAllSet avatar ScottAllSet commented on June 3, 2024

I validated a couple other things just to weed out some possibilities:

  1. it happens when I only select the currency column and retrieve it via ordinal 0 (such as your test)
  2. it happens when I change the column order to force select * to return it as ordinal 0.

from mysqlconnector.

bgrainger avatar bgrainger commented on June 3, 2024

I installed MySQL Server 5.7.13 on Mac OS X 10.10.5 but couldn't reproduce with a similar (not exactly the same) test case: 909990c (also passed on Linux).

Are you inserting the row with this connector? Using a literal statement, or using a parameterised insert? Can you verify that the DB does actually contain 85.3 (e.g., with MySQL Workbench)?

It definitely seems consistent with your currency column, but I can't figure out yet what's different.

from mysqlconnector.

bgrainger avatar bgrainger commented on June 3, 2024

It's not consistent but it's always wrong and always a really big number.

Can you give some more examples of the other bad values you get? There may be some kind of pattern in them that gives a clue to the cause of the bug.

from mysqlconnector.

ScottAllSet avatar ScottAllSet commented on June 3, 2024

screen shot 2016-07-28 at 9 38 25 am

Here's a screenshot of the commands I ran in MySQL workbench and the output. I haven't tried inserting the row using the connector, only MySQL Workbench.

It appears that the values I get back are all the same for a given run but change each run without me changing or adding anything to the database.
First run:
screen shot 2016-07-28 at 9 53 16 am
Second run:
screen shot 2016-07-28 at 9 55 08 am
Here's Workbench with the three values:
screen shot 2016-07-28 at 9 56 53 am

from mysqlconnector.

bgrainger avatar bgrainger commented on June 3, 2024

If you change your table creation to currency decimal(13,3) DEFAULT NULL do you start getting larger "random" numbers, e.g., 4534471829.345?

from mysqlconnector.

ScottAllSet avatar ScottAllSet commented on June 3, 2024

I don't get larger whole numbers but the mantissa does increase to 3 digits:
screen shot 2016-07-28 at 1 35 48 pm

from mysqlconnector.

bgrainger avatar bgrainger commented on June 3, 2024

Is it possible you could share the whole ConsoleApplication.Test solution (e.g., attach a ZIP to this issue)?

from mysqlconnector.

ScottAllSet avatar ScottAllSet commented on June 3, 2024

Certainly!
Here's the code I'm using. I also included the SQL.
tester.zip

from mysqlconnector.

ScottAllSet avatar ScottAllSet commented on June 3, 2024

Is it possible the use of invariant culture when parsing the decimal is the problem? Mine is en-US, are you using the same? I'm just spit-balling here.

from mysqlconnector.

bgrainger avatar bgrainger commented on June 3, 2024

Thanks. I can reproduce your problem now, and I think it's a bug in the VS Code debugger.

If I add the following two lines before testItems.Add(t):

var currency = t.currency;
var currencyString = t.currency.ToString();

then I get the following output in the Variables window:

screenshot 2016-07-28 17 57 50

t.currency has the correct value if I store it in another variable, but the property value isn't displayed accurately in VS Code. (Additionally, System.Console.WriteLine(t.currency) also prints the expected value.) This may also explain why the value changes each time but is consistent for one run of the program (if it depends on something in the current debugging session).

from mysqlconnector.

bgrainger avatar bgrainger commented on June 3, 2024

I can reproduce the problem with one line of code: var t = new Test { id = 1, name = "Sarah", currency = 85.3m };. (All the MySQL-related code can be deleted.)

In the Variables pane in the debugger, t.currency shows the wrong value.

I searched vscode issues for decimal but didn't find anything. You may need to report this as a new issue to the VS Code team.

from mysqlconnector.

bgrainger avatar bgrainger commented on June 3, 2024

BTW, you can work around the bug by making currency a public field (i.e., public decimal currency;) instead of a property (public decimal currency {get;set;}). This indicates to me that it might be a problem with Code correctly reading the compiler-generated backing field for the property.

Indeed, if we write the property out in full:

public decimal currency
{
    get { return _currency; }
    set { _currency = value; }
}
private decimal _currency;

we get the following Variable output:

screenshot 2016-07-28 18 08 56

from mysqlconnector.

bgrainger avatar bgrainger commented on June 3, 2024

I've filed this as microsoft/vscode#9929.

from mysqlconnector.

ScottAllSet avatar ScottAllSet commented on June 3, 2024

Thank you very much!

from mysqlconnector.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.