<!-- 
RSS generated by JIRA (5.2.7#850-sha1:b2af0c8dc8537b36121c6a579fabbdf79fc919e5) at Mon May 20 08:52:00 UTC 2013

It is possible to restrict the fields that are returned in this document by specifying the 'field' parameter in your request.
For example, to request only the issue key and summary add field=key&field=summary to the URL of your request.
For example:
http://www.doctrine-project.org/jira/si/jira.issueviews:issue-xml/DBAL-65/DBAL-65.xml?field=key&field=summary
-->
<rss version="0.92" >
<channel>
    <title>Doctrine Project</title>
    <link>http://www.doctrine-project.org/jira</link>
    <description>This file is an XML representation of an issue</description>
    <language>en-us</language>    <build-info>
        <version>5.2.7</version>
        <build-number>850</build-number>
        <build-date>21-02-2013</build-date>
    </build-info>

<item>
            <title>[DBAL-65] No way to store binary data in PostgreSQL with Doctrine</title>
                <link>http://www.doctrine-project.org/jira/browse/DBAL-65</link>
                <project id="10040" key="DBAL">Doctrine DBAL</project>
                        <description>&lt;p&gt;The type system introduced by Doctrine makes impossible to store binary data in PostgreSQL databases that use Unicode. The `text` type is mapped to `TEXT`, but any trial to place some binary data there ends up with a database error, like this:&lt;/p&gt;

&lt;p&gt;&lt;tt&gt;SQLSTATE&lt;span class=&quot;error&quot;&gt;&amp;#91;22021&amp;#93;&lt;/span&gt;: Character not in repertoire: 7 ERROR: invalid byte sequence for encoding &quot;UTF8&quot;: 0x9c&lt;/tt&gt;&lt;/p&gt;

&lt;p&gt;This is a critical limitation, because Doctrine cannot be used now in projects that for any reasons have to use PostgreSQL, and their databases must store binary data. Even if it cannot be fixed right now, it should be clearly pointed out in the documentation in &quot;Known vendor issues&quot;.&lt;/p&gt;

&lt;p&gt;A possible solution for this problem is creating an equivalent of &apos;text&apos; field, called &apos;binary&apos; or something like that. It must be a simple type that is mapped to the simplest, but large type available in the database engine without any form of data structure validation. For PostgreSQL, this could be &apos;blob&apos;, but other database engines can use different types.&lt;/p&gt;</description>
                <environment>PostgreSQL 8.4</environment>
            <key id="12128">DBAL-65</key>
            <summary>No way to store binary data in PostgreSQL with Doctrine</summary>
                <type id="1" iconUrl="http://www.doctrine-project.org/jira/images/icons/issuetypes/bug.png">Bug</type>
                                <priority id="3" iconUrl="http://www.doctrine-project.org/jira/images/icons/priorities/major.png">Major</priority>
                    <status id="5" iconUrl="http://www.doctrine-project.org/jira/images/icons/statuses/resolved.png">Resolved</status>
                    <resolution id="6">Invalid</resolution>
                                <assignee username="beberlei">Benjamin Eberlei</assignee>
                                <reporter username="zyxist">Tomasz J&#281;drzejewski</reporter>
                        <labels>
                    </labels>
                <created>Sat, 20 Nov 2010 14:07:43 +0000</created>
                <updated>Tue, 9 Oct 2012 14:51:55 +0000</updated>
                    <resolved>Sat, 20 Nov 2010 17:55:09 +0000</resolved>
                                                                    <due></due>
                    <votes>0</votes>
                        <watches>2</watches>
                        <comments>
                    <comment id="14792" author="zyxist" created="Sat, 20 Nov 2010 14:12:17 +0000"  >&lt;p&gt;Just a small note why I consider this bug as quite serious: for many programmers and their projects the lack of both support for such content type and any information about the limitation can be very dangerous. It can be impossible to remove ORM, if such an issue is encountered in the implementation process, and trials to workaround it are time-consuming.&lt;/p&gt;

&lt;p&gt;If I&apos;m about to decide whether to use a particular ORM or not, I must have full information about ORM and database-specific limitations.&lt;/p&gt;

&lt;p&gt;One more update: shame on me, obviously there is no &quot;blob&quot; type in PostgreSQL; in this database engine binary data could be represented by &apos;BYTEA&apos;.&lt;/p&gt;</comment>
                    <comment id="14793" author="beberlei" created="Sat, 20 Nov 2010 17:55:09 +0000"  >&lt;p&gt;This is not an issue, there are two options to &quot;solve&quot; your problem in userland:&lt;/p&gt;

&lt;p&gt;1. Create your own DBAL type - &lt;a href=&quot;http://www.doctrine-project.org/projects/orm/2.0/docs/reference/basic-mapping/en#custom-mapping-types&quot; class=&quot;external-link&quot;&gt;http://www.doctrine-project.org/projects/orm/2.0/docs/reference/basic-mapping/en#custom-mapping-types&lt;/a&gt;&lt;br/&gt;
2. Use columnDefinition Attribute of @column - &lt;a href=&quot;http://www.doctrine-project.org/projects/orm/2.0/docs/reference/annotations-reference/en#ann_column&quot; class=&quot;external-link&quot;&gt;http://www.doctrine-project.org/projects/orm/2.0/docs/reference/annotations-reference/en#ann_column&lt;/a&gt;&lt;/p&gt;</comment>
                    <comment id="14963" author="zyxist" created="Sun, 12 Dec 2010 09:56:14 +0000"  >&lt;p&gt;I know I can create a custom type, but I&apos;d like to have a portable binary type by default in Doctrine DBAL, not reinventing the wheel every time I want to have one. I consider binary data as one of the primitive types that every database engine supports.&lt;/p&gt;</comment>
                    <comment id="18813" author="jonrwads" created="Tue, 9 Oct 2012 14:49:13 +0000"  >&lt;p&gt;This is an old post but just in case somebody else finds it.  There is no need to do any of the above to store binary data in Postgres.  I had the same situation and was easily solved by compressing file, base64 encoding it, and finally serializing it.&lt;/p&gt;

&lt;p&gt;    public static function prepareFileforDatabase($file)&lt;/p&gt;
    {
        $compressor = new \Zend_Filter_Compress_Gz();
        $file = $compressor-&amp;gt;compress($file);
        $file = base64_encode($file);
        return serialize($file);
    }

&lt;p&gt;We use Zend and you may be able to get away with not compressing if you wanted to avoid the extra overhead on your server.  To undo it is exactly the opposite.&lt;/p&gt;

&lt;p&gt;    public static function prepareFileforPHP($file)&lt;/p&gt;
    {
        $compressor = new \Zend_Filter_Compress_Gz();
        $file = unserialize($file);
        $file = base64_decode($file);
        return $compressor-&amp;gt;decompress($file);
    }

&lt;p&gt;Sorry for the code coming out in all one line, but you get the idea.&lt;/p&gt;</comment>
                </comments>
                    <attachments>
                </attachments>
            <subtasks>
        </subtasks>
        </item>
</channel>
</rss>