Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
antSword
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
HuangJunbo
antSword
Commits
52ba83cc
Commit
52ba83cc
authored
Jun 23, 2022
by
Medicean
Committed by
Medicean
Jul 17, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(Fix: Core/JSP) 修正 mysql 表名中有特殊符号时执行异常的问题
parent
cd5a5c00
Changes
2
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
49 deletions
+41
-49
mysql.js
source/core/jsp/template/database/mysql.js
+4
-4
index.js
source/modules/database/jsp/index.js
+37
-45
No files found.
source/core/jsp/template/database/mysql.js
View file @
52ba83cc
This diff is collapsed.
Click to expand it.
source/modules/database/jsp/index.js
View file @
52ba83cc
...
@@ -18,9 +18,9 @@ class JSP {
...
@@ -18,9 +18,9 @@ class JSP {
// * 数据库驱动列表
// * 数据库驱动列表
//
//
this
.
conns
=
{
this
.
conns
=
{
'mysql'
:
'com.mysql.jdbc.Driver
\
r
\
njdbc:mysql://localhost
/test
?user=root&password=123456'
,
'mysql'
:
'com.mysql.jdbc.Driver
\
r
\
njdbc:mysql://localhost
:3306/information_schame
?user=root&password=123456'
,
'sqlserver'
:
'com.microsoft.sqlserver.jdbc.SQLServerDriver
\
r
\
njdbc:sqlserver://127.0.0.1:1433;'
+
'sqlserver'
:
'com.microsoft.sqlserver.jdbc.SQLServerDriver
\
r
\
njdbc:sqlserver://127.0.0.1:1433;'
+
'databaseName=
test
;user=sa;password=123456'
,
'databaseName=
master
;user=sa;password=123456'
,
'oracle'
:
'oracle.jdbc.driver.OracleDriver
\
r
\
njdbc:oracle:thin:@127.0.0.1:1521/test
\
r
\
nuser'
+
'oracle'
:
'oracle.jdbc.driver.OracleDriver
\
r
\
njdbc:oracle:thin:@127.0.0.1:1521/test
\
r
\
nuser'
+
'
\
r
\
npassword'
'
\
r
\
npassword'
};
};
...
@@ -89,7 +89,7 @@ class JSP {
...
@@ -89,7 +89,7 @@ class JSP {
let
sql
=
""
;
let
sql
=
""
;
switch
(
this
.
dbconf
[
'type'
])
{
switch
(
this
.
dbconf
[
'type'
])
{
case
'mysql'
:
case
'mysql'
:
sql
=
`SELECT \`
${
column
}
\` FROM \`
${
table
}
\` ORDER BY 1 DESC LIMIT 0,20;`
;
sql
=
`SELECT \`
${
column
}
\` FROM \`
${
db
}
\`.\`
${
table
}
\` ORDER BY 1 DESC LIMIT 0,20;`
;
break
;
break
;
case
'sqlserver'
:
case
'sqlserver'
:
case
'mssql'
:
case
'mssql'
:
...
@@ -105,7 +105,7 @@ class JSP {
...
@@ -105,7 +105,7 @@ class JSP {
sql
=
`SELECT
${
column
}
FROM
${
table
}
ORDER BY 1 DESC LIMIT 20 OFFSET 0;`
;
sql
=
`SELECT
${
column
}
FROM
${
table
}
ORDER BY 1 DESC LIMIT 20 OFFSET 0;`
;
break
;
break
;
default
:
default
:
sql
=
`SELECT \`
${
column
}
\` FROM \`
${
table
}
\` ORDER BY 1 DESC LIMIT 0,20;`
;
sql
=
`SELECT \`
${
column
}
\` FROM \`
${
db
}
\`.\`
${
table
}
\` ORDER BY 1 DESC LIMIT 0,20;`
;
break
;
break
;
}
}
this
this
...
@@ -629,11 +629,7 @@ class JSP {
...
@@ -629,11 +629,7 @@ class JSP {
// 获取字段
// 获取字段
getColumns
(
id
,
db
,
table
)
{
getColumns
(
id
,
db
,
table
)
{
this
this
.
manager
.
list
.
layout
.
progressOn
();
.
manager
.
list
.
layout
.
progressOn
();
// 获取配置
// 获取配置
const
conf
=
antSword
[
'ipcRenderer'
].
sendSync
(
'shell-getDataConf'
,
{
const
conf
=
antSword
[
'ipcRenderer'
].
sendSync
(
'shell-getDataConf'
,
{
_id
:
this
.
manager
.
opt
[
'_id'
],
_id
:
this
.
manager
.
opt
[
'_id'
],
...
@@ -654,12 +650,8 @@ class JSP {
...
@@ -654,12 +650,8 @@ class JSP {
throw
ret
;
throw
ret
;
}
}
const
arr
=
ret
.
split
(
'
\
t'
);
const
arr
=
ret
.
split
(
'
\
t'
);
const
_db
=
Buffer
const
_db
=
Buffer
.
from
(
db
).
toString
(
'base64'
);
.
from
(
db
)
const
_table
=
Buffer
.
from
(
table
).
toString
(
'base64'
);
.
toString
(
'base64'
);
const
_table
=
Buffer
.
from
(
table
)
.
toString
(
'base64'
);
// 删除子节点
// 删除子节点
this
this
.
tree
.
tree
...
@@ -670,46 +662,46 @@ class JSP {
...
@@ -670,46 +662,46 @@ class JSP {
return
return
};
};
_
=
antSword
.
unxss
(
_
);
_
=
antSword
.
unxss
(
_
);
const
_column
=
Buffer
const
_column
=
Buffer
.
from
(
_
.
substr
(
0
,
_
.
lastIndexOf
(
' '
)
>
0
?
_
.
lastIndexOf
(
' '
)
:
_
.
length
)).
toString
(
'base64'
);
.
from
(
_
.
substr
(
0
,
_
.
lastIndexOf
(
' '
)))
.
toString
(
'base64'
);
this
this
.
tree
.
tree
.
insertNewItem
(
`table::
${
id
}
:
${
_db
}
:
${
_table
}
`
,
`column::
${
id
}
:
${
_db
}
:
${
_table
}
:
${
_column
}
`
,
antSword
.
noxss
(
_
),
null
,
this
.
manager
.
list
.
imgs
[
3
],
this
.
manager
.
list
.
imgs
[
3
],
this
.
manager
.
list
.
imgs
[
3
]);
.
insertNewItem
(
`table::
${
id
}
:
${
_db
}
:
${
_table
}
`
,
`column::
${
id
}
:
${
_db
}
:
${
_table
}
:
${
_column
}
`
,
antSword
.
noxss
(
_
),
null
,
this
.
manager
.
list
.
imgs
[
3
],
this
.
manager
.
list
.
imgs
[
3
],
this
.
manager
.
list
.
imgs
[
3
]);
});
});
// 更新编辑器SQL语句
// 更新编辑器SQL语句
this
let
presql
=
""
;
.
manager
switch
(
this
.
dbconf
[
'type'
])
{
.
query
case
'mssql'
:
.
editor
case
'sqlsrv'
:
.
session
presql
=
`SELECT TOP 20 * from [
${
table
}
] ORDER BY 1 DESC;`
;
.
setValue
(
conf
[
'type'
]
===
'oracle'
?
break
;
`SELECT * FROM (SELECT A.*,ROWNUM N FROM
${
db
}
.
${
table
}
A ORDER BY 1 DESC) WHERE N>0 AND N<=20`
:
case
'oracle'
:
`SELECT * FROM
${
db
}
.
${
table
}
ORDER BY 1 DESC LIMIT 0,20;`
);
case
'oracle_oci8'
:
this
presql
=
`SELECT * FROM
${
db
}
.
${
table
}
WHERE ROWNUM < 20 ORDER BY 1`
;
.
manager
break
;
.
list
case
'postgresql'
:
.
layout
case
'postgresql_pdo'
:
.
progressOff
();
presql
=
`SELECT * FROM
${
table
}
ORDER BY 1 DESC LIMIT 20 OFFSET 0;`
;
break
;
case
'sqlite3'
:
case
'sqlite_pdo'
:
presql
=
`SELECT * FROM "
${
db
}
"."
${
table
}
" ORDER BY 1 DESC limit 0,20;`
;
break
;
default
:
presql
=
`SELECT * FROM \`
${
db
}
\`.\`
${
table
}
\` ORDER BY 1 DESC LIMIT 0,20;`
;
break
;
}
this
.
manager
.
query
.
editor
.
session
.
setValue
(
presql
);
this
.
manager
.
list
.
layout
.
progressOff
();
})
})
.
catch
((
err
)
=>
{
.
catch
((
err
)
=>
{
toastr
.
error
(
LANG
[
'result'
][
'error'
][
'column'
](
err
[
'status'
]
||
JSON
.
stringify
(
err
)),
LANG_T
[
'error'
]);
toastr
.
error
(
LANG
[
'result'
][
'error'
][
'column'
](
err
[
'status'
]
||
JSON
.
stringify
(
err
)),
LANG_T
[
'error'
]);
this
this
.
manager
.
list
.
layout
.
progressOff
();
.
manager
.
list
.
layout
.
progressOff
();
});
});
}
}
// 执行SQL
// 执行SQL
execSQL
(
sql
)
{
execSQL
(
sql
)
{
this
this
.
manager
.
query
.
layout
.
progressOn
();
.
manager
.
query
.
layout
.
progressOn
();
this
this
.
core
.
core
.
request
(
this
.
core
[
`database_
${
this
.
dbconf
[
'type'
]}
`
].
query
({
.
request
(
this
.
core
[
`database_
${
this
.
dbconf
[
'type'
]}
`
].
query
({
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment