Okay, another how many databases support this, question?  I was unaware
MySQL allowed queries based on comparison to a blob column.  Is anyone aware
of other database support for this?

BTW, Slawomir the term is PATCH.

John McNally


----- Original Message -----
From: Slawomir Gawin <[EMAIL PROTECTED]>
To: Turbine <[EMAIL PROTECTED]>
Sent: Tuesday, August 08, 2000 7:26 AM
Subject: [PATH] SqlExpression


> Hello!
>
> I'm learning to use peers in Turbine. In my database (mysql) I've a column
which type is mediumblob.
> And I was unable to do BasePeer.doSelect(Criteria) without this path to
org.apache.turbine.util.db.SqlExpression.java:
>
> @@ -158,6 +158,11 @@
>          {
>              criteria = quoteString(criteria.toString());
>          }
> +        else if( criteria instanceof byte[])
> +        {
> +            criteria = encodeBytes((byte[]) criteria);
> +        }
> +
>          if ( comparison.equals(Criteria.LIKE) )
>          {
>              return buildLike( columnName, (String)criteria, ignoreCase,
db );
> @@ -406,5 +411,27 @@
>                                   .append(value)
>                                   .append("'")
>                                   .toString();
> +    }
> +
> +    /**
> +        Encodes a byte[] ready for placement in a SQL expression.
> +
> +        @param value the byte[] to quote
> +        @return encoded value as String
> +    */
> +    static String encodeBytes(byte value[])
> +    {
> +         StringBuffer result = new StringBuffer("0x");
> +        int count = value.length;
> +        for(int i=0; i<count; i++)
> +        {
> +            String hex = Integer.toHexString(value[i]&0xff);
> +            if (hex.length()==1)
> +            {
> +                result.append("0");
> +            }
> +            result.append(hex);
> +        }
> +        return result.toString();
>      }
>  }
>
> Is it making any sense?
>
> Slawek
>
>
>
> ------------------------------------------------------------
> To subscribe:        [EMAIL PROTECTED]
> To unsubscribe:      [EMAIL PROTECTED]
> Search: <http://www.mail-archive.com/turbine%40list.working-dogs.com/>
> Problems?:           [EMAIL PROTECTED]
>



------------------------------------------------------------
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
Search: <http://www.mail-archive.com/turbine%40list.working-dogs.com/>
Problems?:           [EMAIL PROTECTED]

Reply via email to