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

When the identity is a BIGINT #266

Open
dyanarose opened this issue Sep 7, 2016 · 4 comments
Open

When the identity is a BIGINT #266

dyanarose opened this issue Sep 7, 2016 · 4 comments

Comments

@dyanarose
Copy link

Hi,

Looking at these two lines, it looks like the code assumes identities will be Int32s. So this would fail if instead, it's an Int64 for example.

https://github.com/FransBouma/Massive/blob/v2.0/src/Massive.Shared.cs#L1053
https://github.com/FransBouma/Massive/blob/v2.0/src/Massive.Shared.cs#L1066

@FransBouma
Copy link
Owner

You're right!

Problem is though: there's no info to determine what the type should be, everything is dynamic... so I picked 'int' as in general that's a safe bet in this case... Any suggestions?

@Siliconrob
Copy link

For the case of MS SQL I know you can ignore the overflow values by using

SET ARITHABORT OFF; - MSDN
SET ARITHIGNORE ON; - MSDN

In that case at least you can use Int64 and the downcast to Int32 identities should work. Helpful?

@FransBouma
Copy link
Owner

Hmm. It smells like on error resume next however ;) Perhaps some other route to specify the type might be better... But haven't given it much thought

@mikebeaton
Copy link
Contributor

Looking at the code at that date #L1053 #L1066 those two lines will not fail if the PK is a long which can fit into an int, only if the value is a long which can't fit.

Massive probably/possibly can't do better than this, as a cross-DB wrapper where most supported DBs work with ints.

But actually there was a line in that file #L785 which used an (int) cast instead of Convert.ToInt32(), to handle the result of COUNT, and that line failed with an exception (even for values which should fit into int) when ported to a DB which sent back a long count.

This is now fixed, or at least now follows the reasonable(?) pattern of the other two lines, as of 57073a9 for MySQL support. It will basically work for most users, if you really need long for PKs and COUNT values in your DB, you'd have to go in and edit these three lines.

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

4 participants