fix: fixed some issues

This commit is contained in:
meilin.huang
2025-02-20 17:07:13 +08:00
parent aa393590b2
commit 6072bcb111
30 changed files with 120 additions and 89 deletions

View File

@@ -77,6 +77,7 @@ function build() {
if [ "${copyDocScript}" == "1" ] ; then if [ "${copyDocScript}" == "1" ] ; then
echo_green "Copy resources such as scripts [config.yml.example、readme.txt、startup.sh、shutdown.sh]" echo_green "Copy resources such as scripts [config.yml.example、readme.txt、startup.sh、shutdown.sh]"
cp ${server_folder}/config.yml.example ${toFolder} cp ${server_folder}/config.yml.example ${toFolder}
mv ${toFolder}/config.yml.example ${toFolder}/config.yml
cp ${server_folder}/readme.txt ${toFolder} cp ${server_folder}/readme.txt ${toFolder}
cp ${server_folder}/readme_en.txt ${toFolder} cp ${server_folder}/readme_en.txt ${toFolder}
cp ${server_folder}/resources/script/startup.sh ${toFolder} cp ${server_folder}/resources/script/startup.sh ${toFolder}

View File

@@ -11,7 +11,7 @@
}, },
"dependencies": { "dependencies": {
"@element-plus/icons-vue": "^2.3.1", "@element-plus/icons-vue": "^2.3.1",
"@vueuse/core": "^12.5.0", "@vueuse/core": "^12.7.0",
"asciinema-player": "^3.9.0", "asciinema-player": "^3.9.0",
"axios": "^1.6.2", "axios": "^1.6.2",
"clipboard": "^2.0.11", "clipboard": "^2.0.11",
@@ -28,7 +28,7 @@
"monaco-sql-languages": "^0.12.2", "monaco-sql-languages": "^0.12.2",
"monaco-themes": "^0.4.4", "monaco-themes": "^0.4.4",
"nprogress": "^0.2.0", "nprogress": "^0.2.0",
"pinia": "^2.3.1", "pinia": "^3.0.1",
"qrcode.vue": "^3.6.0", "qrcode.vue": "^3.6.0",
"screenfull": "^6.0.2", "screenfull": "^6.0.2",
"sortablejs": "^1.15.6", "sortablejs": "^1.15.6",
@@ -37,7 +37,7 @@
"trzsz": "^1.1.5", "trzsz": "^1.1.5",
"uuid": "^9.0.1", "uuid": "^9.0.1",
"vue": "^3.5.13", "vue": "^3.5.13",
"vue-i18n": "^11.1.0", "vue-i18n": "^11.1.1",
"vue-router": "^4.5.0", "vue-router": "^4.5.0",
"vuedraggable": "^4.1.0", "vuedraggable": "^4.1.0",
"xterm": "^5.3.0", "xterm": "^5.3.0",
@@ -60,9 +60,9 @@
"eslint": "^8.35.0", "eslint": "^8.35.0",
"eslint-plugin-vue": "^9.31.0", "eslint-plugin-vue": "^9.31.0",
"prettier": "^3.2.5", "prettier": "^3.2.5",
"sass": "^1.84.0", "sass": "^1.85.0",
"typescript": "^5.7.3", "typescript": "^5.7.3",
"vite": "^6.1.0", "vite": "^6.1.1",
"vite-plugin-progress": "0.0.7", "vite-plugin-progress": "0.0.7",
"vue-eslint-parser": "^9.4.3" "vue-eslint-parser": "^9.4.3"
}, },

View File

@@ -845,7 +845,7 @@ defineExpose({
font-weight: bold; font-weight: bold;
position: absolute; position: absolute;
top: -7px; top: -7px;
padding: 3px; padding: 2px;
} }
.column-right { .column-right {

View File

@@ -6,7 +6,7 @@
:key="column.columnName" :key="column.columnName"
class="w100 mb5" class="w100 mb5"
:prop="column.columnName" :prop="column.columnName"
:required="props.tableName != '' && !column.nullable && !column.isPrimaryKey && !column.isIdentity" :required="props.tableName != '' && !column.nullable && !column.isPrimaryKey && !column.autoIncrement"
> >
<template #label> <template #label>
<span class="pointer" :title="column?.columnComment ? `${column.columnType} | ${column.columnComment}` : column.columnType"> <span class="pointer" :title="column?.columnComment ? `${column.columnType} | ${column.columnComment}` : column.columnType">
@@ -19,7 +19,7 @@
:data-type="dbInst.getDialect().getDataType(column.dataType)" :data-type="dbInst.getDialect().getDataType(column.dataType)"
:placeholder="column?.columnComment ? `${column.columnType} | ${column.columnComment}` : column.columnType" :placeholder="column?.columnComment ? `${column.columnType} | ${column.columnComment}` : column.columnType"
:column-name="column.columnName" :column-name="column.columnName"
:disabled="column.isIdentity" :disabled="column.autoIncrement"
/> />
</el-form-item> </el-form-item>
</el-form> </el-form>

View File

@@ -537,7 +537,7 @@ watch(
numScale: a.showScale, numScale: a.showScale,
notNull: !a.nullable, notNull: !a.nullable,
pri: a.isPrimaryKey, pri: a.isPrimaryKey,
auto_increment: a.isIdentity /*a.extra?.indexOf('auto_increment') > -1*/, auto_increment: a.autoIncrement /*a.extra?.indexOf('auto_increment') > -1*/,
remark: a.columnComment, remark: a.columnComment,
}; };
state.tableData.fields.res.push(data); state.tableData.fields.res.push(data);

View File

@@ -13,8 +13,8 @@ require (
github.com/go-ldap/ldap/v3 v3.4.8 github.com/go-ldap/ldap/v3 v3.4.8
github.com/go-playground/locales v0.14.1 github.com/go-playground/locales v0.14.1
github.com/go-playground/universal-translator v0.18.1 github.com/go-playground/universal-translator v0.18.1
github.com/go-playground/validator/v10 v10.20.0 github.com/go-playground/validator/v10 v10.25.0
github.com/go-sql-driver/mysql v1.8.1 github.com/go-sql-driver/mysql v1.9.0
github.com/golang-jwt/jwt/v5 v5.2.1 github.com/golang-jwt/jwt/v5 v5.2.1
github.com/google/uuid v1.6.0 github.com/google/uuid v1.6.0
github.com/gorilla/websocket v1.5.3 github.com/gorilla/websocket v1.5.3
@@ -54,7 +54,7 @@ require (
github.com/davecgh/go-spew v1.1.1 // indirect github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
github.com/dustin/go-humanize v1.0.1 // indirect github.com/dustin/go-humanize v1.0.1 // indirect
github.com/gabriel-vasile/mimetype v1.4.3 // indirect github.com/gabriel-vasile/mimetype v1.4.8 // indirect
github.com/gin-contrib/sse v0.1.0 // indirect github.com/gin-contrib/sse v0.1.0 // indirect
github.com/glebarez/go-sqlite v1.21.2 // indirect github.com/glebarez/go-sqlite v1.21.2 // indirect
github.com/go-asn1-ber/asn1-ber v1.5.5 // indirect github.com/go-asn1-ber/asn1-ber v1.5.5 // indirect
@@ -92,7 +92,7 @@ require (
golang.org/x/arch v0.14.0 // indirect golang.org/x/arch v0.14.0 // indirect
golang.org/x/exp v0.0.0-20250210185358-939b2ce775ac // indirect golang.org/x/exp v0.0.0-20250210185358-939b2ce775ac // indirect
golang.org/x/image v0.23.0 // indirect golang.org/x/image v0.23.0 // indirect
golang.org/x/net v0.33.0 // indirect golang.org/x/net v0.34.0 // indirect
golang.org/x/sys v0.30.0 // indirect golang.org/x/sys v0.30.0 // indirect
golang.org/x/text v0.22.0 // indirect golang.org/x/text v0.22.0 // indirect
google.golang.org/protobuf v1.34.1 // indirect google.golang.org/protobuf v1.34.1 // indirect

View File

@@ -37,7 +37,7 @@ type Column struct {
DataType string `json:"dataType"` // 数据类型 DataType string `json:"dataType"` // 数据类型
ColumnComment string `json:"columnComment"` // 列备注 ColumnComment string `json:"columnComment"` // 列备注
IsPrimaryKey bool `json:"isPrimaryKey"` // 是否为主键 IsPrimaryKey bool `json:"isPrimaryKey"` // 是否为主键
IsIdentity bool `json:"isIdentity"` // 是否自增 AutoIncrement bool `json:"autoIncrement"` // 是否自增
ColumnDefault string `json:"columnDefault"` // 默认值 ColumnDefault string `json:"columnDefault"` // 默认值
Nullable bool `json:"nullable"` // 是否可为null Nullable bool `json:"nullable"` // 是否可为null
CharMaxLength int `json:"charMaxLength"` // 字符最大长度 CharMaxLength int `json:"charMaxLength"` // 字符最大长度

View File

@@ -67,7 +67,7 @@ SELECT table_name tableName,
WHEN extra LIKE '%%auto_increment%%' THEN WHEN extra LIKE '%%auto_increment%%' THEN
1 1
ELSE 0 ELSE 0
END AS isIdentity, END AS autoIncrement,
is_nullable nullable, is_nullable nullable,
CHARACTER_MAXIMUM_LENGTH charMaxLength, CHARACTER_MAXIMUM_LENGTH charMaxLength,
NUMERIC_SCALE numScale, NUMERIC_SCALE numScale,

View File

@@ -13,26 +13,26 @@ order by
n.nspname n.nspname
--------------------------------------- ---------------------------------------
--PGSQL_TABLE_INFO 表详细信息 --PGSQL_TABLE_INFO 表详细信息
select SELECT
c.relname as "tableName", c.relname AS "tableName",
obj_description (c.oid) as "tableComment", obj_description(c.oid) AS "tableComment",
pg_table_size ('"' || n.nspname || '"."' || c.relname || '"') as "dataLength", pg_total_relation_size(c.oid) AS "dataLength",
pg_indexes_size ('"' || n.nspname || '"."' || c.relname || '"') as "indexLength", pg_indexes_size(c.oid) AS "indexLength",
psut.n_live_tup as "tableRows" psut.n_live_tup AS "tableRows"
from FROM
pg_class c pg_class c
join pg_namespace n on JOIN
c.relnamespace = n.oid pg_namespace n ON c.relnamespace = n.oid
join pg_stat_user_tables psut on JOIN
psut.relid = c.oid pg_stat_user_tables psut ON psut.relid = c.oid
where WHERE
has_table_privilege(CAST(c.oid AS regclass), 'SELECT') has_table_privilege(c.oid, 'SELECT')
and n.nspname = current_schema() and n.nspname = current_schema()
and c.reltype > 0
{{if .tableNames}} {{if .tableNames}}
and c.relname in ({{.tableNames}}) and c.relname in ({{.tableNames}})
{{end}} {{end}}
order by c.relname ORDER BY
c.relname;
--------------------------------------- ---------------------------------------
--PGSQL_INDEX_INFO 表索引信息 --PGSQL_INDEX_INFO 表索引信息
SELECT a.indexname AS "indexName", SELECT a.indexname AS "indexName",
@@ -51,20 +51,58 @@ WHERE a.schemaname = (select current_schema())
AND a.indexname not like '%%_pkey' AND a.indexname not like '%%_pkey'
--------------------------------------- ---------------------------------------
--PGSQL_COLUMN_MA 表列信息 --PGSQL_COLUMN_MA 表列信息
SELECT a.table_name AS "tableName", SELECT
a.table_name AS "tableName",
a.column_name AS "columnName", a.column_name AS "columnName",
a.is_nullable AS "nullable", a.is_nullable AS "nullable",
a.udt_name AS "dataType", t.typname AS "dataType",
a.character_maximum_length AS "charMaxLength", a.character_maximum_length AS "charMaxLength",
a.numeric_precision AS "numPrecision", a.numeric_precision AS "numPrecision",
case when a.column_default like 'nextval%%' then null else a.column_default end AS "columnDefault", CASE
WHEN a.column_default LIKE 'nextval%%' THEN NULL
ELSE a.column_default
END AS "columnDefault",
a.numeric_scale AS "numScale", a.numeric_scale AS "numScale",
case when a.column_default like 'nextval%%' then 1 else 0 end AS "isIdentity", CASE
case when b.column_name is not null then 1 else 0 end AS "isPrimaryKey", WHEN a.column_default LIKE 'nextval%%' THEN 1
col_description((a.table_schema || '.' || a.table_name) ::regclass, a.ordinal_position) AS "columnComment" ELSE 0
FROM information_schema.columns a END AS "autoIncrement",
left join information_schema.key_column_usage b CASE
on a.table_schema = b.table_schema and b.table_name = a.table_name and b.column_name = a.column_name WHEN b.column_name IS NOT NULL THEN 1
WHERE a.table_schema = (select current_schema()) ELSE 0
and a.table_name in (%s) END AS "isPrimaryKey",
order by a.table_name, a.ordinal_position (
SELECT
description
FROM
pg_description
WHERE
objoid = c.oid
AND objsubid = a.ordinal_position
) AS "columnComment"
FROM
information_schema.columns a
LEFT JOIN information_schema.key_column_usage b ON a.table_schema = b.table_schema
AND b.table_name = a.table_name
AND b.column_name = a.column_name
JOIN pg_catalog.pg_class c ON c.relname = a.table_name
AND c.relnamespace = (
SELECT
oid
FROM
pg_catalog.pg_namespace
WHERE
nspname = a.table_schema
)
JOIN pg_catalog.pg_attribute att ON att.attrelid = c.oid
AND att.attname = a.column_name
JOIN pg_catalog.pg_type t ON t.oid = att.atttypid
WHERE
a.table_schema = (
SELECT
current_schema()
)
AND a.table_name IN (%s)
ORDER BY
a.table_name,
a.ordinal_position;

View File

@@ -106,7 +106,7 @@ func (dd *DMMetadata) GetColumns(tableNames ...string) ([]dbi.Column, error) {
ColumnComment: cast.ToString(re["COLUMN_COMMENT"]), ColumnComment: cast.ToString(re["COLUMN_COMMENT"]),
Nullable: cast.ToString(re["NULLABLE"]) == "YES", Nullable: cast.ToString(re["NULLABLE"]) == "YES",
IsPrimaryKey: cast.ToInt(re["IS_PRIMARY_KEY"]) == 1, IsPrimaryKey: cast.ToInt(re["IS_PRIMARY_KEY"]) == 1,
IsIdentity: cast.ToInt(re["IS_IDENTITY"]) == 1, AutoIncrement: cast.ToInt(re["IS_IDENTITY"]) == 1,
ColumnDefault: cast.ToString(re["COLUMN_DEFAULT"]), ColumnDefault: cast.ToString(re["COLUMN_DEFAULT"]),
NumPrecision: cast.ToInt(re["NUM_PRECISION"]), NumPrecision: cast.ToInt(re["NUM_PRECISION"]),
NumScale: cast.ToInt(re["NUM_SCALE"]), NumScale: cast.ToInt(re["NUM_SCALE"]),

View File

@@ -93,7 +93,7 @@ func (sg *SQLGenerator) GenInsert(tableName string, columns []dbi.Column, values
identityInsertOn := "" identityInsertOn := ""
identityInsertOff := "" identityInsertOff := ""
// 有自增列的才加上这个语句 // 有自增列的才加上这个语句
if collx.AnyMatch(columns, func(column dbi.Column) bool { return column.IsIdentity }) { if collx.AnyMatch(columns, func(column dbi.Column) bool { return column.AutoIncrement }) {
identityInsertOn = fmt.Sprintf("set identity_insert %s on;", quote(tableName)) identityInsertOn = fmt.Sprintf("set identity_insert %s on;", quote(tableName))
hasIdentity = true hasIdentity = true
res = append(res, identityInsertOn) res = append(res, identityInsertOn)
@@ -124,7 +124,7 @@ func (sg *SQLGenerator) GenInsert(tableName string, columns []dbi.Column, values
uniqueCols = append(uniqueCols, col.ColumnName) uniqueCols = append(uniqueCols, col.ColumnName)
caseSqls = append(caseSqls, fmt.Sprintf("( T1.%s = T2.%s )", quote(col.ColumnName), quote(col.ColumnName))) caseSqls = append(caseSqls, fmt.Sprintf("( T1.%s = T2.%s )", quote(col.ColumnName), quote(col.ColumnName)))
} }
if col.IsIdentity { if col.AutoIncrement {
// 自增字段不放入insert内即使是设置了identity_insert on也不起作用 // 自增字段不放入insert内即使是设置了identity_insert on也不起作用
identityCols = append(identityCols, quote(col.ColumnName)) identityCols = append(identityCols, quote(col.ColumnName))
} }
@@ -178,7 +178,7 @@ func (sg *SQLGenerator) genColumnBasicSql(quoter dbi.Quoter, column dbi.Column)
dataType := column.DataType dataType := column.DataType
incr := "" incr := ""
if column.IsIdentity { if column.AutoIncrement {
incr = " IDENTITY" incr = " IDENTITY"
} }

View File

@@ -1,17 +1,9 @@
package mssql package mssql
import ( import (
"fmt"
"mayfly-go/internal/db/dbm/dbi" "mayfly-go/internal/db/dbm/dbi"
) )
var (
DTOracleDate = dbi.DTDateTime.Copy().WithSQLValue(func(val any) string {
// oracle date型需要用函数包裹to_date('%s', 'yyyy-mm-dd hh24:mi:ss')
return fmt.Sprintf("to_date('%s', 'yyyy-mm-dd hh24:mi:ss')", val)
})
)
var ( var (
Bigint = dbi.NewDbDataType("bigint", dbi.DTInt64).WithCT(dbi.CTInt8) Bigint = dbi.NewDbDataType("bigint", dbi.DTInt64).WithCT(dbi.CTInt8)
Numeric = dbi.NewDbDataType("numeric", dbi.DTNumeric).WithCT(dbi.CTNumeric) Numeric = dbi.NewDbDataType("numeric", dbi.DTNumeric).WithCT(dbi.CTNumeric)

View File

@@ -54,7 +54,7 @@ func (md *MssqlDialect) CopyTable(copy *dbi.DbCopyTable) error {
hasIdentity := false hasIdentity := false
for _, v := range columns { for _, v := range columns {
columnNames = append(columnNames, fmt.Sprintf("[%s]", v.ColumnName)) columnNames = append(columnNames, fmt.Sprintf("[%s]", v.ColumnName))
if v.IsIdentity { if v.AutoIncrement {
hasIdentity = true hasIdentity = true
} }

View File

@@ -110,7 +110,7 @@ func (md *MssqlMetadata) GetColumns(tableNames ...string) ([]dbi.Column, error)
ColumnComment: anyx.ToString(re["COLUMN_COMMENT"]), ColumnComment: anyx.ToString(re["COLUMN_COMMENT"]),
Nullable: anyx.ToString(re["NULLABLE"]) == "YES", Nullable: anyx.ToString(re["NULLABLE"]) == "YES",
IsPrimaryKey: cast.ToInt(re["IS_PRIMARY_KEY"]) == 1, IsPrimaryKey: cast.ToInt(re["IS_PRIMARY_KEY"]) == 1,
IsIdentity: cast.ToInt(re["IS_IDENTITY"]) == 1, AutoIncrement: cast.ToInt(re["IS_IDENTITY"]) == 1,
ColumnDefault: cast.ToString(re["COLUMN_DEFAULT"]), ColumnDefault: cast.ToString(re["COLUMN_DEFAULT"]),
NumPrecision: cast.ToInt(re["NUM_PRECISION"]), NumPrecision: cast.ToInt(re["NUM_PRECISION"]),
NumScale: cast.ToInt(re["NUM_SCALE"]), NumScale: cast.ToInt(re["NUM_SCALE"]),

View File

@@ -190,7 +190,7 @@ func (sg *SQLGenerator) batchInsertSimple(tableName string, columns []dbi.Column
// 设置允许填充自增列之后,显示指定列名可以插入自增列 // 设置允许填充自增列之后,显示指定列名可以插入自增列
identityInsertOn := "" identityInsertOn := ""
for _, column := range columns { for _, column := range columns {
if column.IsIdentity { if column.AutoIncrement {
identityInsertOn = fmt.Sprintf("SET IDENTITY_INSERT [%s].[%s] ON", schema, tableName) identityInsertOn = fmt.Sprintf("SET IDENTITY_INSERT [%s].[%s] ON", schema, tableName)
} }
} }
@@ -221,7 +221,7 @@ func (sg *SQLGenerator) batchInsertMerge(tableName string, columns []dbi.Column,
hashIdentity := false hashIdentity := false
for _, col := range columns { for _, col := range columns {
if col.IsIdentity { if col.AutoIncrement {
hashIdentity = true hashIdentity = true
identityCols = append(identityCols, col.ColumnName) identityCols = append(identityCols, col.ColumnName)
} }
@@ -286,7 +286,7 @@ func (sg *SQLGenerator) genColumnBasicSql(quoter dbi.Quoter, column dbi.Column)
dataType := column.DataType dataType := column.DataType
incr := "" incr := ""
if column.IsIdentity { if column.AutoIncrement {
incr = " IDENTITY(1,1)" incr = " IDENTITY(1,1)"
} }

View File

@@ -105,7 +105,7 @@ func (md *MysqlMetadata) GetColumns(tableNames ...string) ([]dbi.Column, error)
ColumnComment: cast.ToString(re["columnComment"]), ColumnComment: cast.ToString(re["columnComment"]),
Nullable: cast.ToString(re["nullable"]) == "YES", Nullable: cast.ToString(re["nullable"]) == "YES",
IsPrimaryKey: cast.ToInt(re["isPrimaryKey"]) == 1, IsPrimaryKey: cast.ToInt(re["isPrimaryKey"]) == 1,
IsIdentity: cast.ToInt(re["isIdentity"]) == 1, AutoIncrement: cast.ToInt(re["autoIncrement"]) == 1,
ColumnDefault: cast.ToString(re["columnDefault"]), ColumnDefault: cast.ToString(re["columnDefault"]),
CharMaxLength: cast.ToInt(re["charMaxLength"]), CharMaxLength: cast.ToInt(re["charMaxLength"]),
NumPrecision: cast.ToInt(re["numPrecision"]), NumPrecision: cast.ToInt(re["numPrecision"]),

View File

@@ -99,7 +99,7 @@ func (msg *SQLGenerator) genColumnBasicSql(quoter dbi.Quoter, column dbi.Column)
dataType := column.DataType dataType := column.DataType
incr := "" incr := ""
if column.IsIdentity { if column.AutoIncrement {
incr = " AUTO_INCREMENT" incr = " AUTO_INCREMENT"
} }

View File

@@ -270,7 +270,7 @@ func (od *OracleDialect) GetSQLGenerator() dbi.SQLGenerator {
func (od *OracleDialect) genColumnBasicSql(column dbi.Column) string { func (od *OracleDialect) genColumnBasicSql(column dbi.Column) string {
colName := od.Quoter().Quote(column.ColumnName) colName := od.Quoter().Quote(column.ColumnName)
if column.IsIdentity { if column.AutoIncrement {
// 如果是自增不需要设置默认值和空值自增列数据类型必须是number // 如果是自增不需要设置默认值和空值自增列数据类型必须是number
return fmt.Sprintf(" %s NUMBER generated by default as IDENTITY", colName) return fmt.Sprintf(" %s NUMBER generated by default as IDENTITY", colName)
} }

View File

@@ -130,7 +130,7 @@ func (od *OracleMetadata) GetColumns(tableNames ...string) ([]dbi.Column, error)
ColumnComment: cast.ToString(re["COLUMN_COMMENT"]), ColumnComment: cast.ToString(re["COLUMN_COMMENT"]),
Nullable: cast.ToString(re["NULLABLE"]) == "YES", Nullable: cast.ToString(re["NULLABLE"]) == "YES",
IsPrimaryKey: cast.ToInt(re["IS_PRIMARY_KEY"]) == 1, IsPrimaryKey: cast.ToInt(re["IS_PRIMARY_KEY"]) == 1,
IsIdentity: cast.ToInt(re["IS_IDENTITY"]) == 1, AutoIncrement: cast.ToInt(re["IS_IDENTITY"]) == 1,
ColumnDefault: cast.ToString(re["COLUMN_DEFAULT"]), ColumnDefault: cast.ToString(re["COLUMN_DEFAULT"]),
NumPrecision: cast.ToInt(re["NUM_PRECISION"]), NumPrecision: cast.ToInt(re["NUM_PRECISION"]),
NumScale: cast.ToInt(re["NUM_SCALE"]), NumScale: cast.ToInt(re["NUM_SCALE"]),

View File

@@ -57,7 +57,7 @@ func (od *OracleMetadata11) GetColumns(tableNames ...string) ([]dbi.Column, erro
ColumnComment: cast.ToString(re["COLUMN_COMMENT"]), ColumnComment: cast.ToString(re["COLUMN_COMMENT"]),
Nullable: cast.ToString(re["NULLABLE"]) == "YES", Nullable: cast.ToString(re["NULLABLE"]) == "YES",
IsPrimaryKey: cast.ToInt(re["IS_PRIMARY_KEY"]) == 1, IsPrimaryKey: cast.ToInt(re["IS_PRIMARY_KEY"]) == 1,
IsIdentity: cast.ToInt(re["IS_IDENTITY"]) == 1, AutoIncrement: cast.ToInt(re["IS_IDENTITY"]) == 1,
ColumnDefault: cast.ToString(re["COLUMN_DEFAULT"]), ColumnDefault: cast.ToString(re["COLUMN_DEFAULT"]),
NumPrecision: cast.ToInt(re["NUM_PRECISION"]), NumPrecision: cast.ToInt(re["NUM_PRECISION"]),
NumScale: cast.ToInt(re["NUM_SCALE"]), NumScale: cast.ToInt(re["NUM_SCALE"]),
@@ -73,7 +73,7 @@ func (od *OracleMetadata11) genColumnBasicSql(column dbi.Column) string {
dialect := od.dc.GetDialect() dialect := od.dc.GetDialect()
colName := dialect.Quoter().Quote(column.ColumnName) colName := dialect.Quoter().Quote(column.ColumnName)
if column.IsIdentity { if column.AutoIncrement {
// 11g以前的版本 如果是自增自增列数据类型必须是number不需要设置默认值和空值建表后设置自增序列 // 11g以前的版本 如果是自增自增列数据类型必须是number不需要设置默认值和空值建表后设置自增序列
return fmt.Sprintf(" %s NUMBER", colName) return fmt.Sprintf(" %s NUMBER", colName)
} }
@@ -96,7 +96,7 @@ func (od *OracleMetadata11) genColumnBasicSql(column dbi.Column) string {
func (od *OracleMetadata11) GenerateTableOtherDDL(tableInfo dbi.Table, quoteTableName string, columns []dbi.Column) []string { func (od *OracleMetadata11) GenerateTableOtherDDL(tableInfo dbi.Table, quoteTableName string, columns []dbi.Column) []string {
result := make([]string, 0) result := make([]string, 0)
for _, col := range columns { for _, col := range columns {
if col.IsIdentity { if col.AutoIncrement {
seqName := fmt.Sprintf("%s_%s_seq", tableInfo.TableName, col.ColumnName) seqName := fmt.Sprintf("%s_%s_seq", tableInfo.TableName, col.ColumnName)
trgName := fmt.Sprintf("%s_%s_trg", tableInfo.TableName, col.ColumnName) trgName := fmt.Sprintf("%s_%s_trg", tableInfo.TableName, col.ColumnName)
result = append(result, fmt.Sprintf("CREATE SEQUENCE %s START WITH 1 INCREMENT BY 1", seqName)) result = append(result, fmt.Sprintf("CREATE SEQUENCE %s START WITH 1 INCREMENT BY 1", seqName))

View File

@@ -134,7 +134,7 @@ func (sg *SQLGenerator) GenInsert(tableName string, columns []dbi.Column, values
uniqueCols = append(uniqueCols, col.ColumnName) uniqueCols = append(uniqueCols, col.ColumnName)
caseSqls = append(caseSqls, fmt.Sprintf("( T1.%s = T2.%s )", quote(col.ColumnName), quote(col.ColumnName))) caseSqls = append(caseSqls, fmt.Sprintf("( T1.%s = T2.%s )", quote(col.ColumnName), quote(col.ColumnName)))
} }
if col.IsIdentity { if col.AutoIncrement {
// 自增字段不放入insert内即使是设置了identity_insert on也不起作用 // 自增字段不放入insert内即使是设置了identity_insert on也不起作用
identityCols = append(identityCols, quote(col.ColumnName)) identityCols = append(identityCols, quote(col.ColumnName))
} }
@@ -186,7 +186,7 @@ func (sg *SQLGenerator) GenInsert(tableName string, columns []dbi.Column, values
func (msg *SQLGenerator) genColumnBasicSql(quoter dbi.Quoter, column dbi.Column) string { func (msg *SQLGenerator) genColumnBasicSql(quoter dbi.Quoter, column dbi.Column) string {
colName := quoter.Quote(column.ColumnName) colName := quoter.Quote(column.ColumnName)
if column.IsIdentity { if column.AutoIncrement {
// 如果是自增不需要设置默认值和空值自增列数据类型必须是number // 如果是自增不需要设置默认值和空值自增列数据类型必须是number
return fmt.Sprintf(" %s NUMBER generated by default as IDENTITY", colName) return fmt.Sprintf(" %s NUMBER generated by default as IDENTITY", colName)
} }
@@ -214,7 +214,7 @@ func (sg *SQLGenerator) GenerateTableOtherDDL(tableInfo dbi.Table, quoteTableNam
func (sg *SQLGenerator) Oracle11GenerateTableOtherDDL(tableInfo dbi.Table, quoteTableName string, columns []dbi.Column) []string { func (sg *SQLGenerator) Oracle11GenerateTableOtherDDL(tableInfo dbi.Table, quoteTableName string, columns []dbi.Column) []string {
result := make([]string, 0) result := make([]string, 0)
for _, col := range columns { for _, col := range columns {
if col.IsIdentity { if col.AutoIncrement {
seqName := fmt.Sprintf("%s_%s_seq", tableInfo.TableName, col.ColumnName) seqName := fmt.Sprintf("%s_%s_seq", tableInfo.TableName, col.ColumnName)
trgName := fmt.Sprintf("%s_%s_trg", tableInfo.TableName, col.ColumnName) trgName := fmt.Sprintf("%s_%s_trg", tableInfo.TableName, col.ColumnName)
result = append(result, fmt.Sprintf("CREATE SEQUENCE %s START WITH 1 INCREMENT BY 1", seqName)) result = append(result, fmt.Sprintf("CREATE SEQUENCE %s START WITH 1 INCREMENT BY 1", seqName))

View File

@@ -30,7 +30,7 @@ type DumpHelper struct {
func (dh *DumpHelper) AfterInsert(writer io.Writer, tableName string, columns []dbi.Column) { func (dh *DumpHelper) AfterInsert(writer io.Writer, tableName string, columns []dbi.Column) {
// 设置自增序列当前值 // 设置自增序列当前值
for _, column := range columns { for _, column := range columns {
if column.IsIdentity { if column.AutoIncrement {
seq := fmt.Sprintf("SELECT setval('%s_%s_seq', (SELECT max(%s) FROM %s));\n", tableName, column.ColumnName, column.ColumnName, tableName) seq := fmt.Sprintf("SELECT setval('%s_%s_seq', (SELECT max(%s) FROM %s));\n", tableName, column.ColumnName, column.ColumnName, tableName)
writer.Write([]byte(seq)) writer.Write([]byte(seq))
} }

View File

@@ -105,7 +105,7 @@ func (pd *PgsqlMetadata) GetColumns(tableNames ...string) ([]dbi.Column, error)
ColumnComment: cast.ToString(re["columnComment"]), ColumnComment: cast.ToString(re["columnComment"]),
Nullable: cast.ToString(re["nullable"]) == "YES", Nullable: cast.ToString(re["nullable"]) == "YES",
IsPrimaryKey: cast.ToInt(re["isPrimaryKey"]) == 1, IsPrimaryKey: cast.ToInt(re["isPrimaryKey"]) == 1,
IsIdentity: cast.ToInt(re["isIdentity"]) == 1, AutoIncrement: cast.ToInt(re["autoIncrement"]) == 1,
ColumnDefault: cast.ToString(re["columnDefault"]), ColumnDefault: cast.ToString(re["columnDefault"]),
NumPrecision: cast.ToInt(re["numPrecision"]), NumPrecision: cast.ToInt(re["numPrecision"]),
NumScale: cast.ToInt(re["numScale"]), NumScale: cast.ToInt(re["numScale"]),

View File

@@ -214,7 +214,7 @@ func (pd *SQLGenerator) genColumnBasicSql(quoter dbi.Quoter, column dbi.Column)
} }
// 如果是自增类型需要转换为serial // 如果是自增类型需要转换为serial
if column.IsIdentity { if column.AutoIncrement {
if dataType == "int4" { if dataType == "int4" {
column.DataType = "serial" column.DataType = "serial"
} else if dataType == "int2" { } else if dataType == "int2" {

View File

@@ -122,7 +122,7 @@ func (sd *SqliteMetadata) GetColumns(tableNames ...string) ([]dbi.Column, error)
ColumnComment: "", ColumnComment: "",
Nullable: cast.ToInt(re["notnull"]) != 1, Nullable: cast.ToInt(re["notnull"]) != 1,
IsPrimaryKey: cast.ToInt(re["pk"]) == 1, IsPrimaryKey: cast.ToInt(re["pk"]) == 1,
IsIdentity: cast.ToInt(re["pk"]) == 1, AutoIncrement: cast.ToInt(re["pk"]) == 1,
ColumnDefault: defaultValue, ColumnDefault: defaultValue,
NumScale: 0, NumScale: 0,
} }

View File

@@ -83,7 +83,7 @@ func (ssg *SQLGenerator) GenInsert(tableName string, columns []dbi.Column, value
func (ssg *SQLGenerator) genColumnBasicSql(quoter dbi.Quoter, column dbi.Column) string { func (ssg *SQLGenerator) genColumnBasicSql(quoter dbi.Quoter, column dbi.Column) string {
incr := "" incr := ""
if column.IsIdentity { if column.AutoIncrement {
incr = " AUTOINCREMENT" incr = " AUTOINCREMENT"
} }

View File

@@ -11,6 +11,6 @@ type DbSql struct {
DbId uint64 `json:"dbId" gorm:"not null;"` DbId uint64 `json:"dbId" gorm:"not null;"`
Db string `json:"db" gorm:"size:100;not null;"` Db string `json:"db" gorm:"size:100;not null;"`
Type int `json:"type" gorm:"not null;"` // 类型 Type int `json:"type" gorm:"not null;"` // 类型
Sql string `json:"sql" gorm:"size:4000;comment:sql语句"` Sql string `json:"sql" gorm:"type:text;comment:sql语句"`
Name string `json:"name" gorm:"size:255;not null;comment:sql模板名"` Name string `json:"name" gorm:"size:255;not null;comment:sql模板名"`
} }

View File

@@ -8,7 +8,7 @@ type MachineFileForm struct {
Id uint64 `json:"id"` Id uint64 `json:"id"`
Name string `json:"name" binding:"required"` Name string `json:"name" binding:"required"`
MachineId uint64 `json:"machineId" binding:"required"` MachineId uint64 `json:"machineId" binding:"required"`
Type int `json:"type" binding:"required"` Type int8 `json:"type" binding:"required"`
Path string `json:"path" binding:"required"` Path string `json:"path" binding:"required"`
} }

View File

@@ -74,11 +74,11 @@ func (mcj *MachineCronJobVO) GetRelateId() uint64 {
} }
type MachineFileVO struct { type MachineFileVO struct {
Id *int64 `json:"id"` Id int64 `json:"id"`
Name *string `json:"name"` Name string `json:"name"`
Path *string `json:"path"` Path string `json:"path"`
Type *int `json:"type"` Type int8 `json:"type"`
MachineId *uint64 `json:"machineId"` MachineId uint64 `json:"machineId"`
} }
type MachineFileInfo struct { type MachineFileInfo struct {

View File

@@ -7,6 +7,6 @@ type MachineFile struct {
Name string `json:"name" gorm:"not null;size:50;comment:机器文件配置linux一切皆文件故也可以表示目录"` // 机器文件配置linux一切皆文件故也可以表示目录 Name string `json:"name" gorm:"not null;size:50;comment:机器文件配置linux一切皆文件故也可以表示目录"` // 机器文件配置linux一切皆文件故也可以表示目录
MachineId uint64 `json:"machineId" gorm:"not null;comment:机器id"` // 机器id MachineId uint64 `json:"machineId" gorm:"not null;comment:机器id"` // 机器id
Type string `json:"type" gorm:"not null;size:32;comment:1目录2文件"` // 1目录2文件 Type int8 `json:"type" gorm:"not null;comment:1目录2文件"` // 1目录2文件
Path string `json:"path" gorm:"not null;size:150;comment:路径"` // 路径 Path string `json:"path" gorm:"not null;size:150;comment:路径"` // 路径
} }