Commit ee19f449 authored by Jérome Perrin's avatar Jérome Perrin

dms: explicitly cast `path` selected columns to char

On python3, the type of selected columns depend on the data type from
mariadb side, VARCHAR will be str, BINARY/BLOB will be bytes, etc

These SQL method select path that is first evaluated from a variable
that is NULL and in that case, mariadb seems to select LONGBLOB as data
type:

    MariaDB [test]> set @defined_as_null=null; drop table if exists tmp; create table tmp as (select @defined_as_null); show create table tmp;
    +-------+------------------------------------------------------------------------------------------------------------------------------------+
    | Table | Create Table                                                                                                                       |
    +-------+------------------------------------------------------------------------------------------------------------------------------------+
    | tmp   | CREATE TABLE `tmp` (
      `@defined_as_null` longblob DEFAULT NULL
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci |
    +-------+------------------------------------------------------------------------------------------------------------------------------------+

By casting to CHAR in SQL, on the python side we always have the str
that we expect here, because this is used as path attribute of a SQL
brain.
parent 5349d8c4
......@@ -18,7 +18,7 @@ sub.path,
uid
FROM
( SELECT
@current_path:=IF(@current_reference = reference, @current_path, path) AS path,
@current_path:=CAST(IF(@current_reference = reference, @current_path, path) AS CHAR) AS path,
@current_reference:=reference AS reference
FROM (
SELECT
......
......@@ -17,7 +17,7 @@ sub.path,
uid
FROM
( SELECT
@current_path:=IF(@current_reference = reference, @current_path, path) AS path,
@current_path:=CAST(IF(@current_reference = reference, @current_path, path) AS CHAR) AS path,
@current_reference:=reference AS reference
FROM (
SELECT
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment