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
GUID Type coversion error [DNET376] #381
Comments
Commented by: vinogradniy (vinogradniy) Test |
Modified by: vinogradniy (vinogradniy)Attachment: GuidTests.cs [ 11936 ] |
Commented by: @cincuranet The second assert is failing. But you're creating Guid from *string* returned by Firebird. This string has different ordering compared to what Guid ctor expects. But the first assert, that really matters as it works with real Guid values, is OK and provider handles it correctly. |
Commented by: vinogradniy (vinogradniy) Guids obtained through Firebird DSQL and Net Guid (string) have a different view. This is at least misleading and at worst leads to errors. String from UUID_TO_CHAR() : 5bfb70f4-bdfb-2e41-83f9-eb14aa132ad9 |
Commented by: @cincuranet Yes, that's expected. UUID_TO_CHAR returns different byte ordering than Guid.ToString. |
Commented by: vinogradniy (vinogradniy) See #DNET509. |
Submitted by: vinogradniy (vinogradniy)
Attachments:
GuidTests.cs
My first post - http://216.121.112.228/browse/NH-2618 .
Firebird 2.5 store Uuid into left to right convetion as "CHAR(16) CHARACTER SET OCTETS" (see http://www.firebirdfaq.org/faq98/ ). But http://ADO.NET Provider constructs System.Guid with System.Guid(byte[]) constructor, but System.GuidType shoul be constructed with Guid(int a, short b, short c, byte d, byte e, byte f, byte g, byte h, byte i, byte j, byte k) for correct representation. Also see Firebird 2.5 builtin fuctions UUID_TO_CHAR() and CHAR_TO_UUID().
System.Guid reflection:
{{{
// Creates a new guid from an array of bytes.
//
public Guid(byte[] b)
{
if (b==null)
throw new ArgumentNullException("b");
if (b.Length != 16)
throw new ArgumentException(String.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("Arg_GuidArrayCtor"), "16"));
}}}
NUnit test:
{{{
[Test]
public void GuidMappingTest()
{
FbCommand createTable = new FbCommand("CREATE TABLE GUID_TEST (INT_FIELD INTEGER, GUID_FIELD CHAR(16) CHARACTER SET OCTETS)", Connection);
createTable.ExecuteNonQuery();
createTable.Dispose();
}}}
Execution Result:
{{{
GuidMappingTest: Failed
Command:
CREATE TABLE GUID_TEST (INT_FIELD INTEGER, GUID_FIELD CHAR(16) CHARACTER SET OCTETS)
Command:
INSERT INTO GUID_TEST (INT_FIELD, GUID_FIELD) VALUES (@intfield, @GuidValue)
Name:@intfield Type:Integer Value:-169522060
Name:@GuidValue Type:Guid Value:f470fb5b-fbbd-412e-83f9-eb14aa132ad9
Command:
SELECT INT_FIELD, GUID_FIELD, UUID_TO_CHAR(GUID_FIELD) AS FBGUID FROM GUID_TEST
patternGuid = f470fb5b-fbbd-412e-83f9-eb14aa132ad9
providerGuid = f470fb5b-fbbd-412e-83f9-eb14aa132ad9
rfc4122Guid = 5bfb70f4-bdfb-2e41-83f9-eb14aa132ad9
Expected: f470fb5b-fbbd-412e-83f9-eb14aa132ad9
But was: 5bfb70f4-bdfb-2e41-83f9-eb14aa132ad9
}}}
Best regards,
Eugenyi Vinogradnyi (aka ssdi).
The text was updated successfully, but these errors were encountered: