Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
dinky
Project
Project
Details
Activity
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
wangpeng
dinky
Commits
8f8c08a2
Unverified
Commit
8f8c08a2
authored
May 09, 2024
by
Zzm0809
Committed by
GitHub
May 09, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Optimization]optimizing mysql sql generation logic (#3463)
Signed-off-by:
Zzm0809
<
934230207@qq.com
>
Co-authored-by:
Zzm0809
<
Zzm0809@users.noreply.github.com
>
parent
eeaaa70c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
3 deletions
+10
-3
MySqlDriver.java
.../src/main/java/org/dinky/metadata/driver/MySqlDriver.java
+10
-3
No files found.
dinky-metadata/dinky-metadata-mysql/src/main/java/org/dinky/metadata/driver/MySqlDriver.java
View file @
8f8c08a2
...
@@ -37,6 +37,8 @@ import java.util.List;
...
@@ -37,6 +37,8 @@ import java.util.List;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
import
cn.hutool.core.util.NumberUtil
;
import
cn.hutool.core.util.StrUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
/**
/**
...
@@ -106,14 +108,19 @@ public class MySqlDriver extends AbstractJdbcDriver {
...
@@ -106,14 +108,19 @@ public class MySqlDriver extends AbstractJdbcDriver {
}
else
if
(
null
!=
column
.
getLength
())
{
}
else
if
(
null
!=
column
.
getLength
())
{
unit
=
String
.
format
(
"(%s)"
,
column
.
getLength
());
unit
=
String
.
format
(
"(%s)"
,
column
.
getLength
());
}
}
// Avoid parsing mismatches when the numeric data type column declared by UNSIGNED/ZEROFILL keyword
String
columnType
=
column
.
getType
();
final
String
dv
=
column
.
getDefaultValue
();
final
String
dv
=
column
.
getDefaultValue
();
// If it defaults to a numeric type, there is no need to include single quotes or a bit type
String
defaultValueTag
=
" DEFAULT '%s'"
;
if
(
NumberUtil
.
isNumber
(
dv
)
||
columnType
.
startsWith
(
"bit"
))
{
defaultValueTag
=
" DEFAULT %s"
;
}
String
defaultValue
=
Asserts
.
isNotNull
(
dv
)
String
defaultValue
=
Asserts
.
isNotNull
(
dv
)
?
String
.
format
(
" DEFAULT '%s'"
,
dv
.
isEmpty
(
)
?
"''"
:
dv
)
?
String
.
format
(
defaultValueTag
,
StrUtil
.
isEmpty
(
dv
)
?
"''"
:
dv
)
:
String
.
format
(
"%s NULL "
,
!
column
.
isNullable
()
?
" NOT "
:
""
);
:
String
.
format
(
"%s NULL "
,
!
column
.
isNullable
()
?
" NOT "
:
""
);
// Avoid parsing mismatches when the numeric data type column declared by UNSIGNED/ZEROFILL keyword
String
columnType
=
column
.
getType
();
if
(
columnType
.
contains
(
"unsigned"
)
||
columnType
.
contains
(
"zerofill"
))
{
if
(
columnType
.
contains
(
"unsigned"
)
||
columnType
.
contains
(
"zerofill"
))
{
String
[]
arr
=
columnType
.
split
(
" "
);
String
[]
arr
=
columnType
.
split
(
" "
);
arr
[
0
]
=
arr
[
0
].
concat
(
unit
);
arr
[
0
]
=
arr
[
0
].
concat
(
unit
);
...
...
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