Skip to content

Conversation

@michaelherold
Copy link
Owner

@michaelherold michaelherold commented May 29, 2018

Sequel is another popular database interface and is the underpinning of ROM. As such, supporting the use of KSUID within it is a good value-add for users of the gem.

To add a KSUID field to a Sequel model, you merely need to activate the plugin within the model:

class Event < Sequel::Model(:events)
  plugin :ksuid
end

You can activate four optional behaviors in the plugin:

  1. Name the field something other than the default :ksuid with field: <field_name>.
  2. Force the generation of a KSUID on a new record, even if you have set one prior to saving, with force: true.
  3. Save the KSUID as a byte array (type bytea in Postgres or blob in SQLite) with binary: true.
  4. You can wrap the resulting field in a KSUID::Type through both the setter and accessor through wrap: true.

To Do

  • Verify that the binary mode reads back correctly out of both Postgres and SQLite.

Questions

  • Should point 4, above, be a default? I don't often use Sequel so I don't have an informed opinion.

Relates to #6

@michaelherold michaelherold force-pushed the sequel branch 4 times, most recently from f1cf43f to aea0390 Compare May 29, 2018 02:38
@michaelherold
Copy link
Owner Author

With the work in #20, this will be extracted into a separate gem. I want the ksuid gem to be just that - the KSUID object.

@michaelherold michaelherold removed this from the v1.0.0 milestone Oct 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants