DBIx::C...entifier(3)

πŸ’– DBIx::Class::Storage::DBI::UniqueIdentifier β€” the manual, but make it make sense πŸ’–

okay so bestie, this one is a page from the DBIx::Class docs (perl, obviously 😌), and it's literally all about giving your database GUIDs without breaking a sweat. Let's get into it ✨


πŸŽ€ NAME πŸŽ€

DBIx::Class::Storage::DBI::UniqueIdentifier β€” the storage component for RDBMSes that support GUID types 🫢


🌸 DESCRIPTION 🌸

So this is a storage component for databases that support GUID types β€” think stuff like uniqueidentifier, uniqueidentifierstr, or guid πŸ’…

And here's the slay part: GUIDs get generated automatically for PK columns that have a supported data_type, and also for non-PK columns with auto_nextval set πŸ”₯ No cap, it just does it for you.


⭐ METHODS ⭐

πŸ¦‹ new_guid

The composing class must set new_guid to whatever method it's using to generate a new GUID. It can also set it to undef β€” but then the user is required to set it themselves, or a runtime error gets thrown 😭 so like, don't leave it hanging, bestie.

It can be either of these two things:

  • string β€” in which case it's used as the name of a database function that creates a new GUID πŸ‘‘
  • coderef β€” in which case the coderef should return a string GUID, using Data::GUID, or literally whatever GUID generation method you prefer 😌 It gets passed the $self DBIx::Class::Storage reference as a parameter.

For example:

$schema->storage->new_guid(sub { Data::GUID->new->as_string });

it's giving "one line, does the thing" πŸ’œ obsessed.


🧚 FURTHER QUESTIONS? 🧚

Check the list of additional DBIC resources. (yes that's the whole section, go look it up iykyk 🌈)


This module is free software, copyright by the DBIx::Class (DBIC) authors πŸ’– You can redistribute it and/or modify it under the same terms as the DBIx::Class library.


and that's the whole page, bestie β€” no crumbs left behind πŸ“

this iconic lil number was served up by perl v5.42.0 on 2025-01-22, and it's brought to you by the DBIx::Class::Storage::DBI::UniqueIdentifier(3) manual page πŸ’…βœ¨

πŸ“¦ where this page comes from