mirror of
https://gitee.com/dromara/mayfly-go
synced 2025-11-01 23:10:26 +08:00
fix: fixed some issues
This commit is contained in:
@@ -77,6 +77,7 @@ function build() {
|
||||
if [ "${copyDocScript}" == "1" ] ; then
|
||||
echo_green "Copy resources such as scripts [config.yml.example、readme.txt、startup.sh、shutdown.sh]"
|
||||
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_en.txt ${toFolder}
|
||||
cp ${server_folder}/resources/script/startup.sh ${toFolder}
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@element-plus/icons-vue": "^2.3.1",
|
||||
"@vueuse/core": "^12.5.0",
|
||||
"@vueuse/core": "^12.7.0",
|
||||
"asciinema-player": "^3.9.0",
|
||||
"axios": "^1.6.2",
|
||||
"clipboard": "^2.0.11",
|
||||
@@ -28,7 +28,7 @@
|
||||
"monaco-sql-languages": "^0.12.2",
|
||||
"monaco-themes": "^0.4.4",
|
||||
"nprogress": "^0.2.0",
|
||||
"pinia": "^2.3.1",
|
||||
"pinia": "^3.0.1",
|
||||
"qrcode.vue": "^3.6.0",
|
||||
"screenfull": "^6.0.2",
|
||||
"sortablejs": "^1.15.6",
|
||||
@@ -37,7 +37,7 @@
|
||||
"trzsz": "^1.1.5",
|
||||
"uuid": "^9.0.1",
|
||||
"vue": "^3.5.13",
|
||||
"vue-i18n": "^11.1.0",
|
||||
"vue-i18n": "^11.1.1",
|
||||
"vue-router": "^4.5.0",
|
||||
"vuedraggable": "^4.1.0",
|
||||
"xterm": "^5.3.0",
|
||||
@@ -60,9 +60,9 @@
|
||||
"eslint": "^8.35.0",
|
||||
"eslint-plugin-vue": "^9.31.0",
|
||||
"prettier": "^3.2.5",
|
||||
"sass": "^1.84.0",
|
||||
"sass": "^1.85.0",
|
||||
"typescript": "^5.7.3",
|
||||
"vite": "^6.1.0",
|
||||
"vite": "^6.1.1",
|
||||
"vite-plugin-progress": "0.0.7",
|
||||
"vue-eslint-parser": "^9.4.3"
|
||||
},
|
||||
|
||||
@@ -845,7 +845,7 @@ defineExpose({
|
||||
font-weight: bold;
|
||||
position: absolute;
|
||||
top: -7px;
|
||||
padding: 3px;
|
||||
padding: 2px;
|
||||
}
|
||||
|
||||
.column-right {
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
:key="column.columnName"
|
||||
class="w100 mb5"
|
||||
:prop="column.columnName"
|
||||
:required="props.tableName != '' && !column.nullable && !column.isPrimaryKey && !column.isIdentity"
|
||||
:required="props.tableName != '' && !column.nullable && !column.isPrimaryKey && !column.autoIncrement"
|
||||
>
|
||||
<template #label>
|
||||
<span class="pointer" :title="column?.columnComment ? `${column.columnType} | ${column.columnComment}` : column.columnType">
|
||||
@@ -19,7 +19,7 @@
|
||||
:data-type="dbInst.getDialect().getDataType(column.dataType)"
|
||||
:placeholder="column?.columnComment ? `${column.columnType} | ${column.columnComment}` : column.columnType"
|
||||
:column-name="column.columnName"
|
||||
:disabled="column.isIdentity"
|
||||
:disabled="column.autoIncrement"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
@@ -537,7 +537,7 @@ watch(
|
||||
numScale: a.showScale,
|
||||
notNull: !a.nullable,
|
||||
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,
|
||||
};
|
||||
state.tableData.fields.res.push(data);
|
||||
|
||||
@@ -13,8 +13,8 @@ require (
|
||||
github.com/go-ldap/ldap/v3 v3.4.8
|
||||
github.com/go-playground/locales v0.14.1
|
||||
github.com/go-playground/universal-translator v0.18.1
|
||||
github.com/go-playground/validator/v10 v10.20.0
|
||||
github.com/go-sql-driver/mysql v1.8.1
|
||||
github.com/go-playground/validator/v10 v10.25.0
|
||||
github.com/go-sql-driver/mysql v1.9.0
|
||||
github.com/golang-jwt/jwt/v5 v5.2.1
|
||||
github.com/google/uuid v1.6.0
|
||||
github.com/gorilla/websocket v1.5.3
|
||||
@@ -54,7 +54,7 @@ require (
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // 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/glebarez/go-sqlite v1.21.2 // 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/exp v0.0.0-20250210185358-939b2ce775ac // 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/text v0.22.0 // indirect
|
||||
google.golang.org/protobuf v1.34.1 // indirect
|
||||
|
||||
@@ -37,7 +37,7 @@ type Column struct {
|
||||
DataType string `json:"dataType"` // 数据类型
|
||||
ColumnComment string `json:"columnComment"` // 列备注
|
||||
IsPrimaryKey bool `json:"isPrimaryKey"` // 是否为主键
|
||||
IsIdentity bool `json:"isIdentity"` // 是否自增
|
||||
AutoIncrement bool `json:"autoIncrement"` // 是否自增
|
||||
ColumnDefault string `json:"columnDefault"` // 默认值
|
||||
Nullable bool `json:"nullable"` // 是否可为null
|
||||
CharMaxLength int `json:"charMaxLength"` // 字符最大长度
|
||||
|
||||
@@ -67,7 +67,7 @@ SELECT table_name tableName,
|
||||
WHEN extra LIKE '%%auto_increment%%' THEN
|
||||
1
|
||||
ELSE 0
|
||||
END AS isIdentity,
|
||||
END AS autoIncrement,
|
||||
is_nullable nullable,
|
||||
CHARACTER_MAXIMUM_LENGTH charMaxLength,
|
||||
NUMERIC_SCALE numScale,
|
||||
|
||||
@@ -13,26 +13,26 @@ order by
|
||||
n.nspname
|
||||
---------------------------------------
|
||||
--PGSQL_TABLE_INFO 表详细信息
|
||||
select
|
||||
c.relname as "tableName",
|
||||
obj_description (c.oid) as "tableComment",
|
||||
pg_table_size ('"' || n.nspname || '"."' || c.relname || '"') as "dataLength",
|
||||
pg_indexes_size ('"' || n.nspname || '"."' || c.relname || '"') as "indexLength",
|
||||
psut.n_live_tup as "tableRows"
|
||||
from
|
||||
pg_class c
|
||||
join pg_namespace n on
|
||||
c.relnamespace = n.oid
|
||||
join pg_stat_user_tables psut on
|
||||
psut.relid = c.oid
|
||||
where
|
||||
has_table_privilege(CAST(c.oid AS regclass), 'SELECT')
|
||||
and n.nspname = current_schema()
|
||||
and c.reltype > 0
|
||||
SELECT
|
||||
c.relname AS "tableName",
|
||||
obj_description(c.oid) AS "tableComment",
|
||||
pg_total_relation_size(c.oid) AS "dataLength",
|
||||
pg_indexes_size(c.oid) AS "indexLength",
|
||||
psut.n_live_tup AS "tableRows"
|
||||
FROM
|
||||
pg_class c
|
||||
JOIN
|
||||
pg_namespace n ON c.relnamespace = n.oid
|
||||
JOIN
|
||||
pg_stat_user_tables psut ON psut.relid = c.oid
|
||||
WHERE
|
||||
has_table_privilege(c.oid, 'SELECT')
|
||||
and n.nspname = current_schema()
|
||||
{{if .tableNames}}
|
||||
and c.relname in ({{.tableNames}})
|
||||
{{end}}
|
||||
order by c.relname
|
||||
ORDER BY
|
||||
c.relname;
|
||||
---------------------------------------
|
||||
--PGSQL_INDEX_INFO 表索引信息
|
||||
SELECT a.indexname AS "indexName",
|
||||
@@ -51,20 +51,58 @@ WHERE a.schemaname = (select current_schema())
|
||||
AND a.indexname not like '%%_pkey'
|
||||
---------------------------------------
|
||||
--PGSQL_COLUMN_MA 表列信息
|
||||
SELECT a.table_name AS "tableName",
|
||||
a.column_name AS "columnName",
|
||||
a.is_nullable AS "nullable",
|
||||
a.udt_name AS "dataType",
|
||||
a.character_maximum_length AS "charMaxLength",
|
||||
a.numeric_precision AS "numPrecision",
|
||||
case when a.column_default like 'nextval%%' then null else a.column_default end AS "columnDefault",
|
||||
a.numeric_scale AS "numScale",
|
||||
case when a.column_default like 'nextval%%' then 1 else 0 end AS "isIdentity",
|
||||
case when b.column_name is not null then 1 else 0 end AS "isPrimaryKey",
|
||||
col_description((a.table_schema || '.' || a.table_name) ::regclass, 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
|
||||
WHERE a.table_schema = (select current_schema())
|
||||
and a.table_name in (%s)
|
||||
order by a.table_name, a.ordinal_position
|
||||
SELECT
|
||||
a.table_name AS "tableName",
|
||||
a.column_name AS "columnName",
|
||||
a.is_nullable AS "nullable",
|
||||
t.typname AS "dataType",
|
||||
a.character_maximum_length AS "charMaxLength",
|
||||
a.numeric_precision AS "numPrecision",
|
||||
CASE
|
||||
WHEN a.column_default LIKE 'nextval%%' THEN NULL
|
||||
ELSE a.column_default
|
||||
END AS "columnDefault",
|
||||
a.numeric_scale AS "numScale",
|
||||
CASE
|
||||
WHEN a.column_default LIKE 'nextval%%' THEN 1
|
||||
ELSE 0
|
||||
END AS "autoIncrement",
|
||||
CASE
|
||||
WHEN b.column_name IS NOT NULL THEN 1
|
||||
ELSE 0
|
||||
END AS "isPrimaryKey",
|
||||
(
|
||||
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;
|
||||
|
||||
@@ -106,7 +106,7 @@ func (dd *DMMetadata) GetColumns(tableNames ...string) ([]dbi.Column, error) {
|
||||
ColumnComment: cast.ToString(re["COLUMN_COMMENT"]),
|
||||
Nullable: cast.ToString(re["NULLABLE"]) == "YES",
|
||||
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"]),
|
||||
NumPrecision: cast.ToInt(re["NUM_PRECISION"]),
|
||||
NumScale: cast.ToInt(re["NUM_SCALE"]),
|
||||
|
||||
@@ -93,7 +93,7 @@ func (sg *SQLGenerator) GenInsert(tableName string, columns []dbi.Column, values
|
||||
identityInsertOn := ""
|
||||
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))
|
||||
hasIdentity = true
|
||||
res = append(res, identityInsertOn)
|
||||
@@ -124,7 +124,7 @@ func (sg *SQLGenerator) GenInsert(tableName string, columns []dbi.Column, values
|
||||
uniqueCols = append(uniqueCols, 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也不起作用
|
||||
identityCols = append(identityCols, quote(col.ColumnName))
|
||||
}
|
||||
@@ -178,7 +178,7 @@ func (sg *SQLGenerator) genColumnBasicSql(quoter dbi.Quoter, column dbi.Column)
|
||||
dataType := column.DataType
|
||||
|
||||
incr := ""
|
||||
if column.IsIdentity {
|
||||
if column.AutoIncrement {
|
||||
incr = " IDENTITY"
|
||||
}
|
||||
|
||||
|
||||
@@ -1,17 +1,9 @@
|
||||
package mssql
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"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 (
|
||||
Bigint = dbi.NewDbDataType("bigint", dbi.DTInt64).WithCT(dbi.CTInt8)
|
||||
Numeric = dbi.NewDbDataType("numeric", dbi.DTNumeric).WithCT(dbi.CTNumeric)
|
||||
|
||||
@@ -54,7 +54,7 @@ func (md *MssqlDialect) CopyTable(copy *dbi.DbCopyTable) error {
|
||||
hasIdentity := false
|
||||
for _, v := range columns {
|
||||
columnNames = append(columnNames, fmt.Sprintf("[%s]", v.ColumnName))
|
||||
if v.IsIdentity {
|
||||
if v.AutoIncrement {
|
||||
hasIdentity = true
|
||||
}
|
||||
|
||||
|
||||
@@ -110,7 +110,7 @@ func (md *MssqlMetadata) GetColumns(tableNames ...string) ([]dbi.Column, error)
|
||||
ColumnComment: anyx.ToString(re["COLUMN_COMMENT"]),
|
||||
Nullable: anyx.ToString(re["NULLABLE"]) == "YES",
|
||||
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"]),
|
||||
NumPrecision: cast.ToInt(re["NUM_PRECISION"]),
|
||||
NumScale: cast.ToInt(re["NUM_SCALE"]),
|
||||
|
||||
@@ -190,7 +190,7 @@ func (sg *SQLGenerator) batchInsertSimple(tableName string, columns []dbi.Column
|
||||
// 设置允许填充自增列之后,显示指定列名可以插入自增列
|
||||
identityInsertOn := ""
|
||||
for _, column := range columns {
|
||||
if column.IsIdentity {
|
||||
if column.AutoIncrement {
|
||||
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
|
||||
|
||||
for _, col := range columns {
|
||||
if col.IsIdentity {
|
||||
if col.AutoIncrement {
|
||||
hashIdentity = true
|
||||
identityCols = append(identityCols, col.ColumnName)
|
||||
}
|
||||
@@ -286,7 +286,7 @@ func (sg *SQLGenerator) genColumnBasicSql(quoter dbi.Quoter, column dbi.Column)
|
||||
dataType := column.DataType
|
||||
|
||||
incr := ""
|
||||
if column.IsIdentity {
|
||||
if column.AutoIncrement {
|
||||
incr = " IDENTITY(1,1)"
|
||||
}
|
||||
|
||||
|
||||
@@ -105,7 +105,7 @@ func (md *MysqlMetadata) GetColumns(tableNames ...string) ([]dbi.Column, error)
|
||||
ColumnComment: cast.ToString(re["columnComment"]),
|
||||
Nullable: cast.ToString(re["nullable"]) == "YES",
|
||||
IsPrimaryKey: cast.ToInt(re["isPrimaryKey"]) == 1,
|
||||
IsIdentity: cast.ToInt(re["isIdentity"]) == 1,
|
||||
AutoIncrement: cast.ToInt(re["autoIncrement"]) == 1,
|
||||
ColumnDefault: cast.ToString(re["columnDefault"]),
|
||||
CharMaxLength: cast.ToInt(re["charMaxLength"]),
|
||||
NumPrecision: cast.ToInt(re["numPrecision"]),
|
||||
|
||||
@@ -99,7 +99,7 @@ func (msg *SQLGenerator) genColumnBasicSql(quoter dbi.Quoter, column dbi.Column)
|
||||
dataType := column.DataType
|
||||
|
||||
incr := ""
|
||||
if column.IsIdentity {
|
||||
if column.AutoIncrement {
|
||||
incr = " AUTO_INCREMENT"
|
||||
}
|
||||
|
||||
|
||||
@@ -270,7 +270,7 @@ func (od *OracleDialect) GetSQLGenerator() dbi.SQLGenerator {
|
||||
func (od *OracleDialect) genColumnBasicSql(column dbi.Column) string {
|
||||
colName := od.Quoter().Quote(column.ColumnName)
|
||||
|
||||
if column.IsIdentity {
|
||||
if column.AutoIncrement {
|
||||
// 如果是自增,不需要设置默认值和空值,自增列数据类型必须是number
|
||||
return fmt.Sprintf(" %s NUMBER generated by default as IDENTITY", colName)
|
||||
}
|
||||
|
||||
@@ -130,7 +130,7 @@ func (od *OracleMetadata) GetColumns(tableNames ...string) ([]dbi.Column, error)
|
||||
ColumnComment: cast.ToString(re["COLUMN_COMMENT"]),
|
||||
Nullable: cast.ToString(re["NULLABLE"]) == "YES",
|
||||
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"]),
|
||||
NumPrecision: cast.ToInt(re["NUM_PRECISION"]),
|
||||
NumScale: cast.ToInt(re["NUM_SCALE"]),
|
||||
|
||||
@@ -57,7 +57,7 @@ func (od *OracleMetadata11) GetColumns(tableNames ...string) ([]dbi.Column, erro
|
||||
ColumnComment: cast.ToString(re["COLUMN_COMMENT"]),
|
||||
Nullable: cast.ToString(re["NULLABLE"]) == "YES",
|
||||
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"]),
|
||||
NumPrecision: cast.ToInt(re["NUM_PRECISION"]),
|
||||
NumScale: cast.ToInt(re["NUM_SCALE"]),
|
||||
@@ -73,7 +73,7 @@ func (od *OracleMetadata11) genColumnBasicSql(column dbi.Column) string {
|
||||
dialect := od.dc.GetDialect()
|
||||
colName := dialect.Quoter().Quote(column.ColumnName)
|
||||
|
||||
if column.IsIdentity {
|
||||
if column.AutoIncrement {
|
||||
// 11g以前的版本 如果是自增,自增列数据类型必须是number,不需要设置默认值和空值,建表后设置自增序列
|
||||
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 {
|
||||
result := make([]string, 0)
|
||||
for _, col := range columns {
|
||||
if col.IsIdentity {
|
||||
if col.AutoIncrement {
|
||||
seqName := fmt.Sprintf("%s_%s_seq", 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))
|
||||
|
||||
@@ -134,7 +134,7 @@ func (sg *SQLGenerator) GenInsert(tableName string, columns []dbi.Column, values
|
||||
uniqueCols = append(uniqueCols, 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也不起作用
|
||||
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 {
|
||||
colName := quoter.Quote(column.ColumnName)
|
||||
|
||||
if column.IsIdentity {
|
||||
if column.AutoIncrement {
|
||||
// 如果是自增,不需要设置默认值和空值,自增列数据类型必须是number
|
||||
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 {
|
||||
result := make([]string, 0)
|
||||
for _, col := range columns {
|
||||
if col.IsIdentity {
|
||||
if col.AutoIncrement {
|
||||
seqName := fmt.Sprintf("%s_%s_seq", 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))
|
||||
|
||||
@@ -30,7 +30,7 @@ type DumpHelper struct {
|
||||
func (dh *DumpHelper) AfterInsert(writer io.Writer, tableName string, columns []dbi.Column) {
|
||||
// 设置自增序列当前值
|
||||
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)
|
||||
writer.Write([]byte(seq))
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@ func (pd *PgsqlMetadata) GetColumns(tableNames ...string) ([]dbi.Column, error)
|
||||
ColumnComment: cast.ToString(re["columnComment"]),
|
||||
Nullable: cast.ToString(re["nullable"]) == "YES",
|
||||
IsPrimaryKey: cast.ToInt(re["isPrimaryKey"]) == 1,
|
||||
IsIdentity: cast.ToInt(re["isIdentity"]) == 1,
|
||||
AutoIncrement: cast.ToInt(re["autoIncrement"]) == 1,
|
||||
ColumnDefault: cast.ToString(re["columnDefault"]),
|
||||
NumPrecision: cast.ToInt(re["numPrecision"]),
|
||||
NumScale: cast.ToInt(re["numScale"]),
|
||||
|
||||
@@ -214,7 +214,7 @@ func (pd *SQLGenerator) genColumnBasicSql(quoter dbi.Quoter, column dbi.Column)
|
||||
}
|
||||
|
||||
// 如果是自增类型,需要转换为serial
|
||||
if column.IsIdentity {
|
||||
if column.AutoIncrement {
|
||||
if dataType == "int4" {
|
||||
column.DataType = "serial"
|
||||
} else if dataType == "int2" {
|
||||
|
||||
@@ -122,7 +122,7 @@ func (sd *SqliteMetadata) GetColumns(tableNames ...string) ([]dbi.Column, error)
|
||||
ColumnComment: "",
|
||||
Nullable: cast.ToInt(re["notnull"]) != 1,
|
||||
IsPrimaryKey: cast.ToInt(re["pk"]) == 1,
|
||||
IsIdentity: cast.ToInt(re["pk"]) == 1,
|
||||
AutoIncrement: cast.ToInt(re["pk"]) == 1,
|
||||
ColumnDefault: defaultValue,
|
||||
NumScale: 0,
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
incr := ""
|
||||
if column.IsIdentity {
|
||||
if column.AutoIncrement {
|
||||
incr = " AUTOINCREMENT"
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,6 @@ type DbSql struct {
|
||||
DbId uint64 `json:"dbId" gorm:"not null;"`
|
||||
Db string `json:"db" gorm:"size:100;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模板名"`
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ type MachineFileForm struct {
|
||||
Id uint64 `json:"id"`
|
||||
Name string `json:"name" 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"`
|
||||
}
|
||||
|
||||
|
||||
@@ -74,11 +74,11 @@ func (mcj *MachineCronJobVO) GetRelateId() uint64 {
|
||||
}
|
||||
|
||||
type MachineFileVO struct {
|
||||
Id *int64 `json:"id"`
|
||||
Name *string `json:"name"`
|
||||
Path *string `json:"path"`
|
||||
Type *int `json:"type"`
|
||||
MachineId *uint64 `json:"machineId"`
|
||||
Id int64 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Path string `json:"path"`
|
||||
Type int8 `json:"type"`
|
||||
MachineId uint64 `json:"machineId"`
|
||||
}
|
||||
|
||||
type MachineFileInfo struct {
|
||||
|
||||
@@ -7,6 +7,6 @@ type MachineFile struct {
|
||||
|
||||
Name string `json:"name" gorm:"not null;size:50;comment:机器文件配置(linux一切皆文件,故也可以表示目录)"` // 机器文件配置(linux一切皆文件,故也可以表示目录)
|
||||
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:路径"` // 路径
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user