Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Btrim function is not working properly in PostgreSQL

Here, I have a problem in the value from trim() function in PostgreSQL:

Ruby code:

    if(this.modelName=="ClientOffice")
       {    this.params="model_name="+this.modelName+"&action_name="+this.actionName+"&
find_condition=btrim(clients_corporate_billings.id,' ') %3D 
btrim('"+validString('populateValue0','text')+"',' ')
  & object_id="+this.objectId;
      }

 &action_name="+this.actionName+"
    &find_condition=btrim(clients_corporate_billings.id,' ') %3D
     btrim('"+validString('populateValue0','text')+"',' ')

In above code, btrim is function of PostgreSQL for trimming but it gives/produce error.

like image 291
Rubyist Avatar asked Oct 14 '25 09:10

Rubyist


1 Answers

From the documentation.

Function: btrim(string text [, characters text])
Return Type: text
Description: Remove the longest string consisting only of characters in characters (a space by default) from the start and end of string
Example: btrim('xyxtrimyyx', 'xy')
Result: trim


So you need to cast as text:

&find_condition=btrim(clients_corporate_billings.id::text,' ') %3D

like image 175
vol7ron Avatar answered Oct 16 '25 22:10

vol7ron



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!