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

v1.10.0,查询页面,选择查询oracle表,返回创建表语句有问题 #2378

Closed
peng19832 opened this issue Nov 13, 2023 · 1 comment · Fixed by #2406
Closed

v1.10.0,查询页面,选择查询oracle表,返回创建表语句有问题 #2378

peng19832 opened this issue Nov 13, 2023 · 1 comment · Fixed by #2406

Comments

@peng19832
Copy link
Contributor

重现步骤

  1. 在sql查询页面,勾选实例、数据库和表
  2. 下方没有返回创建表语句,而是返回每一列的数据类型

预期外的结果

image

日志文本

[root@k8s-node3 ~]# docker logs sqlaudit -f --tail=10
[2023-11-13 17:56:15 +0800] [36] [INFO] Listening at: http://127.0.0.1:8888 (36)
[2023-11-13 17:56:15 +0800] [36] [INFO] Using worker: sync
[2023-11-13 17:56:15 +0800] [43] [INFO] Booting worker with pid: 43
[2023-11-13 17:56:15 +0800] [54] [INFO] Booting worker with pid: 54
[2023-11-13 17:56:15 +0800] [55] [INFO] Booting worker with pid: 55
[2023-11-13 17:56:16 +0800] [56] [INFO] Booting worker with pid: 56
2023-11-13 17:56:16,079 - environ.environ - INFO - /opt/archery/.env not found - if you're not configuring your environment separately, check this.
2023-11-13 17:56:16,129 - environ.environ - INFO - /opt/archery/.env not found - if you're not configuring your environment separately, check this.
2023-11-13 17:56:16,152 - environ.environ - INFO - /opt/archery/.env not found - if you're not configuring your environment separately, check this.
2023-11-13 17:56:16,251 - environ.environ - INFO - /opt/archery/.env not found - if you're not configuring your environment separately, check this.

版本

1.10.0

部署方式

Docker

是否还有其他可以辅助定位问题的信息?比如数据库版本等

MySQL: 5.7

@LeoQuote
Copy link
Collaborator

LeoQuote commented Nov 21, 2023

大佬, 不好意思, 这个应该是我前段时间重构 engine 导致的, 现在都是对标 mysql, 需要跟 mysql 的返回一样, 重构还是为了维护方便, 以后再定制 engine 应该会更简单

def describe_table(self, db_name, tb_name, **kwargs):
"""return ResultSet"""
# https://www.thepolyglotdeveloper.com/2015/01/find-tables-oracle-database-column-name/
sql = f"""SELECT
a.column_name,
data_type,
data_length,
nullable,
data_default,
b.comments
FROM all_tab_cols a, all_col_comments b
WHERE a.table_name = b.table_name
and a.owner = b.OWNER
and a.COLUMN_NAME = b.COLUMN_NAME
and a.table_name = :tb_name and a.owner = :db_name order by column_id
"""
result = self.query(
db_name=db_name,
sql=sql,
parameters={"db_name": db_name, "tb_name": tb_name},
)
return result

def describe_table(self, db_name, tb_name, **kwargs):
sql = f"describe table {tb_name}"
result = self.query(db_name=db_name, sql=sql)
result.column_list = ["table", "create table"]
filtered_rows = []
for r in result.rows:
filtered_rows.append((r[2], r[3]))
result.rows = filtered_rows
return result

参考下 cassandra 的实现, 是需要返回一个result set, 要求如下:

  1. result.column_list = ["table", "create table"]
  2. result.rows = [("表名", "建表语句")]

我这边没有 oracle 的环境所以暂时无法适配, 还请劳烦大佬适配一下, 如果方便的话还请提一个 pr, 谢谢!

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

Successfully merging a pull request may close this issue.

2 participants