#1071 confirmed
Peter Brant

[PATCH] Add Extlib::ByteArray as a core primitive type

Reported by Peter Brant | October 1st, 2009 @ 09:36 PM | in 1.1.1

I need to be able to read and write binary (bytea) fields using a Postgres database. Attached is a patch that adds Extlib::ByteArray as a primitive type. DataObjects takes care of everything else.

Comments and changes to this ticket

  • Dan Kubb (dkubb)

    Dan Kubb (dkubb) October 7th, 2009 @ 01:26 PM

    • Milestone set to 0.10.2
    • State changed from “new” to “accepted”
    • Assigned user set to “Dan Kubb (dkubb)”
  • Dan Kubb (dkubb)

    Dan Kubb (dkubb) February 1st, 2010 @ 04:33 PM

    • Milestone changed from 0.10.2 to 1.0.0
  • Dan Kubb (dkubb)
  • Dan Kubb (dkubb)
  • Dan Kubb (dkubb)

    Dan Kubb (dkubb) February 2nd, 2010 @ 02:47 AM

    • State changed from “accepted” to “confirmed”
  • Dan Kubb (dkubb)

    Dan Kubb (dkubb) February 4th, 2010 @ 05:19 AM

    • State changed from “confirmed” to “accepted”
    • Assigned user set to “Dan Kubb (dkubb)”
    • Milestone set to 1.0.0

    dbussink needs to update the Extlib::ByteArray type to just ByteArray. Once that is completed, I will create a Binary type in DM, with some specs to ensure binary data is saved/retrieved properly.

    Active adapter authors will also need to be made aware of the new Binary DM type.

  • Dan Kubb (dkubb)

    Dan Kubb (dkubb) February 5th, 2010 @ 01:09 AM

    • State changed from “accepted” to “hold”

    Marking this as on-hold until DO is updated.

  • Dan Kubb (dkubb)

    Dan Kubb (dkubb) February 15th, 2010 @ 10:58 PM

    • Assigned user cleared.

    Will create a Binary type once solnic's type/property refactoring is done and merged into the mainline.

  • Piotr Solnica (solnic)

    Piotr Solnica (solnic) February 19th, 2010 @ 07:43 AM

    Dan, how this Binary type should behave? The property is already there but it does nothing special now.

  • Dan Kubb (dkubb)

    Dan Kubb (dkubb) May 22nd, 2010 @ 01:15 AM

    • Assigned user set to “Piotr Solnica (solnic)”

    @Piotr: Would it work to make it so the DM::Property::Binary has an explicit primitive set for it, even though it's a subclass of DM::Property::String?

    I've added dbussink to this conversation because there is one thing we need to discuss. Currently DO uses Extlib::ByteArray as the type DO uses to know when to treat the string as binary. I think we should rename it to just ByteArray, or if namespace collisions are a concern, to String::ByteArray. We want to remove references from Extlib for when we eventually break away from it as a dependency.

  • Piotr Solnica (solnic)

    Piotr Solnica (solnic) May 26th, 2010 @ 04:37 AM

    We can set whatever primitive we want but...I'm not sure what we want.

  • Dan Kubb (dkubb)

    Dan Kubb (dkubb) May 26th, 2010 @ 12:43 PM

    I think we should make a primitive called String::ByteArray, have it inherit from String and then specify that as the primitive.

    DataObjects should be updated to treat String::ByteArray as a binary string and store it accordingly. Any adapters that don't need to treat raw binary strings specially can just fallback to treating them as a String.

    In our #typecast and #load methods we can take the object passed in, and if string.instance_of?(String) is true, we can do String::ByteArray.new(string) to convert it.

    I also think DataObjects should return the String::ByteArray instances for binary strings rather than just String objects.

    Does this sound ok to everyone?

  • Peter Brant

    Peter Brant May 26th, 2010 @ 02:06 PM

    Sounds perfect to me.

  • Piotr Solnica (solnic)

    Piotr Solnica (solnic) June 2nd, 2010 @ 06:28 AM

    • Milestone cleared.
    • State changed from “hold” to “confirmed”
  • Piotr Solnica (solnic)

    Piotr Solnica (solnic) June 2nd, 2010 @ 06:28 AM

    We're gonna make in the 1.0.x series which will also require a new DO release

  • Dirkjan Bussink

    Dirkjan Bussink June 2nd, 2010 @ 02:19 PM

    After some discussion with Dan, I want to propose the following:

    Isn't this something that should be handled in dm-do-adapter? I don't think we should try to make a global binary type out of this. That would make DataObjects::ByteArray a perfectly valid name, since the dm-do-adapter is aware of the DataObjects namespace.

    If other drivers like MongoDB also have a binary type, the DM::Property::Binary property should be mapped to that MongoDB specific type in the dm-mongo-adapter.

    I think this would make it a nice clean separation and put the concerns in the right places.

  • Dan Kubb (dkubb)

    Dan Kubb (dkubb) June 2nd, 2010 @ 02:31 PM

    This could work now that the adapters are required to handle types. We could have it so the DO adapter uses the DM::Property::Binary type, and sends the primitive over to DO as DataObjects::ByteArray. DataObjects::ByteArray would inherit from ::String.

    DO would then perform the query, and coerce the values into DataObjects::ByteArray instances and return them to the dm-do-adapter.

    The contract that the adapters have is that value.kind_of?(primitive) is true for every value in the Array of Hashes they return. Since DM::Property::Binary inherits from DM::Property::String, which has ::String as a primitive, we're all good.

  • Piotr Solnica (solnic)

    Piotr Solnica (solnic) November 1st, 2010 @ 01:17 PM

    • Milestone set to 1.1
    • Milestone order changed from “0” to “0”
  • Piotr Solnica (solnic)

    Piotr Solnica (solnic) January 16th, 2011 @ 05:15 AM

    • Milestone changed from 1.1 to 1.1.1
    • Milestone order changed from “6” to “0”
  • Dan Kubb (dkubb)
  • Xavier Shay

    Xavier Shay April 18th, 2011 @ 06:25 AM

    I watch with keen interest

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Attachments

Referenced by

Pages