mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-27 13:46:00 +00:00
type analysers for mysql, postgre
This commit is contained in:
@@ -4,7 +4,7 @@ const sql = require('./sql');
|
||||
|
||||
const DatabaseAnalyser = require('../default/DatabaseAnalyser');
|
||||
const { filter } = require('lodash');
|
||||
const { isTypeString } = require('@dbgate/tools');
|
||||
const { isTypeString, isTypeNumeric } = require('@dbgate/tools');
|
||||
|
||||
function objectTypeToField(type) {
|
||||
switch (type.trim()) {
|
||||
@@ -25,9 +25,19 @@ function objectTypeToField(type) {
|
||||
}
|
||||
}
|
||||
|
||||
function getColumnInfo({ isNullable, isIdentity, columnName, dataType, charMaxLength }) {
|
||||
function getColumnInfo({
|
||||
isNullable,
|
||||
isIdentity,
|
||||
columnName,
|
||||
dataType,
|
||||
charMaxLength,
|
||||
numericPrecision,
|
||||
numericScale,
|
||||
}) {
|
||||
let fullDataType = dataType;
|
||||
if (charMaxLength && isTypeString(dataType)) fullDataType = `${dataType}(${charMaxLength})`;
|
||||
if (numericPrecision && numericScale && isTypeNumeric(dataType))
|
||||
fullDataType = `${dataType}(${numericPrecision},${numericScale})`;
|
||||
return {
|
||||
columnName,
|
||||
dataType: fullDataType,
|
||||
|
||||
@@ -4,6 +4,8 @@ select c.name as columnName, t.name as dataType, c.object_id as objectId, c.is_i
|
||||
col.CHARACTER_MAXIMUM_LENGTH as charMaxLength,
|
||||
d.definition as defaultValue, d.name as defaultConstraint,
|
||||
m.definition as computedExpression, m.is_persisted as isPersisted, c.column_id as columnId,
|
||||
col.NUMERIC_PRECISION as numericPrecision,
|
||||
col.NUMERIC_SCALE as numericScale,
|
||||
-- TODO only if version >= 2008
|
||||
c.is_sparse as isSparse
|
||||
from sys.columns c
|
||||
|
||||
Reference in New Issue
Block a user