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

Different byte order (?) when importing SQL Server UUID #11

Open
matthenning opened this issue Mar 17, 2016 · 3 comments
Open

Different byte order (?) when importing SQL Server UUID #11

matthenning opened this issue Mar 17, 2016 · 3 comments

Comments

@matthenning
Copy link

I get strange results when using Uuid::import on a uuid returned from an SQL Server uniqueidentifier filled by the SQL default newsequentialid() like this:

>>> $uid = Webpatser\Uuid\Uuid::import(App\Deployment::first()->id)
=> Webpatser\Uuid\Uuid {#742}

>>> dd($uid)
Webpatser\Uuid\Uuid {#742
  #bytes: b"""
    k\x07[‚ìD\x11å€Ü\x00\x15]\n
    ¼T
    """
  #hex: null
  #string: "6b075b82-ec44-11e5-80dc-00155d0abc54"
  #urn: null
  #version: null
  #variant: null
  #node: null
  #time: null
}

>>> App\Deployment::find($uid->string)
=> null

The last bit should have returned the model, from which I previously got the uuid.
The actual uuid as I see it in SQL Server Management Studio looks like this though:

SQL: 825B076B-44EC-E511-80DC-00155D0ABC54
PHP: 6B075B82-EC44-11E5-80DC-00155D0ABC54

The first two blocks seem to be in reversed order.

When using the first uuid I can find the model as expected:

>>> App\Deployment::find('825B076B-44EC-E511-80DC-00155D0ABC54')
=> App\Deployment {#734}

Am I missing something here?

@webpatser
Copy link
Owner

hmmm.. I don't have an SQLServer instance available. So it's hard to figure out why this is happening.

Maybe someone can track what is happening?

@matthenning
Copy link
Author

I've since given up on the issue but I was able to figure out it has something to do with SQL Server storing the UUID in little or big endian.
I hope this helps someone.

@olavivaino
Copy link

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

3 participants