Tuesday, August 30, 2016

Re: iregex doesn't work properly

You are making me confused. 
1) Django  send data to db and SQL is correct
2) MySQL returns correct result
3) Django shows right data

 Which one step has issue ? 

Many thanks,

Serge


+380 636150445
skype: skhohlov

On Tue, Aug 30, 2016 at 10:51 AM, Denis Yu <denis.yugay@gmail.com> wrote:
Yes, i've seen.

could you pls say one more ideas to check?




воскресенье, 28 августа 2016 г., 21:11:56 UTC+6 пользователь Sergiy Khohlov написал:
I've made mistake : "$" should be in request not "%"

 this request "SELECT COUNT(*) AS `__count` FROM `clients_order_process` WHERE (`clients_order_process`.`step` = 1 AND `clients_order_process`.`step_description` REGEXP '^заказ роутер.$')"  informs that django sends data correctly.

Many thanks,

Serge


+380 636150445
skype: skhohlov

On Sun, Aug 28, 2016 at 2:18 PM, Denis Yu <denis...@gmail.com> wrote:
  1. Here is the result in logging table:

mysql> select * from mysql.general_log;
....
| 2016-08-28 14:14:17.188990 | crm[crm] @ localhost [] |       934 |         0 | Query        | SELECT COUNT(*) AS `__count` FROM `clients_order_process` WHERE (`clients_order_process`.`step` = 1 AND `clients_order_process`.`step_description` REGEXP '^заказ роутер.$')
....




the record exists in table:
mysql> select id, step, step_description from clients_order_process where id =241;
+-----+------+---------------------------+
| id  | step | step_description          |
+-----+------+---------------------------+
| 241 |    1 | заказ роутера             |
+-----+------+---------------------------+
1 row in set (0,00 sec)



  1. the result of query  SELECT id from Order_process WHERE step_description REGEXP BINARY '^заказ роутера%'; :

mysql>  SELECT id from clients_order_process WHERE step_description REGEXP BINARY '^заказ роутера%';
Empty set (0,00 sec)



mysql> select * from mysql.general_log;
+----------------------------+-------------------------+-----------+-----------+--------------+---------------------------------------------------------------------------------------------------------+
| event_time                 | user_host               | thread_id | server_id | command_type | argument                                                                                                |
+----------------------------+-------------------------+-----------+-----------+--------------+---------------------------------------------------------------------------------------------------------+
| 2016-08-28 14:18:20.921420 | crm[crm] @ localhost [] |       857 |         0 | Query        | SELECT id from clients_order_process WHERE step_description REGEXP BINARY '^заказ роутера%'   


Pls, explain, what way do you recommend using raw string?


thanks




воскресенье, 28 августа 2016 г., 0:58:24 UTC+6 пользователь Sergiy Khohlov написал:
Not sure that problem is related to character_set_server due to highest priority of create table option.  I'm using postgres as default.  I'm proposing to check latin chars and turn on mysql debugging  in case of your permission. 
  localization coding  of MySql is  here http://dev.mysql.com/doc/refman/5.7/en/charset-syntax.html


 At this moment I propose do next : 
1)  check log for sql request from django to Mysql 
2) execute next sql from mysql :    SELECT id from Order_process WHERE step_description REGEXP BINARY '^заказ роутера%';


 Why are you not using raw string in your regex ?


Many thanks,

Serge


+380 636150445
skype: skhohlov

On Sat, Aug 27, 2016 at 8:13 PM, Denis Yu <denis...@gmail.com> wrote:
Sergiy,

Thank you for reply

I checked following parameters:

mysql> show create table clients_order_process; (clients_order_process - it's my table)

| clients_order_process | CREATE TABLE `clients_order_process` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `step` int(11) NOT NULL,
  `step_description` longtext NOT NULL,
  `date_step` datetime NOT NULL,
  `order_id` int(11) NOT NULL,
  `manager_id` int(11),
  PRIMARY KEY (`id`),
  KEY `clients_order_proces_order_id_1eb697bf_fk_clients_order_id` (`order_id`),
  KEY `clients_order_process_8784215c` (`manager_id`),
  CONSTRAINT `clients_order_proces_order_id_1eb697bf_fk_clients_order_id` FOREIGN KEY (`order_id`) REFERENCES `clients_order` (`id`),
  CONSTRAINT `clients_order_process_manager_id_f3e3fa60_fk_auth_user_id` FOREIGN KEY (`manager_id`) REFERENCES `auth_user` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=249 DEFAULT CHARSET=utf8 |


mysql> show variables like 'character_set%';
+--------------------------+----------------------------+
| Variable_name            | Value                      |
+--------------------------+----------------------------+
| character_set_client     | utf8                       |
| character_set_connection | utf8                       |
| character_set_database   | utf8                       |
| character_set_filesystem | binary                     |
| character_set_results    | utf8                       |
| character_set_server     | latin1                     |
| character_set_system     | utf8                       |
| character_sets_dir       | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0,01 sec)


so, I found  | character_set_server     | latin1 
is this the problem?





суббота, 27 августа 2016 г., 19:28:18 UTC+6 пользователь Sergiy Khohlov написал:

Try to check this via mysql shell. It will be nice to know codepage at system, database and django project. Have you checked this with Latin charset already ?


27 серп. 2016 16:06 "Denis Yu" <denis...@gmail.com> пише:
Hi,

Someone please, help to resolve my problem with iregex !

using Django 1.9
mysql Server version: 5.7.13-0ubuntu0.16.04.2 (Ubuntu)
python 2.7

I got the record in mysql in table Order_process:

+-----+------+---------------------------+---------------------+----------+------------+
| id  | step | step_description          | date_step           | order_id | manager_id |
+-----+------+---------------------------+---------------------+----------+------------+
| 241 |    1 | заказ роутера             | 2016-08-21 11:03:16 |      170 |          1 |
+-----+------+---------------------------+---------------------+----------+------------+
 
next, I'd like to get thi record by queryset:
    str_iregex = '^заказ роутер.$'
    orders = Order_process.objects.filter(step_description__iregex = str_iregex , step = 1).order_by('-id')

But the got no result.
pls help








--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/8da615e3-c990-4359-9851-32d12b5d9fb0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/b909b7c6-d8f3-41e5-99d5-19708446f4df%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/3f892689-aa16-4395-b06e-7445dd180974%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/bdbaeba6-3dc9-4d49-bd3d-513d06fec817%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CADTRxJMvFh6T-WL8nqKNNo7LHxBre5pdmt7Qmyh6MTtx8K-1DQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment