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

Decimal handling for sqlite (on windows) breaks intermittently #355

Open
neilotoole opened this issue Jan 15, 2024 · 0 comments
Open

Decimal handling for sqlite (on windows) breaks intermittently #355

neilotoole opened this issue Jan 15, 2024 · 0 comments
Labels
bug windows Related to Windows OSes

Comments

@neilotoole
Copy link
Owner

neilotoole commented Jan 15, 2024

Describe the bug
It's well-known that SQLite is loosey-goosey with type handling. In particular, it doesn't really support decimal / numeric.

A recent PR introduced a dedicated decimal.Decimal type into the codebase. However, even using that type, SQLite exhibits intermittent undesired behavior on Windows: it sometimes returns a decimal value as a REAL/float, but not with the correct (round) value. E.g. see this pipeline.

    db_type_test.go:193: 
        	Error Trace:	D:/a/sq/sq/drivers/sqlite3/db_type_test.go:193
        	Error:      	Not equal: 
        	            	expected: decimal.Decimal{value:(*big.Int)(0xc000402de0), exp:-2}
        	            	actual  : decimal.Decimal{value:(*big.Int)(0xc000402400), exp:-14}
        	            	
        	            	Diff:
        	            	--- Expected
        	            	+++ Actual
        	            	@@ -4,6 +4,6 @@
        	            	   abs: (big.nat) (len=1) {
        	            	-   (big.Word) 7777
        	            	+   (big.Word) 7777000000000001
        	            	   }
        	            	  }),
        	            	- exp: (int32) -2
        	            	+ exp: (int32) -14
        	            	 }
        	Test:       	TestDatabaseTypes
        	Messages:   	type_test__b5wvrewy_0[1][17] (col_decimal) expected decimal.Decimal(77.77) but got decimal.Decimal(77.77000000000001)

To Reproduce

This happens intermittently on the GH windows runner. Usually re-running the job will result in the correct value. However, those intermittently failing tests are currently deliberately skipped. To reproduce, unskip the tests.

Expected behavior

The exact decimal/numeric value should be returned every time.

sq version

This happens on master pipeline, intermittently.

@neilotoole neilotoole added bug windows Related to Windows OSes labels Jan 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug windows Related to Windows OSes
Projects
None yet
Development

No branches or pull requests

1 participant