diff --git a/app/assets/index.tsx b/app/assets/index.tsx index 6ee1980c..37c2a8d6 100644 --- a/app/assets/index.tsx +++ b/app/assets/index.tsx @@ -1,3 +1,4 @@ +import { message } from 'antd'; import React from 'react'; import ReactDom from 'react-dom'; import { Provider } from 'react-redux'; @@ -5,7 +6,9 @@ import { BrowserRouter as Router } from 'react-router-dom'; import App from './App'; import { store } from './store'; - +message.config({ + maxCount: 1, +}); ReactDom.render( diff --git a/app/assets/utils/function.ts b/app/assets/utils/function.ts index dd5a46bd..3559792b 100644 --- a/app/assets/utils/function.ts +++ b/app/assets/utils/function.ts @@ -4,7 +4,7 @@ import _ from 'lodash'; import { keyWords } from '#assets/config/nebulaQL'; export const handleKeyword = (name: string) => { - return keyWords.includes(name) ? '`' + name + '`' : name; + return keyWords.includes(name.toLowerCase()) ? `\`${name}\`` : name; }; export const handleVidStringName = (name: string, spaceVidType?: string) => { diff --git a/app/assets/utils/gql.ts b/app/assets/utils/gql.ts index 408c8f4e..30fcdcc1 100644 --- a/app/assets/utils/gql.ts +++ b/app/assets/utils/gql.ts @@ -57,7 +57,7 @@ export const getExploreMatchGQL = (params: { const wheres = _filters ? `AND ALL(l IN e WHERE ${_filters})` : ''; const gql = `MATCH p=(v)${ edgeDirection === 'incoming' ? '<-' : '-' - }[e${edgeTypes.map(edge => `:${edge}`).join('|')}${_step}]${ + }[e${edgeTypes.map(edge => `:${handleKeyword(edge)}`).join('|')}${_step}]${ edgeDirection === 'outgoing' ? '->' : '-' }(v2) WHERE id(v) IN [${selectVertexes @@ -198,40 +198,40 @@ export const getAlterGQL = (params: { const date = config.fields .map(item => { const { name, type, value, fixedLength, allowNull, comment } = item; + const propertyName = handleKeyword(name); if (action === 'DROP') { - return name; - } else { - let str = `${name} ${ - type !== 'fixed_string' - ? type - : type + `(${fixedLength ? item.fixedLength : ''})` - } ${allowNull ? 'NULL' : 'NOT NULL'}`; - if (value) { - switch (type) { - case 'string': - case 'fixed_string': - str += ` DEFAULT "${value}"`; - break; - case 'timestamp': - const timestampReg = /^(\d{4})-(\d{2})-(\d{2})\s(\d{2}):(\d{2}):(\d{2})$/; - str += timestampReg.test(value) - ? ` DEFAULT "${value}"` - : ` DEFAULT ${value}`; - break; - default: - str += ` DEFAULT ${value}`; - } - } - if (comment) { - str += ` COMMENT "${comment}"`; + return propertyName; + } + let str = `${propertyName} ${ + type !== 'fixed_string' + ? type + : type + `(${fixedLength ? item.fixedLength : ''})` + } ${allowNull ? 'NULL' : 'NOT NULL'}`; + if (value) { + switch (type) { + case 'string': + case 'fixed_string': + str += ` DEFAULT "${value}"`; + break; + case 'timestamp': + const timestampReg = /^(\d{4})-(\d{2})-(\d{2})\s(\d{2}):(\d{2}):(\d{2})$/; + str += timestampReg.test(value) + ? ` DEFAULT "${value}"` + : ` DEFAULT ${value}`; + break; + default: + str += ` DEFAULT ${value}`; } - return str; } + if (comment) { + str += ` COMMENT "${comment}"`; + } + return str; }) .join(', '); content = `${action} (${date})`; } - const gql = `ALTER ${type} ${name} ${content}`; + const gql = `ALTER ${type} ${handleKeyword(name)} ${content}`; return gql; };