plugins-workspace icon indicating copy to clipboard operation
plugins-workspace copied to clipboard

[bug] SQL Plugins Query mysql Return unsupported datatype: BINARY

Open lmq2582609 opened this issue 1 year ago • 6 comments

Describe the bug

Here's my code

let db = await Database.load(`mysql://${username}:${password}@${host}:${port}/information_schema`)
let res = await db.select(`SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = '${database}' AND TABLE_TYPE = 'BASE TABLE'`)
console.info('返回:', res)

error:unsupported datatype: BINARY

But when I use:SELECT TABLE_SCHEMA, TABLE_NAME FROM INFORMATION_SCHEMA.TABLES ........ Returns correctly when * is not used

Reproduction

No response

Expected behavior

No response

Full tauri info output

[✔] Environment
    - OS: Windows 10.0.22631 x86_64 (X64)
    ✔ WebView2: 128.0.2739.79
    ✔ MSVC: Visual Studio Generation Tools 2022
    ✔ rustc: 1.82.0 (f6e511eec 2024-10-15)
    ✔ cargo: 1.82.0 (8f40fc59f 2024-08-21)
    ✔ rustup: 1.27.1 (54dd3d00f 2024-04-24)
    ✔ Rust toolchain: stable-x86_64-pc-windows-msvc (default)
    - node: 18.18.0
    - npm: 9.8.1

[-] Packages
    - tauri 🦀: 2.0.6
    - tauri-build 🦀: 2.0.2
    - wry 🦀: 0.46.3
    - tao 🦀: 0.30.5
    - @tauri-apps/api : 2.0.3
    - @tauri-apps/cli : 2.0.5

[-] Plugins
    - tauri-plugin-sql 🦀: 2.0.1
    - @tauri-apps/plugin-sql : 2.0.0 (outdated, latest: 2.0.1)
    - tauri-plugin-log 🦀: 2.0.1
    - @tauri-apps/plugin-log : 2.0.0
    - tauri-plugin-fs 🦀: 2.0.3
    - @tauri-apps/plugin-fs : 2.0.1 (outdated, latest: 2.0.2)
    - tauri-plugin-shell 🦀: 2.0.2
    - @tauri-apps/plugin-shell : 2.0.1
    - tauri-plugin-store 🦀: 2.1.0
    - @tauri-apps/plugin-store : 2.1.0

[-] App
    - build-type: bundle
    - CSP: unset
    - frontendDist: ../dist
    - devUrl: http://localhost:1420/
    - framework: Vue.js
    - bundler: Vite

Stack trace

No response

Additional context

No response

lmq2582609 avatar Nov 06 '24 09:11 lmq2582609

Today I changed a table with a marker bit type, and a new error occurred during the query. error:unsupported datatype: BIT database is mysql,table structure:

CREATE TABLE `m_config` (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `config_id` bigint NOT NULL COMMENT '',
  `config_name` varchar(100) COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '',
  `config_key` varchar(100) COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '',
  `config_value` varchar(500) COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '',
  `description` varchar(512) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '',
  `status` tinyint DEFAULT '1' COMMENT '',
  `create_id` bigint DEFAULT '0' COMMENT '',
  `create_time` datetime(6) DEFAULT NULL COMMENT '',
  `update_id` bigint DEFAULT '0' COMMENT '',
  `update_time` datetime(6) DEFAULT NULL COMMENT '',
  `deleted` bit(1) DEFAULT b'1' COMMENT '0deleted  1normal',
  `version` int DEFAULT '0' COMMENT '',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='params config'

select statement:

SELECT * FROM m_config

my code:

let db = await Database.load(`mysql://${username}:${password}@${host}:${port}/${database}`)
let sql = `SELECT * FROM ${database}.${connName}`
console.info(‘sql', sql)
let res = await db.select(sql)

lmq2582609 avatar Nov 07 '24 08:11 lmq2582609

这个插件有测试过吗?

liuhuo23 avatar Nov 26 '24 12:11 liuhuo23

COLUMN_KEY is a enum type , you should use CAST(COLUMN_KEY AS CHAR) AS COLUMN_KEY` to get it 亲测有效 @lmq2582609

Bigduang avatar Apr 24 '25 08:04 Bigduang

COLUMN_KEY is a enum type , you should use CAST(COLUMN_KEY AS CHAR) AS COLUMN_KEY` to get it 亲测有效 @lmq2582609

这种确实可以,但是要改用户的sql的,感觉这种方式还是不太友好。 上来找解决方案,结果还是没找到

mugbya avatar Jul 07 '25 14:07 mugbya

COLUMN_KEY is a enum type , you should use CAST(COLUMN_KEY AS CHAR) AS COLUMN_KEY` to get it 亲测有效 @lmq2582609

这种不适合我的场景,在不知道字段是什么类型的情况下,没法使用

lmq2582609 avatar Jul 09 '25 01:07 lmq2582609

COLUMN_KEY is a enum type , you should use CAST(COLUMN_KEY AS CHAR) AS COLUMN_KEY` to get it 亲测有效 @lmq2582609

这种不适合我的场景,在不知道字段是什么类型的情况下,没法使用

en ,自己写吧,我已经自己写了,不用这个插件了

mugbya avatar Jul 16 '25 12:07 mugbya