[Dbix-class] Weird search issue

David Ihnen davidi at norchemlab.com
Thu Feb 12 18:13:53 GMT 2009


Looks like an encoding problem, fREW.  You might notice its not a dot 
*between* - its a dot *after* each letter.  The data is being sent in as 
something like 16 bit unicode, and is being serialized out without 
taking that into account.

I wish I knew the solution, but I hope that provides a lead for you.

David

fREW Schmidt wrote:
> Ok, here is my code:
>
>         return $self->basic_data({
>                 table => 'Customer',
>                 search => {
>                     id => "AA001",
>                 },
>                 columns => [qw/id name price_approval_required comments/],
>             });
>
>
> and I am calling this function that I wrote:
>
>     sub basic_data {
>         my $self = shift;
>         my $params = shift;
>         my $table = $params->{table};
>         my $search = $params->{search};
>         my $columns = $params->{columns};
>         my $rows = $self->query->param('limit') || 25;
>         my $page = ($self->query->param('start')?(
>     $self->query->param('start')/$rows + 1 ):1);
>         my $order_by =
>     ($self->query->param('sort')?$self->query->param('sort').'
>     '.$self->query->param('dir'):'id');
>         use DBIx::Class::ResultClass::HashRefInflator;
>         my $rs_full = $self->schema()->resultset($table)->search($search,{
>             order_by => $order_by,
>             columns => $columns,
>         });
>         my $data = { data => []};
>         $data->{total} = $rs_full->count;
>         my $rs = $rs_full->search({},{
>             rows => $rows,
>             page => $page,
>         });
>         $rs->result_class('DBIx::Class::ResultClass::HashRefInflator');
>         while (my $operation_code = $rs->next() ) {
>             push @{$data->{data}}, $operation_code;
>         }
>         return $self->json_body($data);
>     }
>
>
> yet I am getting this error:
>
>     [Thu Feb 12 10:57:16 2009] [error] [client 127.0.0.1] [Dispatch]
>     ERROR for request
>     '/devcgi/init.plx/controller_WorkOrderEntry/customer?cusomter_id=AA001':
>     Error executing run mode 'customer':
>     DBIx::Class::ResultSet::next(): DBI Exception: DBD::ODBC::st
>     fetchrow_array failed: [Microsoft][SQL Native Client]String data,
>     right truncation (SQL-01004) [for Statement "SELECT * FROM
>     [Thu Feb 12 10:57:16 2009] [error] [client 127.0.0.1] (
>     [Thu Feb 12 10:57:16 2009] [error] [client 127.0.0.1]     SELECT
>     TOP 25 * FROM
>     [Thu Feb 12 10:57:16 2009] [error] [client 127.0.0.1]     (
>     [Thu Feb 12 10:57:16 2009] [error] [client 127.0.0.1]        
>     SELECT TOP 25  me.id <http://me.id>, me.name <http://me.name>,
>     me.price_approval_required, me.comments FROM Customers me WHERE (
>     id = ? ) ORDER BY id ASC
>     [Thu Feb 12 10:57:16 2009] [error] [client 127.0.0.1]     ) AS foo
>     [Thu Feb 12 10:57:16 2009] [error] [client 127.0.0.1]     ORDER BY
>     id DESC
>     [Thu Feb 12 10:57:16 2009] [error] [client 127.0.0.1] ) AS bar
>     [Thu Feb 12 10:57:16 2009] [error] [client 127.0.0.1] ORDER BY id ASC
>     [Thu Feb 12 10:57:16 2009] [error] [client 127.0.0.1] " with
>     ParamValues: 1='A.A.0.0.1.'] at C:\\Documents and
>     Settings\\frew\\My
>     Documents\\Code\\aircraft_ducting/ACD/Controller.pm line 75
>
>
> Anyone have any idea why it is adding dots between each character in 
> the search?
>
> -fREW
>
>
> -- 
> fREW Schmidt
> http://blog.afoolishmanifesto.com
> ------------------------------------------------------------------------
>
> _______________________________________________
> List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
> IRC: irc.perl.org#dbix-class
> SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
> Searchable Archive: http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk




More information about the DBIx-Class mailing list