Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

脱敏功能中a.*,phone,a.*的结果里query_tree的index乱序 #426

Closed
unknowissue opened this issue Feb 9, 2022 · 3 comments
Closed

Comments

@unknowissue
Copy link

描述
脱敏功能中a.,phone,a. from t1 a 的结果里query_tree的index乱序,是否符合预期呢?

比如

 select a.*,a.phone,a.* from users a  ;
[{"index":0,"field":"id","type":"int","table":"users","schema":"db1","alias":"id"},
{"index":1,"field":"phone","type":"varchar(80)","table":"users","schema":"db1","alias":"phone"},
{"index":2,"field":"email","type":"varchar(30)","table":"users","schema":"db1","alias":"email"},
{"index":3,"field":"create_time","type":"datetime","table":"users","schema":"db1","alias":"create_time"},
{"index":1,"field":"phone","type":"varchar(80)","table":"users","schema":"db1","alias":"phone"},
{"index":2,"field":"id","type":"int","table":"users","schema":"db1","alias":"id"},
{"index":3,"field":"phone","type":"varchar(80)","table":"users","schema":"db1","alias":"phone"},
{"index":4,"field":"email","type":"varchar(30)","table":"users","schema":"db1","alias":"email"},
{"index":5,"field":"create_time","type":"datetime","table":"users","schema":"db1","alias":"create_time"}]

select id,phone,email,create_time,a.*  ,phone   from users a limit 100;
 [{"index":0,"field":"id","type":"int","table":"users","schema":"db1","alias":"id"},
{"index":1,"field":"phone","type":"varchar(80)","table":"users","schema":"db1","alias":"phone"},
{"index":2,"field":"email","type":"varchar(30)","table":"users","schema":"db1","alias":"email"},
{"index":3,"field":"create_time","type":"datetime","table":"users","schema":"db1","alias":"create_time"},
{"index":4,"field":"id","type":"int","table":"users","schema":"db1","alias":"id"},
{"index":5,"field":"phone","type":"varchar(80)","table":"users","schema":"db1","alias":"phone"},
{"index":6,"field":"email","type":"varchar(30)","table":"users","schema":"db1","alias":"email"},
{"index":7,"field":"create_time","type":"datetime","table":"users","schema":"db1","alias":"create_time"},
{"index":5,"field":"phone","type":"varchar(80)","table":"users","schema":"db1","alias":"phone"}] 

没懂为啥index会有重复值和乱的,

重现

 select a.*,a.phone,a.* from users a  ;
#!/usr/bin/env python3
# -*- coding:utf-8 -*-
import pymysql
import prettytable as pt
tb = pt.PrettyTable()
sql = '''/*--user=xxxx;--password=xxxxxx==;--host=192.168.1.59;--port=3308;--masking=1;*/
                          inception_magic_start;
                          use `db1`;
                          select a.*,a.phone,a.* from users a  ;
                          inception_magic_commit;'''
conn = pymysql.connect(host='127.0.0.1', user='', passwd='',
                       db='', port=4000, charset="utf8mb4")
cur = conn.cursor()
ret = cur.execute(sql)
result = cur.fetchall()
print(result)
cur.close()
conn.close()
tb.field_names = [i[0] for i in cur.description]
for row in result:
    tb.add_row(row)
print(tb)

select id,phone,email,create_time,a.*  ,phone   from users a limit 100;
#!/usr/bin/env python3
# -*- coding:utf-8 -*-
import pymysql
import prettytable as pt
tb = pt.PrettyTable()
sql = '''/*--user=xxxx;--password=xxxxxx==;--host=192.168.1.59;--port=3308;--masking=1;*/
                          inception_magic_start;
                          use `db1`;
                          select id,phone,email,create_time,a.*  ,phone   from users a limit 100 ;
                          inception_magic_commit;'''
conn = pymysql.connect(host='127.0.0.1', user='', passwd='',
                       db='', port=4000, charset="utf8mb4")
cur = conn.cursor()
ret = cur.execute(sql)
result = cur.fetchall()
print(result)
cur.close()
conn.close()
tb.field_names = [i[0] for i in cur.description]
for row in result:
    tb.add_row(row)
print(tb)

环境

  • 版本: [v1.2.5-10]

参数
可能与问题相关的设置参数

@hanchuanchuan
Copy link
Owner

index原本的设计是记录列所在的位置, 乱序是个bug, 稍后会修复该问题.

@hanchuanchuan
Copy link
Owner

已更新 v1.2.5-23. 请升级后重试.

@unknowissue
Copy link
Author

已更新 v1.2.5-23. 请升级后重试.

ok了,谢谢支持

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants